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

Issue:
znode - 'object is not iterable'
##### Issue Type:

Bug Report
##### Ansible Version:

```
$ ansible --version
ansible 2.1.0
  config file =
  configured module search path = Default w/o overrides
```
##### Ansible Configuration:

Default
##### Environment:
- Running from OSX
- Managing Centos7
##### Summary:

Attempting to add a znode to a remote Zookeeper server results in an `object not iterable` error.
##### Steps To Reproduce:

Run this playbook against a Zookeeper server.

``` yml

---
- hosts: 127.0.0.1
  connection: local
  gather_facts: no
  tasks:
    - action: znode hosts=[ZK_SERVER_ADDR]:2181 name=/mypath value=myvalue state=present
```
##### Expected Results:

I would expect a znode to be added to the Zookeeper server if it didn't exist, update the value if the value was different, and do nothing if the znode existed and required to updating.
##### Actual Results:

```
$ ansible-playbook -vvv znode-present-test.yml
No config file found; using defaults
 [WARNING]: provided hosts list is empty, only localhost is available

1 plays in znode-present-test.yml

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

TASK [znode state=present hosts=[ZK_SERVER_ADDR]:2181 name=/mypath value=myvalue] **
task path: .../znode-present-test.yml:6
...
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "~/.ansible/tmp/ansible-tmp-1449761490.97-163319842606327/znode", line 2151, in <module>
    main()
  File "~/.ansible/tmp/ansible-tmp-1449761490.97-163319842606327/znode", line 126, in main
    result, result_dict = command_dict[command_type][method]
TypeError: 'instancemethod' object is not iterable

fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"hosts": "[ZK_SERVER_ADDR]:2181", "name": "/mypath", "state": "present", "value": "myvalue"}, "module_name": "znode"}, "parsed": false}

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



Discussion:

Resolving patch:
diff --git a/clustering/znode.py b/clustering/znode.py
--- a/clustering/znode.py
+++ b/clustering/znode.py
@@ -122,7 +122,7 @@ def main():
 
     command_type = 'op' if 'op' in module.params and module.params['op'] is not None else 'state'
     method = module.params[command_type]
-    result, result_dict = command_dict[command_type][method]
+    result, result_dict = command_dict[command_type][method]()
     zoo.shutdown()
 
     if result:
@@ -225,4 +225,3 @@ def _wait(self, path, timeout, interval=5):
 from ansible.module_utils.basic import *
 
 main()
-


Test patch:
Repository: ansible/ansible-modules-extras

Issue:
[osx_defaults] cannot specify value = false (without quotes)
##### Issue Type:

Bug report
##### Ansible Version:

2.0.0 (installed from sources)
##### Ansible Configuration:

Nothing special
##### Environment:

N/A
##### Summary:

[osx_defaults] cannot specify value = false (without quotes)
##### Steps To Reproduce:

If you have the task

``` yaml
  osx_defaults:
    domain: /Library/Preferences/com.apple.loginwindow
    key: GuestEnabled
    state: present
    value: false
    type: boolean
```

it fails because, yaml first converts 'false' to False and then osx_defaults, lowercases it. See https://github.com/ansible/ansible-modules-extras/blob/9db032aa118425cde4db904b0e8efac5ed07735b/system/osx_defaults.py#L127-130.

It is weird that it lowercases the value and then expects it to be any of [True, 1, ...].

Note that the same happens with value: no.

The workaround is to specify it with quotes: "false" or "no".
##### Expected Results:

To succsfully set the variable to false.
##### Actual Results:

Failure



Discussion:
Commit 130bd670d82cc55fa321021e819838e07ff10c08 actually broke it and fixed another... Will look into it as soon as possible.

Thx :)

@frenck  we can just use the boolean function provided by module's basic.py

I just ran into this. The issue is tagged as `needs_info`, but I'm not sure what further info you're looking for. It would appear that the line referenced in the original report just needs to not call `lower()` if the value is already a Python boolean, which the YAML parser is doing.

I can submit a pull request if you want.

@booch it won't always be a boolean, in this case it is, just need to check against `isinstance` before applying `lower()`


Resolving patch:
diff --git a/system/osx_defaults.py b/system/osx_defaults.py
--- a/system/osx_defaults.py
+++ b/system/osx_defaults.py
@@ -124,9 +124,11 @@ def _convert_type(self, type, value):
         if type == "string":
             return str(value)
         elif type in ["bool", "boolean"]:
-            if value.lower() in [True, 1, "true", "1", "yes"]:
+            if isinstance(value, basestring):
+                value = value.lower()
+            if value in [True, 1, "true", "1", "yes"]:
                 return True
-            elif value.lower() in [False, 0, "false", "0", "no"]:
+            elif value in [False, 0, "false", "0", "no"]:
                 return False
             raise OSXDefaultsException("Invalid boolean value: {0}".format(repr(value)))
         elif type == "date":


Test patch:
Repository: ansible/ansible-modules-extras

Issue:
Fix documentation os_project module.
os_project returns this fatal error:

```
fatal: [openstack-vcenter]: FAILED! => {"changed": false, "failed": true, "msg": "unsupported parameter for module: domain_id"}
```

The documentation is wrong because the correct parameter must be "domain" instead "domain_id".
See line 173



Discussion:

Resolving patch:
diff --git a/cloud/amazon/ec2_elb_facts.py b/cloud/amazon/ec2_elb_facts.py
--- a/cloud/amazon/ec2_elb_facts.py
+++ b/cloud/amazon/ec2_elb_facts.py
@@ -112,7 +112,7 @@ def get_elb_listeners(listeners):
 def get_health_check(health_check):
     protocol, port_path = health_check.target.split(':')
     try:
-        port, path = port_path.split('/')
+        port, path = port_path.split('/', 1)
         path = '/{}'.format(path)
     except ValueError:
         port = port_path


Test patch:
Repository: ansible/ansible-modules-extras

Issue:
Verbs change in Elasticsearch 2.0.0
Since Elasticsearch 2.0.0 `plugin` dropped the double-dash for verbs. So what used to be `--install` now became `install`. Hence, [this](https://github.com/ansible/ansible-modules-extras/blob/devel/packaging/elasticsearch_plugin.py#L114-L117) doesn't work with new versions.



Discussion:
Hi @omame -- Thanks for submitting this bug report.

@ThePixelDeveloper -- thanks in advance for taking a look at this bug report and for your ongoing work in maintaining this module.

[module: packaging/elasticsearch_plugin.py]

FWIW I verified that removing the double-dashes from the module works with ES 2.0

Alright, I'll take a look at it this week, thanks for bringing it to my attention.

@ThePixelDeveloper -- thanks for the update, let us know when you have something ready. :)

Sorry for the delay! Working on this now.

I'm not sure how to attack this issue, but I think I'm going to go with trying a version 2 install and falling back to a version 1 style. I don't believe adding a version argument would be good for the developer experience here, although I'm a bit unhappy with the solution I came up with still ... Suggestions appreciated, but shall have a PR ready soon.

Hello, for information, it's seem that `bin/plugin install [plugin_name]` works on ES 1.x and ES 2.x. See this [issue on ansible-elasticsearch](https://github.com/elastic/ansible-elasticsearch/issues/61).

I tested on ES 1.7.2 and it works.


Resolving patch:
diff --git a/packaging/elasticsearch_plugin.py b/packaging/elasticsearch_plugin.py
--- a/packaging/elasticsearch_plugin.py
+++ b/packaging/elasticsearch_plugin.py
@@ -33,7 +33,7 @@
 options:
     name:
         description:
-            - Name of the plugin to install
+            - Name of the plugin to install. In ES 2.x, the name can be an url or file location
         required: True
     state:
         description:
@@ -43,7 +43,7 @@
         default: present
     url:
         description:
-            - Set exact URL to download the plugin from
+            - Set exact URL to download the plugin from (Only works for ES 1.x)
         required: False
         default: None
     timeout:
@@ -112,8 +112,8 @@ def parse_error(string):
 def main():
 
     package_state_map = dict(
-        present="--install",
-        absent="--remove"
+        present="install",
+        absent="remove"
     )
 
     module = AnsibleModule(


Test patch:
Repository: ansible/ansible-modules-extras

Issue:
Elasticsearch: Add proxy support during plugins installation
We should be able to install Elasticsearch plugin though proxy.



Discussion:

Resolving patch:
diff --git a/packaging/elasticsearch_plugin.py b/packaging/elasticsearch_plugin.py
--- a/packaging/elasticsearch_plugin.py
+++ b/packaging/elasticsearch_plugin.py
@@ -61,6 +61,16 @@
             - Your configured plugin directory specified in Elasticsearch
         required: False
         default: /usr/share/elasticsearch/plugins/
+    proxy_host:
+        description:
+            - Proxy host to use during plugin installation
+        required: False
+        default: None
+    proxy_port:
+        description:
+            - Proxy port to use during plugin installation
+        required: False
+        default: None        
     version:
         description:
             - Version of the plugin to be installed.
@@ -124,16 +134,20 @@ def main():
             timeout=dict(default="1m"),
             plugin_bin=dict(default="/usr/share/elasticsearch/bin/plugin"),
             plugin_dir=dict(default="/usr/share/elasticsearch/plugins/"),
+            proxy_host=dict(default=None),
+            proxy_port=dict(default=None),
             version=dict(default=None)
         )
     )
 
-    plugin_bin = module.params["plugin_bin"]
-    plugin_dir = module.params["plugin_dir"]
     name = module.params["name"]
     state = module.params["state"]
     url = module.params["url"]
     timeout = module.params["timeout"]
+    plugin_bin = module.params["plugin_bin"]
+    plugin_dir = module.params["plugin_dir"]
+    proxy_host = module.params["proxy_host"]
+    proxy_port = module.params["proxy_port"]
     version = module.params["version"]
 
     present = is_plugin_present(parse_plugin_repo(name), plugin_dir)
@@ -147,6 +161,9 @@ def main():
 
     cmd_args = [plugin_bin, package_state_map[state], name]
 
+    if proxy_host and proxy_port:
+        cmd_args.append("-DproxyHost=%s -DproxyPort=%s" % proxy_host, proxy_port)
+
     if url:
         cmd_args.append("--url %s" % url)
 


Test patch:
Repository: ansible/ansible-modules-extras

Issue:
ec2_vpc_route_table "Multiple subnets named XXX"
Hi,
thanks for your ec2_vpc_route_table module but i noticed a bug anoying with subnet attribute.

I use the following task:

```
- name: Create routing table
  ec2_vpc_route_table:
    vpc_id: "{{ item.0.vpc_id }}"
    region: "{{ item.0.region }}"
    tags: "{{ item.1.tags }}"
    routes: "{{ item.1.routes }}"
    subnets: "{{ item.1.subnets }}"
  with_subelements:
    - amazon.routes
    - config
```

Here is the vars file:

```
amazon:
  routes:
    vpc_test:
      vpc_id: "vpc-aaaaaaaa"
      region: "eu-wtf-1"
      config:
        - tags:
            Name: "test-public"
          subnets:
            - "subnet-XXX"
            - "subnet-YYY"
            - "subnet-ZZZ"
          routes:
            - { dest: "172.16.0.0/16", gateway_id: "vgw-XXX" }
            - { dest: "192.168.1.0/24", gateway_id: "vgw-XXX" }
```

This works with the following syntax with subnet IDs but if i replace subnet-XXX by names, it doesn't work with multiple subnets.

```
failed: [127.0.0.1] => (item=({u'vpc_id': u'vpc-XXX', u'region': u'eu-central-1'}, {u'routes': [{u'dest': u'172.16.0.0/16', u'gateway_id': u'vgw-XXX'}, {u'dest': u'192.168.1.0/24', u'gateway_id': u'vgw-XXX'}], u'subnets': [u'protect-test-a', u'protect-test2-a', u'protect-test3-a'], u'tags': {u'Name': u'test-public'}})) => {"failed": true, "item": [{"region": "eu-wtf-1", "vpc_id": "vpc-XXX"}, {"routes": [{"dest": "172.20.0.0/16", "gateway_id": "vgw-XXX"}, {"dest": "192.168.1.0/24", "gateway_id": "vgw-XXX"}], "subnets": ["protect-test-a", "protect-test2-a", "protect-test3-a"], "tags": {"Name": "test-public"}}], "msg": "Multiple subnets named \"protect-test-a\""}
```

Thanks for your reading



Discussion:

Resolving patch:
diff --git a/cloud/amazon/ec2_vpc_route_table.py b/cloud/amazon/ec2_vpc_route_table.py
--- a/cloud/amazon/ec2_vpc_route_table.py
+++ b/cloud/amazon/ec2_vpc_route_table.py
@@ -183,11 +183,11 @@ def find_subnets(vpc_conn, vpc_id, identified_subnets):
             filters={'vpc_id': vpc_id, 'tag:Name': subnet_names})
 
         for name in subnet_names:
-            matching = [s.tags.get('Name') == name for s in subnets_by_name]
-            if len(matching) == 0:
+            matching_count = len([1 for s in subnets_by_name if s.tags.get('Name') == name])
+            if matching_count == 0:
                 raise AnsibleSubnetSearchException(
                     'Subnet named "{0}" does not exist'.format(name))
-            elif len(matching) > 1:
+            elif matching_count > 1:
                 raise AnsibleSubnetSearchException(
                     'Multiple subnets named "{0}"'.format(name))
 


Test patch:
Repository: ansible/ansible-modules-extras

Issue:
pacman module always reports meta package installation as 'changed'
Issue Type: Bug Report

Ansible Version: 1.9.1

Ansible Configuration: default from FreeBSD port

Environment: Controller FreeBSD 9x. Target Arch x64

Summary: pacman module tasks that install either the 'base-devel' or 'gnome' meta packages always report the status as "changed" and "installed 1 package(s)". This occurs even though the meta package is already installed.

Steps To Reproduce: create and run playbook with a pacman module task that installs an Arch 'meta' package, such as 'base-devel' or 'gnome'

Expected Results: Status message for already installed meta packages will show "changed": false ... "msg": "package(s) already installed"}

Actual Results: status message is "changed" and "installed 1 package(s)".

```
TASK: [workstations | install Arch software pkgs] ************************* 
ok: [host.name] => (item=kexec-tools) => {"changed": false, "item": "kexec-tools", "msg": "package(s) already installed"}
ok: [host.name] => (item=nfs-utils) => {"changed": false, "item": "nfs-utils", "msg": "package(s) already installed"}
changed: [host.name] => (item=base-devel) => {"changed": true, "item": "base-devel", "msg": "installed 1 package(s)"}
TASK: [workstations | install Gnome Desktop environment ] ********* 
changed: [host.name] => {"changed": true, "msg": "installed 1 package(s)"}
```



Discussion:

Resolving patch:
diff --git a/packaging/os/pacman.py b/packaging/os/pacman.py
--- a/packaging/os/pacman.py
+++ b/packaging/os/pacman.py
@@ -267,6 +267,25 @@ def check_packages(module, pacman_path, packages, state):
         module.exit_json(changed=False, msg="package(s) already %s" % state)
 
 
+def expand_package_groups(module, pacman_path, pkgs):
+    expanded = []
+
+    for pkg in pkgs:
+        cmd = "%s -Sgq %s" % (pacman_path, pkg)
+        rc, stdout, stderr = module.run_command(cmd, check_rc=False)
+
+        if rc == 0:
+            # A group was found matching the name, so expand it
+            for name in stdout.split('\n'):
+                name = name.strip()
+                if name:
+                    expanded.append(name)
+        else:
+            expanded.append(pkg)
+
+    return expanded
+
+
 def main():
     module = AnsibleModule(
         argument_spec    = dict(
@@ -305,7 +324,7 @@ def main():
         upgrade(module, pacman_path)
 
     if p['name']:
-        pkgs = p['name']
+        pkgs = expand_package_groups(module, pacman_path, p['name'])
 
         pkg_files = []
         for i, pkg in enumerate(pkgs):


Test patch:
Repository: ansible/ansible-modules-extras

Issue:
datacenter/dc parameter is not available on modules consul_session, consul_kv respectively
##### Issue Type:
- Bug Report
  ##### Plugin Name:
  consul_kv
  consul_session
  ##### Ansible Version:
  2.0.0

```
ansible 2.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```
##### Ansible Configuration:

Please mention any settings you've changed/added/removed in ansible.cfg
(or using the ANSIBLE_\* environment variables).
##### Environment:

Ubuntu Trusty Tahr: 14.04 (up to date)
##### Summary:

Unable to use the "**datacenter**" for consul_session/ consul_kv
- name: register basic session with consul
  consul_session:
    host: "{{consul_server_name}}"
    name: "trialsession"
    datacenter: "{{consul_datacenter}}"

Output: 
fatal: [ip]: FAILED! => {"changed": false, "failed": true, "msg": "unsupported parameter for module: datacenter"}



Discussion:

Resolving patch:
diff --git a/clustering/consul_session.py b/clustering/consul_session.py
--- a/clustering/consul_session.py
+++ b/clustering/consul_session.py
@@ -248,7 +248,8 @@ def main():
         name=dict(required=False),
         node=dict(required=False),
         state=dict(default='present',
-                   choices=['present', 'absent', 'info', 'node', 'list'])
+                   choices=['present', 'absent', 'info', 'node', 'list']),
+        datacenter=dict(required=False)
     )
 
     module = AnsibleModule(argument_spec, supports_check_mode=False)


Test patch:
Repository: ansible/ansible-modules-extras

Issue:
lvg: undocumented support of physical volume creation
##### Issue Type:

Documentation Report
##### Plugin Name:

lvg
##### Ansible Version:

```
# ansible --version
ansible 1.9.4
  configured module search path = None
```
##### Summary:

lvg module seems to take care of physical volume creation, on top of volume group creation. However, it doesn't appear to be documented.

I noticed I could just use

```
- name: Create LVM volume group
  lvg:
    pvs: /dev/vdc
    state: present
    vg: direct-lvm
```

instead of:

```
- name: Create LVM physical volume
  command: pvcreate -y /dev/vdc

- name: Create LVM volume group
  lvg:
    pvs: /dev/vdc
    state: present
    vg: direct-lvm
```

which isn't idempotent since executing pvcreate a second time will fail.



Discussion:

Resolving patch:
diff --git a/system/lvg.py b/system/lvg.py
--- a/system/lvg.py
+++ b/system/lvg.py
@@ -35,6 +35,7 @@
   pvs:
     description:
     - List of comma-separated devices to use as physical devices in this volume group. Required when creating or resizing volume group.
+    - The module will take care of running pvcreate if needed. 
     required: false
   pesize:
     description:


Test patch:
Repository: ansible/ansible-modules-extras

Issue:
mongodb_user support check mode
##### Issue Type:
- Feature Idea
  ##### Plugin Name:
- database/misc/mongodb_user
##### Ansible Version:

```
Ansible Version: 2.0.0.2
Plugin Version: 8d86666 on 1 Dec 2015
```
##### Ansible Configuration:

“N/A”
##### Environment:

“N/A”
##### Summary:

Support check mode
##### Steps To Reproduce:

Execute this task on an empty database with check mode

```
- mongodb_user: login_user={{ mongodb3_admin_user }} login_password={{ mongodb3_admin_password }} login_port={{ mongodb3_mongos_port }} login_database=admin database={{ item.db }} name={{ item.name }} password={{ item.passwd }} roles={{ item.roles | join(",") }} state=present update_password=on_create
  with_items: mongodb3_users
  run_once: true
```
##### Expected Results:

Says "changed" but no user inserted
##### Actual Results:

skip task



Discussion:

Resolving patch:
diff --git a/database/misc/mongodb_user.py b/database/misc/mongodb_user.py
--- a/database/misc/mongodb_user.py
+++ b/database/misc/mongodb_user.py
@@ -172,6 +172,8 @@ def user_add(module, client, db_name, user, password, roles):
 def user_remove(module, client, db_name, user):
     exists = user_find(client, user)
     if exists:
+        if module.check_mode:
+            module.exit_json(changed=True, user=user)
         db = client[db_name]
         db.remove_user(user)
     else:
@@ -212,7 +214,8 @@ def main():
             roles=dict(default=None, type='list'),
             state=dict(default='present', choices=['absent', 'present']),
             update_password=dict(default="always", choices=["always", "on_create"]),
-        )
+        ),
+        supports_check_mode=True
     )
 
     if not pymongo_found:
@@ -264,6 +267,9 @@ def main():
         if update_password != 'always' and user_find(client, user):
             password = None
 
+        if module.check_mode:
+            module.exit_json(changed=True, user=user)
+
         try:
             user_add(module, client, db_name, user, password, roles)
         except OperationFailure, e:


Test patch:
Repository: ansible/ansible-modules-extras

Issue:
Feature Idea: ec2_elb_facts should return hosted_zone_id
I want to create a route53 record with "route53" module with alias=True after fetching information with ec2_elb_facts module. But I can't do it since Route53 requires hosted_zone_id to create an alias record and this module doesn't return it.

ec2_elb_facts module should return hosted_zone_id like the ec2_elb_lb module.



Discussion:
+1
I have the same problem


Resolving patch:
diff --git a/cloud/amazon/ec2_elb_facts.py b/cloud/amazon/ec2_elb_facts.py
--- a/cloud/amazon/ec2_elb_facts.py
+++ b/cloud/amazon/ec2_elb_facts.py
@@ -136,6 +136,8 @@ def get_elb_info(connection,elb):
         'name': elb.name,
         'zones': elb.availability_zones,
         'dns_name': elb.dns_name,
+        'canonical_hosted_zone_name': elb.canonical_hosted_zone_name,
+        'canonical_hosted_zone_name_id': elb.canonical_hosted_zone_name_id,
         'instances': [instance.id for instance in elb.instances],
         'listeners': get_elb_listeners(elb.listeners),
         'scheme': elb.scheme,


Test patch: