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

Issue:
debugging module invocations in playbooks
Issue type: Feature idea
Ansible version: NA
Ansible configuration: NA
Environment: NA
Summary:

I find myself often building up complex module invocations, e.g. for the `ec2` module:

```
# Create EC2 instances using the VPC subnets and security groups and
# access key we configured above.

- name: Set up EC2 instances
  ec2:
    exact_count: 1
    count_tag: "{{ cluster_tags }}"
    image: "{{ item.0.image }}"
    region: "{{ item.0.region }}"
    group_id: "{{ item.2.group_id }}"
    instance_type: "{{ item.0.type }}"
    vpc_subnet_id: "{{ item.1.subnets[0].id }}"
    instance_tags: "{{ cluster_tags | merge(item.0.tags) }}"
    key_name: "{{ ec2_key_name }}"
    assign_public_ip: yes
    volumes: "{{ item.0.volumes }}"
    wait: yes
  with_together:
    - instances
    - vpcs.results
    - security_groups.results
  register: ec2_instances
```

…and then, when something goes wrong, adding a bunch of `debug:` tasks above this to see what's actually getting passed in. It would be _enormously_ and outrageously useful to be able to just add `debug:` to the beginning of this task and have it dump the arguments. If it's hard to deal with `debug: ec2: …` for some reason, I would be equally happy with `debug: [no ec2:, but original args]`. (Related to this is that `debug` ignores arguments it doesn't understand and just prints "here we are".)

Steps to reproduce: NA
Expected results: NA
Actual results: NA



Discussion:
I would prefer

``` yaml
- name: Set up EC2 instances
  debug_args: true
  ec2:
    exact_count: 1
    ...
```

Note: just returning `dict(failed=True, msg=str(self._task.args))` from `plugins/action/debug.py` does most of what I wanted, and adding `debug` to the list of `RAW_PARAM_MODULES` in `parsing/mod_args.py` makes it possible to debug tasks like `command`, which take raw args.


Resolving patch:
diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py
--- a/lib/ansible/plugins/action/__init__.py
+++ b/lib/ansible/plugins/action/__init__.py
@@ -347,7 +347,7 @@ def _execute_module(self, module_name=None, module_args=None, tmp=None, task_var
         if self._play_context.no_log:
             module_args['_ansible_no_log'] = True
 
-        self._display.debug("in _execute_module (%s, %s)" % (module_name, module_args))
+        self._display.vvv("Module: %s, args: %s" % (module_name, module_args))
 
         (module_style, shebang, module_data) = self._configure_module(module_name=module_name, module_args=module_args, task_vars=task_vars)
         if not shebang:


Test patch:
Repository: ansible/ansible

Issue:
ansible_os_family = "NA" on Manjaro host
##### Issue Type:

Bug Report
##### Ansible Version:

ansible 1.9.1
##### Ansible Configuration:

Standard
##### Environment:

Running a virtualenv on Arch.
##### Summary:

ansible_os_family returns "NA" for my Manjaro machine.
##### Steps To Reproduce:

ansible -m setup |grep ansible_os_family
##### Expected Results:

```
"ansible_os_family": "Archlinux",
```
##### Actual Results:

```
"ansible_os_family": "NA", 
```



Discussion:

Resolving patch:
diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py
--- a/lib/ansible/module_utils/facts.py
+++ b/lib/ansible/module_utils/facts.py
@@ -258,7 +258,7 @@ def get_distribution_facts(self):
             OracleLinux = 'RedHat', OVS = 'RedHat', OEL = 'RedHat', Amazon = 'RedHat',
             XenServer = 'RedHat', Ubuntu = 'Debian', Debian = 'Debian', Raspbian = 'Debian', Slackware = 'Slackware', SLES = 'Suse',
             SLED = 'Suse', openSUSE = 'Suse', SuSE = 'Suse', Gentoo = 'Gentoo', Funtoo = 'Gentoo',
-            Archlinux = 'Archlinux', Mandriva = 'Mandrake', Mandrake = 'Mandrake',
+            Archlinux = 'Archlinux', Manjaro = 'Archlinux', Mandriva = 'Mandrake', Mandrake = 'Mandrake',
             Solaris = 'Solaris', Nexenta = 'Solaris', OmniOS = 'Solaris', OpenIndiana = 'Solaris',
             SmartOS = 'Solaris', AIX = 'AIX', Alpine = 'Alpine', MacOSX = 'Darwin',
             FreeBSD = 'FreeBSD', HPUX = 'HP-UX'


Test patch:
Repository: ansible/ansible

Issue:
v2 regression: -T timeout doesn't work
With devel, `ansible -T 30` doesn't seem to set `self._play_context.timeout` at all (but setting `ANSIBLE_TIMEOUT` in the environment does). Anyone working on this already?



Discussion:
@amenonsen nope, go ahead and send a PR for it if you'd like to correct that.


Resolving patch:
diff --git a/lib/ansible/playbook/play_context.py b/lib/ansible/playbook/play_context.py
--- a/lib/ansible/playbook/play_context.py
+++ b/lib/ansible/playbook/play_context.py
@@ -241,6 +241,8 @@ def set_options(self, options):
             self.start_at_task = to_unicode(options.start_at_task)
         if hasattr(options, 'diff') and options.diff:
             self.diff = boolean(options.diff)
+        if hasattr(options, 'timeout') and options.timeout:
+            self.timeout = int(options.timeout)
 
         # get the tag info from options, converting a comma-separated list
         # of values into a proper list if need be. We check to see if the


Test patch:
Repository: ansible/ansible

Issue:
Crash (unhandled exception) on playbook for localhost with empty inventory
##### Issue Type:

Bug Report
##### Ansible Version:

ansible 2.0.0 (devel 2a50957ad8) last updated 2015/09/16 11:56:18 (GMT +200)
##### Ansible Configuration:

N/A
##### Environment:

FreeBSD melamine.cuivre.fr.eu.org 10.1-RELEASE-p5 FreeBSD 10.1-RELEASE-p5 #0: Tue Jan 27 08:55:07 UTC 2015     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
##### Summary:

Crash (unhandled exception) on playbook for localhost with empty inventory.
##### Steps To Reproduce:

Consider playbook ping.yml

```

---
- hosts: localhost
  tasks:
  - name: ping
    action: ping
```
##### Expected Results:

$ ansible-playbook ping.yml
 [WARNING]: provided hosts list is empty, only localhost is available

PLAY ***************************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [ping] ********************************************************************
ok: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0
##### Actual Results:

$ ansible-playbook ping.yml
 [WARNING]: provided hosts list is empty, only localhost is available

Unexpected Exception: 'NoneType' object has no attribute 'add_child_group'
to see the full traceback, use -vvv



Discussion:

Resolving patch:
diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py
--- a/lib/ansible/inventory/__init__.py
+++ b/lib/ansible/inventory/__init__.py
@@ -86,11 +86,16 @@ def parse_inventory(self, host_list):
 
         self.parser = None
 
+        # Always create the 'all' group, even if host_list is
+        # empty: in this case we will subsequently an the implicit
+        # 'localhost' to it.
+
+        all = Group('all')
+        self.groups = [ all ]
+
         if host_list is None:
             pass
         elif isinstance(host_list, list):
-            all = Group('all')
-            self.groups = [ all ]
             for h in host_list:
                 (host, port) = parse_address(h, allow_ranges=False)
                 all.add_host(Host(host, port))


Test patch:
Repository: ansible/ansible

Issue:
virtualization_type gets reported wrong for docker running on virtualised hardware
##### Issue Type:

Bug Report
##### Ansible Version:

`1.9.3`
##### Ansible Configuration:

n/a
##### Environment:

Ubuntu 14.04 guest inside Docker on Ubuntu 14.04 as host on top of Amazon EC2.
##### Summary:

When running a docker container on amazon the `virtualization_type` gets reported as `"xen"` instead of `"docker"`.
##### Steps To Reproduce:

Run `ansible localhost -m setup` inside of a Docker instance on amazon.
##### Expected Results:

`"ansible_virtualization_type": "docker"` should be visible in the output.
##### Actual Results:

`"ansible_virtualization_type": "xen"` is visible in the output.



Discussion:

Resolving patch:
diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py
--- a/lib/ansible/module_utils/facts.py
+++ b/lib/ansible/module_utils/facts.py
@@ -2582,6 +2582,17 @@ def populate(self):
 
     # For more information, check: http://people.redhat.com/~rjones/virt-what/
     def get_virtual_facts(self):
+        if os.path.exists('/proc/1/cgroup'):
+            for line in get_file_lines('/proc/1/cgroup'):
+                if re.search(r'/docker(/|-[0-9a-f]+\.scope)', line):
+                    self.facts['virtualization_type'] = 'docker'
+                    self.facts['virtualization_role'] = 'guest'
+                    return
+                if re.search('/lxc/', line):
+                    self.facts['virtualization_type'] = 'lxc'
+                    self.facts['virtualization_role'] = 'guest'
+                    return
+
         if os.path.exists("/proc/xen"):
             self.facts['virtualization_type'] = 'xen'
             self.facts['virtualization_role'] = 'guest'
@@ -2607,17 +2618,6 @@ def get_virtual_facts(self):
             self.facts['virtualization_role'] = 'guest'
             return
 
-        if os.path.exists('/proc/1/cgroup'):
-            for line in get_file_lines('/proc/1/cgroup'):
-                if re.search(r'/docker(/|-[0-9a-f]+\.scope)', line):
-                    self.facts['virtualization_type'] = 'docker'
-                    self.facts['virtualization_role'] = 'guest'
-                    return
-                if re.search('/lxc/', line):
-                    self.facts['virtualization_type'] = 'lxc'
-                    self.facts['virtualization_role'] = 'guest'
-                    return
-
         product_name = get_file_content('/sys/devices/virtual/dmi/id/product_name')
 
         if product_name in ['KVM', 'Bochs']:


Test patch:
Repository: ansible/ansible

Issue:
Return code is not checked when executing vault password script
...which means the error message is treated as a password and leads to potentially irreversibly encrypting the data with unknown password.



Discussion:

Resolving patch:
diff --git a/lib/ansible/cli/__init__.py b/lib/ansible/cli/__init__.py
--- a/lib/ansible/cli/__init__.py
+++ b/lib/ansible/cli/__init__.py
@@ -501,6 +501,8 @@ def read_vault_password_file(vault_password_file, loader):
             except OSError as e:
                 raise AnsibleError("Problem running vault password script %s (%s). If this is not a script, remove the executable bit from the file." % (' '.join(this_path), e))
             stdout, stderr = p.communicate()
+            if p.returncode != 0:
+                raise AnsibleError("Vault password script %s returned non-zero (%s)." % (this_path, p.returncode))
             vault_pass = stdout.strip('\r\n')
         else:
             try:


Test patch:
Repository: ansible/ansible

Issue:
make test_galaxy fails
A lot of code that was at the heart of ansible-galaxy has been ripped out and not replaced. 

This means that make test_galaxy trivially fails

We need something to replace ansible.utils.role_yaml_parse and ansible.utils.role_spec_parse, and make test_galaxy should pass its tests (those tests exist for a reason!)



Discussion:
i'm still in the process of reworking the interaction with roles for the install function, most of the other functionality is there.

closing as dupe of #11179


Resolving patch:
diff --git a/lib/ansible/playbook/role/include.py b/lib/ansible/playbook/role/include.py
--- a/lib/ansible/playbook/role/include.py
+++ b/lib/ansible/playbook/role/include.py
@@ -27,6 +27,7 @@
 from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject
 from ansible.playbook.attribute import Attribute, FieldAttribute
 from ansible.playbook.role.definition import RoleDefinition
+from ansible.playbook.role.requirement import RoleRequirement
 
 
 __all__ = ['RoleInclude']
@@ -47,6 +48,8 @@ def __init__(self, play=None, role_basedir=None, variable_manager=None, loader=N
     def load(data, play, current_role_path=None, parent_role=None, variable_manager=None, loader=None):
 
         assert isinstance(data, string_types) or isinstance(data, dict) or isinstance(data, AnsibleBaseYAMLObject)
+        if isinstance(data, string_types) and ',' in data:
+            data = RoleRequirement.role_spec_parse(data)
 
         ri = RoleInclude(play=play, role_basedir=current_role_path, variable_manager=variable_manager, loader=loader)
         return ri.load_data(data, variable_manager=variable_manager, loader=loader)


Test patch:
diff --git a/test/integration/galaxy_roles.yml b/test/integration/galaxy_roles.yml
--- a/test/integration/galaxy_roles.yml
+++ b/test/integration/galaxy_roles.yml
@@ -3,7 +3,7 @@
   name: oracle_java7
 
 - src: git+http://bitbucket.org/willthames/git-ansible-galaxy
-  version: v1.4
+  version: v1.6
 
 - src: http://bitbucket.org/willthames/hg-ansible-galaxy
   scm: hg
diff --git a/test/integration/galaxy_rolesfile b/test/integration/galaxy_rolesfile
--- a/test/integration/galaxy_rolesfile
+++ b/test/integration/galaxy_rolesfile
@@ -1,4 +1,4 @@
-git+https://bitbucket.org/willthames/git-ansible-galaxy,v1.4
+git+https://bitbucket.org/willthames/git-ansible-galaxy,v1.6
 hg+https://bitbucket.org/willthames/hg-ansible-galaxy
 https://bitbucket.org/willthames/http-ansible-galaxy/get/master.tar.gz,,http-role
 git+git@github.com:geerlingguy/ansible-role-php.git
Repository: ansible/ansible

Issue:
blocks don't take run_once
With ansible devel, it's possible to specify `delegate_to` on a block, but `run_once` isn't accepted.



Discussion:
literally just used my first block, and i was using it specifically to try a run_once on it, so i'd say its a fairly intuitive expectation of the block feature

Please add `ignore_errors` also in block. I got error for it too.

``` bash
# ansible-playbook -v vikas027.yaml
ERROR! 'ignore_errors' is not a valid attribute for a Block
```


Resolving patch:
diff --git a/lib/ansible/playbook/base.py b/lib/ansible/playbook/base.py
--- a/lib/ansible/playbook/base.py
+++ b/lib/ansible/playbook/base.py
@@ -53,6 +53,9 @@ class Base:
     # flags and misc. settings
     _environment         = FieldAttribute(isa='list')
     _no_log              = FieldAttribute(isa='bool')
+    _always_run           = FieldAttribute(isa='bool')
+    _run_once             = FieldAttribute(isa='bool')
+    _ignore_errors        = FieldAttribute(isa='bool')
 
     # param names which have been deprecated/removed
     DEPRECATED_ATTRIBUTES = [
diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py
--- a/lib/ansible/playbook/task.py
+++ b/lib/ansible/playbook/task.py
@@ -68,7 +68,6 @@ class Task(Base, Conditional, Taggable, Become):
     _args                 = FieldAttribute(isa='dict', default=dict())
     _action               = FieldAttribute(isa='string')
 
-    _always_run           = FieldAttribute(isa='bool')
     _any_errors_fatal     = FieldAttribute(isa='bool')
     _async                = FieldAttribute(isa='int', default=0)
     _changed_when         = FieldAttribute(isa='string')
@@ -76,7 +75,6 @@ class Task(Base, Conditional, Taggable, Become):
     _delegate_to          = FieldAttribute(isa='string')
     _failed_when          = FieldAttribute(isa='string')
     _first_available_file = FieldAttribute(isa='list')
-    _ignore_errors        = FieldAttribute(isa='bool')
     _loop                 = FieldAttribute(isa='string', private=True)
     _loop_args            = FieldAttribute(isa='list', private=True)
     _name                 = FieldAttribute(isa='string', default='')
@@ -84,7 +82,6 @@ class Task(Base, Conditional, Taggable, Become):
     _poll                 = FieldAttribute(isa='int')
     _register             = FieldAttribute(isa='string')
     _retries              = FieldAttribute(isa='int', default=1)
-    _run_once             = FieldAttribute(isa='bool')
     _until                = FieldAttribute(isa='list') # ?
 
     def __init__(self, block=None, role=None, task_include=None):


Test patch:
Repository: ansible/ansible

Issue:
include: fails during exception processing
Given a playbook like this:

```
- hosts: localhost
  tasks:
    - block:

        - include: failing_tasklist.yml

      always:

        - include: cleanup_tasklist.yml
```

Where `failing_tasklist.yml` looks like this:

```
- name: fail on purpose
  fail:
    msg: 'breaking things'
```

And `cleanup_tasklist.yml` looks like this:

```
- name: clean up
  debug:
    msg: 'cleaning things up'
```

I would expect Ansible to run `cleanup_tasklist.yml`, but the
resulting playbook run looks like this:

```
PLAY ***************************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [include] *****************************************************************
included: /home/lars/tmp/block-include-testcase/failing_tasklist.yml for localhost

TASK [fail on purpose] *********************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "breaking things"}

TASK [include] *****************************************************************

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=1   
```

So while it is parsing the `include` statement in the `always` section, it doesn't appear to be running it.  The `cleanup_tasklist.yml` tasklist **is** run if there are no failures in the `block:` tasks, e.g.:

```
- hosts: localhost
  tasks:
    - block:

        - debug:
            msg: not breaking

      always:

        - include: cleanup_tasklist.yml
```



Discussion:
To save you some copy-and-pasting, here's the testcase as a git repository:
- https://github.com/larsks/ansible-testcase-always-include

The problem is here, in `lib/ansible/playbook/included_file.py`:

```
def process_include_results(results, tqm, iterator, loader, variable_manager): included_files = []

    for res in results:
        if res._host.name in tqm._failed_hosts:
            continue
```

If we are handling an exception, then of course `res._host.name` is in
`tqm._failed_hosts`.  At first glance, this seems like the wrong place
to be making this check (shouldn't this be happening per-task
already?), but I'm not familiar enough with the code to make that
determination.


Resolving patch:
diff --git a/lib/ansible/playbook/included_file.py b/lib/ansible/playbook/included_file.py
--- a/lib/ansible/playbook/included_file.py
+++ b/lib/ansible/playbook/included_file.py
@@ -47,8 +47,6 @@ def process_include_results(results, tqm, iterator, loader, variable_manager):
         included_files = []
 
         for res in results:
-            if res._host.name in tqm._failed_hosts:
-                continue
 
             if res._task.action == 'include':
                 if res._task.loop:


Test patch:
Repository: ansible/ansible

Issue:
synchronize uses deprecated ansible_ssh_host variable
Synchronize module doesn't work for me.

http://docs.ansible.com/ansible/intro_inventory.html states that ansible_ssh_host is deprecated.
The synchronize module tries to use this deprecated variable with fallback to the inventory_hostname. Neither works for me:
- ansible_ssh_host is not defined, I use ansible_host.
- inventory_hostname is an alias that is not resolvable with dns.

I think the module should try ansible_host first, then ansible_ssh_host for legacy inventories and fall back to inventory_hostname.

Thanks!



Discussion:

Resolving patch:
diff --git a/lib/ansible/plugins/action/synchronize.py b/lib/ansible/plugins/action/synchronize.py
--- a/lib/ansible/plugins/action/synchronize.py
+++ b/lib/ansible/plugins/action/synchronize.py
@@ -131,7 +131,13 @@ def run(self, tmp=None, task_vars=None):
         src_host = '127.0.0.1'
         inventory_hostname = task_vars.get('inventory_hostname')
         dest_host_inventory_vars = task_vars['hostvars'].get(inventory_hostname)
-        dest_host = dest_host_inventory_vars.get('ansible_ssh_host', inventory_hostname)
+        try:
+            dest_host = dest_host_inventory_vars['ansible_host']
+        except KeyError:
+            try:
+                dest_host = dest_host_inventory_vars['ansible_ssh_host']
+            except KeyError:
+                dest_host = inventory_hostname
 
         dest_is_local = dest_host in C.LOCALHOST
 


Test patch:
Repository: ansible/ansible

Issue:
fact_caching_connection don't handle path expansion of ~ nor $HOME
Version: 1.9 but probably also devel.

When I configure a fact caching directory using the jsonfile cache plugin, I am specifying its path using the ~ or $HOME variable. This works with other parameters like retry_files_save_path but not with fact_caching_connection ... Ansible fails with a message that the directory does not exist. What is false.



Discussion:
@davidfischer-ch could you check devel? We have cleaned up a lot of issues there in regards to stuff like this, so this is probably fixed.

In this case current devel also does not do path expansions as this parameter is mostly used for network locations, only the jsonfile plugin overloads it for use as a path. Other parameters that are clearly and only paths do get expanded.


Resolving patch:
diff --git a/lib/ansible/plugins/cache/jsonfile.py b/lib/ansible/plugins/cache/jsonfile.py
--- a/lib/ansible/plugins/cache/jsonfile.py
+++ b/lib/ansible/plugins/cache/jsonfile.py
@@ -50,7 +50,7 @@ def __init__(self, *args, **kwargs):
 
         self._timeout = float(C.CACHE_PLUGIN_TIMEOUT)
         self._cache = {}
-        self._cache_dir = C.CACHE_PLUGIN_CONNECTION # expects a dir path
+        self._cache_dir = os.path.expandvars(os.path.expanduser(C.CACHE_PLUGIN_CONNECTION)) # expects a dir path
         if not self._cache_dir:
             raise AnsibleError("error, fact_caching_connection is not set, cannot use fact cache")
 


Test patch:
Repository: ansible/ansible

Issue:
SELINUX_SPECIAL_FILESYSTEMS isn't being evaluated properly
when using copy or template module to nfs,fuse, etc filesystem SELINUX_SPECIAL_FILESYSTEMS isn't being replaced via module_common. this got taken out sometime between 1.9x and 2.0. adding it back in resolved selinux issues with copy / template to an nfs mount



Discussion:

Resolving patch:
diff --git a/lib/ansible/executor/module_common.py b/lib/ansible/executor/module_common.py
--- a/lib/ansible/executor/module_common.py
+++ b/lib/ansible/executor/module_common.py
@@ -39,6 +39,7 @@
 REPLACER_WINARGS  = "<<INCLUDE_ANSIBLE_MODULE_WINDOWS_ARGS>>"
 REPLACER_JSONARGS = "<<INCLUDE_ANSIBLE_MODULE_JSON_ARGS>>"
 REPLACER_VERSION  = "\"<<ANSIBLE_VERSION>>\""
+REPLACER_SELINUX  = "<<SELINUX_SPECIAL_FILESYSTEMS>>"
 
 # We could end up writing out parameters with unicode characters so we need to
 # specify an encoding for the python source file
@@ -172,6 +173,7 @@ def modify_module(module_path, module_args, task_vars=dict(), strip_comments=Fal
     module_data = module_data.replace(REPLACER_COMPLEX, python_repred_args)
     module_data = module_data.replace(REPLACER_WINARGS, module_args_json)
     module_data = module_data.replace(REPLACER_JSONARGS, module_args_json)
+    module_data = module_data.replace(REPLACER_SELINUX, ','.join(C.DEFAULT_SELINUX_SPECIAL_FS))
 
     if module_style == 'new':
         facility = C.DEFAULT_SYSLOG_FACILITY
@@ -200,4 +202,3 @@ def modify_module(module_path, module_args, task_vars=dict(), strip_comments=Fal
     module_data = b"\n".join(lines)
 
     return (module_data, module_style, shebang)
-


Test patch: