internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: ansible/ansible

Issue:
example script.py failing with import error
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and master branch are affected too.
-->

##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
<ansible/scripts/update.py

##### ANSIBLE VERSION
2.4.0.0

##### CONFIGURATION
<!---
If using Ansible 2.4 or above, paste the results of "ansible-config dump --only-changed"

Otherwise, mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).

-->

##### OS / ENVIRONMENT
<!---
N/A
-->

##### SUMMARY
update.py script failing with import error for Inventory module.
 from ansible.inventory import Inventory

##### STEPS TO REPRODUCE
python update.py

##### EXPECTED RESULTS
script should run successfully

##### ACTUAL RESULTS
Import error for  Inventory module.



Discussion:

Resolving patch:
diff --git a/examples/scripts/uptime.py b/examples/scripts/uptime.py
--- a/examples/scripts/uptime.py
+++ b/examples/scripts/uptime.py
@@ -3,7 +3,7 @@
 from collections import namedtuple
 
 from ansible.executor.task_queue_manager import TaskQueueManager
-from ansible.inventory import Inventory
+from ansible.inventory.manager import InventoryManager
 from ansible.parsing.dataloader import DataLoader
 from ansible.playbook.play import Play
 from ansible.plugins.callback import CallbackBase
@@ -33,21 +33,21 @@ def main():
     host_list = ['localhost', 'www.example.com', 'www.google.com']
     Options = namedtuple('Options', ['connection', 'module_path', 'forks', 'remote_user',
                                      'private_key_file', 'ssh_common_args', 'ssh_extra_args', 'sftp_extra_args',
-                                     'scp_extra_args', 'become', 'become_method', 'become_user', 'verbosity', 'check'])
+                                     'scp_extra_args', 'become', 'become_method', 'become_user', 'verbosity', 'check',
+                                     'diff'])
 
     # initialize needed objects
-    variable_manager = VariableManager()
     loader = DataLoader()
     options = Options(connection='smart', module_path='/usr/share/ansible', forks=100,
                       remote_user=None, private_key_file=None, ssh_common_args=None, ssh_extra_args=None,
                       sftp_extra_args=None, scp_extra_args=None, become=None, become_method=None,
-                      become_user=None, verbosity=None, check=False)
+                      become_user=None, verbosity=None, check=False, diff=False)
 
     passwords = dict()
 
     # create inventory and pass to var manager
-    inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list=host_list)
-    variable_manager.set_inventory(inventory)
+    inventory = InventoryManager(loader=loader, sources=','.join(host_list))
+    variable_manager = VariableManager(loader=loader, inventory=inventory)
 
     # create play with tasks
     play_source = dict(


Test patch:
Repository: ansible/ansible

Issue:
Ansible stable-2.4 uses fact cache for Inventory by default
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
* New Inventory plugins

##### ANSIBLE VERSION
```
nsible 2.4.1.0
  config file = /root/fact_caching/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /root/ansible_2.4.1/lib/python2.7/site-packages/ansible
  executable location = /root/ansible_2.4.1/bin/ansible
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
```

##### CONFIGURATION
```
ansible-config dump --only-changed
CACHE_PLUGIN(/root/fact_caching/ansible.cfg) = redis
CACHE_PLUGIN_TIMEOUT(/root/fact_caching/ansible.cfg) = 3600
```

##### OS / ENVIRONMENT
```
yum install redis
redis-server

virtualenv ansible_2.4.1
source ansible_2.4.1/bin/activate
pip install git+git://github.com/ansible/ansible.git@stable-2.4
pip install redis
```

##### SUMMARY
Ansible 2.4.1 uses the fact cache for dynamic inventory by default.

##### STEPS TO REPRODUCE

* Install the env listed above
* `git clone https://github.com/chrismeyersfsu/ansible-examples.git`
* `cd ansible-examples/ansible_stable-2.4/fact_cache_inventory`
* make
* remove `extra-host` from `inventory`
* make

##### EXPECTED RESULTS
* For host `extra-host` to not be in the inventory for the second make

##### ACTUAL RESULTS
* Host `extra-host` in the inventory for the second make



Discussion:
Same results when using most recent version of ansible devel `pip install git+git://github.com/ansible/ansible.git@8f62be7b7c93ec669fac26c8f2fc7a73d00c1f3c`

Resolving patch:
diff --git a/lib/ansible/inventory/manager.py b/lib/ansible/inventory/manager.py
--- a/lib/ansible/inventory/manager.py
+++ b/lib/ansible/inventory/manager.py
@@ -190,7 +190,7 @@ def _setup_inventory_plugins(self):
         if not self._inventory_plugins:
             raise AnsibleError("No inventory plugins available to generate inventory, make sure you have at least one whitelisted.")
 
-    def parse_sources(self, cache=True):
+    def parse_sources(self, cache=False):
         ''' iterate over inventory sources and parse each one to populate it'''
 
         self._setup_inventory_plugins()
@@ -214,7 +214,7 @@ def parse_sources(self, cache=True):
 
         self._inventory_plugins = []
 
-    def parse_source(self, source, cache=True):
+    def parse_source(self, source, cache=False):
         ''' Generate or update inventory for the source provided '''
 
         parsed = False


Test patch:
Repository: ansible/ansible

Issue:
inventory_file doesn't contain the pathname
 - Bug Report

##### COMPONENT NAME
Ansible core(?)

##### ANSIBLE VERSION
```
ansible 2.4.0.0
```

##### CONFIGURATION


##### OS / ENVIRONMENT
Ubuntu 16.04

##### SUMMARY
Former versions of Ansible returned the full path for inventory_file. Now it is only the filename.

##### STEPS TO REPRODUCE
ansible -m debug -a var=inventory_file localhost

##### EXPECTED RESULTS
This is the result with Ansible < 2.4.0
````
localhost | SUCCESS => {
    "inventory_file": "/var/lib/jenkins/workspace/openstack-ci/openstack-installer/inventory/inventory.py"
}
````

##### ACTUAL RESULTS
With Ansible 2.4.0
```
localhost | SUCCESS => {
    "inventory_file": "inventory.py"
}
```



Discussion:
I can confirm that regression bug: 

vars_files:
    - group_vars/{{ inventory_environment }}.yml
    - vault.ym

is not working any longer since

inventory_file contains the path w/o filename
inventory_file contains the filename w/o path

the 2.4.0 documentation states inventory_file contains path + filename.

So either the documentation is outdated or its a regression bug.

confirmed, in the refactor i mistakenly  took inventory_dir and inventory_file as complimentary, fixing.

Resolving patch:
diff --git a/lib/ansible/inventory/data.py b/lib/ansible/inventory/data.py
--- a/lib/ansible/inventory/data.py
+++ b/lib/ansible/inventory/data.py
@@ -19,7 +19,6 @@
 from __future__ import (absolute_import, division, print_function)
 __metaclass__ = type
 
-import os
 import sys
 
 from ansible import constants as C
@@ -187,7 +186,7 @@ def add_host(self, host, group=None, port=None):
             h = Host(host, port)
             self.hosts[host] = h
             if self.current_source:  # set to 'first source' in which host was encountered
-                self.set_variable(host, 'inventory_file', os.path.basename(self.current_source))
+                self.set_variable(host, 'inventory_file', self.current_source)
                 self.set_variable(host, 'inventory_dir', basedir(self.current_source))
             else:
                 self.set_variable(host, 'inventory_file', None)


Test patch:
Repository: ansible/ansible

Issue:
ovirt_templates not overriding existing templates when exclusive is True

 - Bug Report

##### COMPONENT NAME
ovirt_template module 
##### ANSIBLE VERSION
```
ansible 2.3.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, May 10 2017, 20:04:28) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]
```

##### CONFIGURATION
n/a
##### OS / ENVIRONMENT
Fedora 25 and RHEL 7

##### SUMMARY
Assuming the ovirt enviroment already contains an existing template called "mytemplate".
Attempt to import "mytemplate" template with exclusive set to true.
```
 - ovirt_templates:
      auth: "{{ ovirt_auth }}"
      state: exported
      name: "mytemplate"
      export_domain: NFS
      storage_domain: SD1
      cluster: Default
      exclusive: True
      wait: True
```
Expecting that "mytemplate" will be overwritten when exclusive is set to True
The template is not overwritten.

##### STEPS TO REPRODUCE

1) Import Template "mytemplate"
2) execute code paste below [a]
3) Expecting 'mytemplate' to be overwritten it is not.

[a] Code Paste
```
 - ovirt_templates:
      auth: "{{ ovirt_auth }}"
      state: exported
      name: "mytemplate"
      export_domain: NFS
      storage_domain: SD1
      cluster: Default
      exclusive: True
      wait: True
```


##### EXPECTED RESULTS
Template to be overwritten

##### ACTUAL RESULTS
Template not overwritten




Discussion:
cc @machacekondra
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
cc @mwperina
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_templates.py b/lib/ansible/modules/cloud/ovirt/ovirt_templates.py
--- a/lib/ansible/modules/cloud/ovirt/ovirt_templates.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_templates.py
@@ -293,7 +293,7 @@ def main():
             ret = templates_module.action(
                 entity=template,
                 action='export',
-                action_condition=lambda t: export_template is None,
+                action_condition=lambda t: export_template is None or module.params['exclusive'],
                 wait_condition=lambda t: t is not None,
                 post_action=templates_module.post_export_action,
                 storage_domain=otypes.StorageDomain(id=export_service.get().id),


Test patch:
Repository: ansible/ansible

Issue:
oVirt - seal template functionality
##### ISSUE TYPE
 - Feature Idea

##### COMPONENT NAME
ovirt_templates

##### ANSIBLE VERSION
```
ansible 2.3.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, May 10 2017, 20:04:28) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]
```

##### SUMMARY
please add the option to seal a template in oVirt/RHV.
as described on - http://www.ovirt.org/develop/release-management/features/virt/virt-sysprep/



Discussion:
cc @machacekondra
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
cc @machacekondra
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
cc @mwperina
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_templates.py b/lib/ansible/modules/cloud/ovirt/ovirt_templates.py
--- a/lib/ansible/modules/cloud/ovirt/ovirt_templates.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_templates.py
@@ -96,6 +96,14 @@
             will be copied to the created template."
             - "This parameter is used only when C(state) I(present)."
         default: False
+    seal:
+        description:
+            - "'Sealing' is an operation that erases all machine-specific configurations from a filesystem:
+               This includes SSH keys, UDEV rules, MAC addresses, system ID, hostname, etc.
+               If I(true) subsequent virtual machines made from this template will avoid configuration inheritance."
+            - "This parameter is used only when C(state) I(present)."
+        default: False
+        version_added: "2.5"
 extends_documentation_fragment: ovirt
 '''
 
@@ -259,6 +267,7 @@ def main():
         image_provider=dict(default=None),
         image_disk=dict(default=None, aliases=['glance_image_disk_name']),
         template_image_disk_name=dict(default=None),
+        seal=dict(type='bool'),
     )
     module = AnsibleModule(
         argument_spec=argument_spec,
@@ -282,6 +291,7 @@ def main():
             ret = templates_module.create(
                 result_state=otypes.TemplateStatus.OK,
                 clone_permissions=module.params['clone_permissions'],
+                seal=module.params['seal'],
             )
         elif state == 'absent':
             ret = templates_module.remove()


Test patch:
Repository: ansible/ansible

Issue:
[cloudformation] 'state' is not a required option
The `cloudformation` doc specifies that the `state` option is **required**. But that is not the case in the argument spec in code -

> state=dict(default='present', choices=['present', 'absent'])

So either the doc needs to be fixed or we need to enforce the presence of the `state` option.

##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
`cloudformation`

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes below -->
```
ansible 2.5.0 last updated 2017/10/11 22:07:08 (GMT -700)
```

##### CONFIGURATION

N/A

##### OS / ENVIRONMENT

N/A

##### SUMMARY
The `cloudformation` doc specifies that the `state` option is **required**. But that is not the case in the argument spec in code -

> state=dict(default='present', choices=['present', 'absent'])

So either the doc needs to be fixed or we need to enforce the presence of the `state` option.


##### STEPS TO REPRODUCE

<!--- Paste example playbooks or commands between quotes below -->
```yaml
-  cloudformation:
    stack_name: "ansible-cloudformation"
    template: "files/cloudformation-example.json"
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
The task should have failed since `state` is absent. 

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->
The stack gets created as the default value for `state` is `present`




Discussion:
cc @jsmartin @ryansb @tedder
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Yeah, default + required is kinda silly. I'll remove required.

Resolving patch:
diff --git a/lib/ansible/modules/cloud/amazon/cloudformation.py b/lib/ansible/modules/cloud/amazon/cloudformation.py
--- a/lib/ansible/modules/cloud/amazon/cloudformation.py
+++ b/lib/ansible/modules/cloud/amazon/cloudformation.py
@@ -47,7 +47,9 @@
     description:
       - If state is "present", stack will be created.  If state is "present" and if stack exists and template has changed, it will be updated.
         If state is "absent", stack will be removed.
-    required: true
+    default: present
+    choices: [ present, absent ]
+    required: false
   template:
     description:
       - The local path of the cloudformation template.


Test patch:
Repository: ansible/ansible

Issue:
Hosts disappears from play host even when rescued in a block
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
core

##### ANSIBLE VERSION
```
ansible 2.3.0.0
  config file = /Users/jean0000/evrardjp/ansible-pocs/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.10 (default, Feb  7 2017, 00:08:15) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]
```

also applies in:
```
ansible 2.4.0.0
  config file = /Users/jean0000/evrardjp/ansible-pocs/ansible.cfg
  configured module search path = [u'/Users/jean0000/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/jean0000/.virtualenvs/ansible2.4/lib/python2.7/site-packages/ansible
  executable location = /Users/jean0000/.virtualenvs/ansible2.4/bin/ansible
  python version = 2.7.10 (default, Feb  7 2017, 00:08:15) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]
```

##### CONFIGURATION
Nothing edited. My config holds right now:
```
[defaults]
gathering = smart
```

##### OS / ENVIRONMENT
N/A

##### SUMMARY
Hosts disappears from play host even when rescued in a block

##### STEPS TO REPRODUCE
https://gist.github.com/evrardjp/564ebf6c18d335c3f8d5eaad639870c1

##### EXPECTED RESULTS
Host should still be part of the ansible_play_hosts after rescue
##### ACTUAL RESULTS
Host is not part of the ansible_play_hosts



Discussion:

Resolving patch:
diff --git a/lib/ansible/executor/play_iterator.py b/lib/ansible/executor/play_iterator.py
--- a/lib/ansible/executor/play_iterator.py
+++ b/lib/ansible/executor/play_iterator.py
@@ -370,6 +370,9 @@ def _get_next_task_from_state(self, state, host, peek, in_child=False):
             elif state.run_state == self.ITERATING_RESCUE:
                 # The process here is identical to ITERATING_TASKS, except instead
                 # we move into the always portion of the block.
+                if host.name in self._play._removed_hosts:
+                    self._play._removed_hosts.remove(host.name)
+
                 if state.rescue_child_state:
                     (state.rescue_child_state, task) = self._get_next_task_from_state(state.rescue_child_state, host=host, peek=peek, in_child=True)
                     if self._check_failed_state(state.rescue_child_state):


Test patch:
Repository: ansible/ansible

Issue:
Pause Prompt keeps input hidden in v2
In tasks I prompt for an AWS AMI and get the user input using register. Before ansible v2, I was able to see what I was typing in at the prompt. After v2 I am not longer able to see what I am typing. 

It seems it now defaults to private, but it there is no way to disable it.



Discussion:
+1
Please add private option to ansible 2.0 or revert old ansible 1.9 behavior.
Thank you

@bcoca any ETA on when this will get fixed? Saw it assigned to the stable 2.0 milestone but I don't see this resolved in the 2.1.0.0 release I'm using. 

+1
I have the same issue with Ansible 2.
I can not see my input with private no or without private option.

fix is not easy as we had to rewrite all the terminal input code, the old one used raw_input which allows echo, the new one sets the tty to 'raw' mode which does not.

@mwhite14 Greetings! Thanks for taking the time to open this issue. In order for the community to handle your issue effectively, we need a bit more information. 

Here are the items we could not find in your description:
- issue type
- ansible version
- component name

Please set the description of this issue with this template:
https://raw.githubusercontent.com/ansible/ansible/devel/.github/ISSUE_TEMPLATE.md

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: issue_missing_data --->
Any update on this issue? Without echoing the input the prompting in pause module looks unusable to us.
@soumyadipDe I'm digging into this. Not a simple fix but doing my best to find a solution.

Resolving patch:
diff --git a/lib/ansible/plugins/action/pause.py b/lib/ansible/plugins/action/pause.py
--- a/lib/ansible/plugins/action/pause.py
+++ b/lib/ansible/plugins/action/pause.py
@@ -140,6 +140,20 @@ def run(self, tmp=None, task_vars=None):
                     old_settings = termios.tcgetattr(fd)
                     tty.setraw(fd)
 
+                    # Enable a few things turned off by tty.setraw()
+                    # ICANON -> Allows characters to be deleted and hides things like ^M.
+                    # ICRNL -> Makes the return key work when ICANON is enabled, otherwise
+                    #          you get stuck at the prompt with no way to get out of it.
+                    # ECHO -> Echos input back to stdout
+                    #
+                    # See man termios for details on these flags
+                    if not seconds:
+                        new_settings = termios.tcgetattr(fd)
+                        new_settings[0] = new_settings[0] | termios.ICRNL
+                        new_settings[3] = new_settings[3] | (termios.ICANON | termios.ECHO)
+                        termios.tcsetattr(fd, termios.TCSANOW, new_settings)
+                        termios.tcsetattr(fd, termios.TCSANOW, new_settings)
+
                     # flush the buffer to make sure no previous key presses
                     # are read in below
                     termios.tcflush(stdin, termios.TCIFLUSH)


Test patch:
Repository: ansible/ansible

Issue:
The helm module claims to upgrade packages, but it doesn't
##### ISSUE TYPE
Bug Report

##### COMPONENT NAME
helm

##### ANSIBLE VERSION
```
ansible 2.5.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/foo/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.14 (default, Sep 20 2017, 01:25:59) [GCC 7.2.0]
```

##### CONFIGURATION
DEFAULT_STDOUT_CALLBACK(/etc/ansible/ansible.cfg) = debug

##### OS / ENVIRONMENT
N/A

##### SUMMARY
The module synopsis says "Install, upgrade, delete and list packages with the Helm package manager".
The module cannot be used to upgrade a package.

##### STEPS TO REPRODUCE
Use the module with chart.version=1, then with chart.version=2.

##### EXPECTED RESULTS
Expected the package to be upgraded when a newer chart.version was passed.

##### ACTUAL RESULTS
Nothing. Not even a warning. The task quietly passes, even though a different version was provided, than the one installed.

##### ANNOYANCE LEVEL
High.
Wasted a day debugging, reporting and working around #32513, only to find out the module does not implement the functionality it claims to provide, meaning I have to start from scratch, using helm cli.


Discussion:
cc @flaper87
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/modules/cloud/misc/helm.py b/lib/ansible/modules/cloud/misc/helm.py
--- a/lib/ansible/modules/cloud/misc/helm.py
+++ b/lib/ansible/modules/cloud/misc/helm.py
@@ -115,14 +115,19 @@ def install(module, tserver):
     namespace = module.params['namespace']
 
     chartb = chartbuilder.ChartBuilder(chart)
-    try:
+    r_matches = (x for x in tserver.list_releases()
+                 if x.name == name and x.namespace == namespace)
+    installed_release = next(r_matches, None)
+    if installed_release:
+        if installed_release.chart.metadata.version != chart['version']:
+            tserver.update_release(chartb.get_helm_chart(), False,
+                                   namespace, name=name, values=values)
+            changed = True
+    else:
         tserver.install_release(chartb.get_helm_chart(), namespace,
                                 dry_run=False, name=name,
                                 values=values)
         changed = True
-    except grpc._channel._Rendezvous as exc:
-        if "already exists" not in str(exc):
-            raise exc
 
     return dict(changed=changed)
 


Test patch: