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

Issue:
gluster_volume module should parse "other names" of 'gluster peer status' command
Hi.

I have the following `gluster peer status` output:

```
Number of Peers: 2

Hostname: emma.int.prhv.afunix.org
Uuid: c536dce8-dda8-4a66-a840-2eea709572da
State: Peer in Cluster (Connected)
Other names:
emma

Hostname: amanda.int.prhv.afunix.org
Uuid: c6654b8f-3ca8-424f-8d0f-7c0b7d8108cc
State: Peer in Cluster (Connected)
Other names:
amanda
```

My inventory has short names configured (emma, amanda, ...).
When I try to configure a volume with gluster_volume module it fails.
Module cannot identify that `gluster peer probe` completed successfully, because it cannot match FQDN with short hostnames.
Gluster itself knows that peers have the specific short names, so should be able to the gluster_volume module.



Discussion:
[module: system/gluster_volume.py]

@rosmo, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->


Resolving patch:
diff --git a/system/gluster_volume.py b/system/gluster_volume.py
--- a/system/gluster_volume.py
+++ b/system/gluster_volume.py
@@ -181,16 +181,24 @@ def get_peers():
     hostname = None
     uuid = None
     state = None
+    shortNames = False
     for row in out.split('\n'):
         if ': ' in row:
             key, value = row.split(': ')
             if key.lower() == 'hostname':
                 hostname = value
+                shortNames = False
             if key.lower() == 'uuid':
                 uuid = value
             if key.lower() == 'state':
                 state = value
                 peers[hostname] = [ uuid, state ]
+        elif row.lower() == 'other names:':
+            shortNames = True
+        elif row != '' and shortNames == True:
+            peers[row] = [ uuid, state ]
+        elif row == '':
+            shortNames = False
     return peers
 
 def get_volumes():


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

Issue:
vmware_guest module doesn't change VM memory during clone
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME

vmware_guest
##### ANSIBLE VERSION

```
ansible 2.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```
##### CONFIGURATION
##### OS / ENVIRONMENT

```
$ cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 
```
##### SUMMARY

Setting memory size during a clone operation fails. See example playbook linked in next section.
##### STEPS TO REPRODUCE

https://github.com/phips/ansible-demos/blob/master/plays/vm_clone-new.yml#L46
##### EXPECTED RESULTS

Memory to be different to the cloned template size.
##### ACTUAL RESULTS

Any hardware/memory setting is ignored and the cloned VM gets the same size memory as the underlying template.



Discussion:
<!-- @phips: Thanks for filing this bug report! -->

@chrrrles ping, this issue is waiting for your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_bug_new --->


Resolving patch:
diff --git a/cloud/vmware/vmware_guest.py b/cloud/vmware/vmware_guest.py
--- a/cloud/vmware/vmware_guest.py
+++ b/cloud/vmware/vmware_guest.py
@@ -617,6 +617,17 @@ def deploy_template(self, poweron=False, wait_for_ip=False):
             configspec = vim.vm.ConfigSpec(deviceChange=[diskspec])
             clonespec_kwargs['config'] = configspec
 
+        # set cpu/memory/etc
+        if 'hardware' in self.params:
+            if not 'config' in clonespec_kwargs:
+                clonespec_kwargs['config'] = vim.vm.ConfigSpec()
+            if 'num_cpus' in self.params['hardware']:
+                clonespec_kwargs['config'].numCPUs = \
+                    int(self.params['hardware']['num_cpus'])
+            if 'memory_mb' in self.params['hardware']:
+                clonespec_kwargs['config'].memoryMB = \
+                    int(self.params['hardware']['memory_mb'])
+
         clonespec = vim.vm.CloneSpec(**clonespec_kwargs)
         task = template.Clone(folder=destfolder, name=self.params['name'], spec=clonespec)
         self.wait_for_task(task)


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

Issue:
lvg fails if pvs option omitted when state=absent
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME

`lvg` module
##### ANSIBLE VERSION

```
ansible 2.1.2.0
  config file = /Users/jsok/workspace/ansible.cfg
  configured module search path = Default w/o overrides
```
##### CONFIGURATION

N/A
##### OS / ENVIRONMENT

CentOS 6.7
##### SUMMARY

The `pvs` option is not necessary when `state=absent`, however failing to supply an empty string will cause the module to fail.
##### STEPS TO REPRODUCE

```

---
- name: Remove a volume group
  hosts: localhost
  tasks:
    - name: Remove vg01
      lvg:
        vg: vg01
        state: absent
```
##### EXPECTED RESULTS

The volume group is removed successfully.
##### ACTUAL RESULTS

```
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "", "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_tj_9JM/ansible_module_lvg.py\", line 255, in <module>\r\n    main()\r\n  File \"/tmp/ansible_tj_9JM/ansible_module_lvg.py\", line 140, in main\r\n    for idx, dev in enumerate(dev_list):\r\nUnboundLocalError: local variable 'dev_list' referenced before assignment\r\n", "msg": "MODULE FAILURE"}
```



Discussion:
To make the task succeed, it is necessary to include `pvs` like:

```
---

- name: Remove a volume group
  hosts: localhost
  tasks:
    - name: Remove vg01
      lvg:
        vg: vg01
        state: absent
        pvs: ''
```


Resolving patch:
diff --git a/system/lvg.py b/system/lvg.py
--- a/system/lvg.py
+++ b/system/lvg.py
@@ -131,6 +131,7 @@ def main():
     pesize = module.params['pesize']
     vgoptions = module.params['vg_options'].split()
 
+    dev_list = []
     if module.params['pvs']:
         dev_list = module.params['pvs']
     elif state == 'present':


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

Issue:
Timezone: global name 'tzfile' is not defined
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
timezone

##### ANSIBLE VERSION
```
ansible 2.2.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```

##### CONFIGURATION
No changes.

##### OS / ENVIRONMENT
Host: Arch
Client: CentOS 6.8

##### SUMMARY
As of https://github.com/ansible/ansible-modules-extras/commit/e29584ad70d2f4e0a8ef02781d7bc7e977ff0e69 timezone is broken again. If I go back to https://github.com/ansible/ansible-modules-extras/commit/df35d324d62e6034ab86db0fb4a56d3ca122d4b2 it works fine again.

##### STEPS TO REPRODUCE
Run playbook with a timezone defined.

##### EXPECTED RESULTS
Timezone set properly, no errors.

##### ACTUAL RESULTS
Receive the fatal error below.

```
fatal: [vagrant-noc-server]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to 192.168.50.3 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible__7aiLU/ansible_module_timezone.py\", line 462, in <module>\r\n    main()\r\n  File \"/tmp/ansible__7aiLU/ansible_module_timezone.py\", line 435, in main\r\n    tz = Timezone(module)\r\n  File \"/tmp/ansible__7aiLU/ansible_module_timezone.py\", line 306, in __init__\r\n    self.update_timezone += ' %s /etc/localtime' % tzfile\r\nNameError: global name 'tzfile' is not defined\r\n", "msg": "MODULE FAILURE"}
```


Discussion:
<!-- @austinbutler: Thanks for filing this bug report! -->

@tmshn ping, this issue is waiting for your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_bug_new --->


Resolving patch:
diff --git a/system/timezone.py b/system/timezone.py
--- a/system/timezone.py
+++ b/system/timezone.py
@@ -223,6 +223,7 @@ def _verify_timezone(self):
         tzfile = '/usr/share/zoneinfo/%s' % tz
         if not os.path.isfile(tzfile):
             self.abort('given timezone "%s" is not available' % tz)
+        return tzfile
 
 
 class SystemdTimezone(Timezone):
@@ -301,7 +302,7 @@ def __init__(self, module):
         super(NosystemdTimezone, self).__init__(module)
         # Validate given timezone
         if 'name' in self.value:
-            self._verify_timezone()
+            tzfile = self._verify_timezone()
             self.update_timezone  = self.module.get_bin_path('cp', required=True)
             self.update_timezone += ' %s /etc/localtime' % tzfile
         self.update_hwclock = self.module.get_bin_path('hwclock', required=True)


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

Issue:
Bad consul_kv token default
Currently the documentation says the token defaults to `None` but the code does not:
https://github.com/ansible/ansible-modules-extras/blob/devel/clustering/consul_kv.py#L244

Note: The current default breaks bootstrapped agent acls.

I can try and send a PR shortly to fix this unless someone else beats me to it!



Discussion:
So, shouldn't we change the default rather than the doc ?

@sgargan, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->

@sgargan, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->

@sgargan, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->

@sgargan, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->

@sgargan, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->


Resolving patch:
diff --git a/clustering/consul_kv.py b/clustering/consul_kv.py
--- a/clustering/consul_kv.py
+++ b/clustering/consul_kv.py
@@ -251,7 +251,7 @@ def test_dependencies(module):
     if not python_consul_installed:
         module.fail_json(msg="python-consul required for this module. "\
               "see http://python-consul.readthedocs.org/en/latest/#installation")
-    
+
 def main():
 
     argument_spec = dict(
@@ -265,7 +265,7 @@ def main():
         recurse=dict(required=False, type='bool'),
         retrieve=dict(required=False, default=True),
         state=dict(default='present', choices=['present', 'absent', 'acquire', 'release']),
-        token=dict(required=False, default='anonymous', no_log=True),
+        token=dict(required=False, no_log=True),
         value=dict(required=False),
         session=dict(required=False)
     )
@@ -273,7 +273,7 @@ def main():
     module = AnsibleModule(argument_spec, supports_check_mode=False)
 
     test_dependencies(module)
-        
+
     try:
         execute(module)
     except ConnectionError as e:


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

Issue:
Amazon ec2_elb_facts module fails when no names passed in
##### ISSUE TYPE
 - Bug Report
 
##### COMPONENT NAME
- ec2_elb_facts

##### ANSIBLE VERSION

```
ansible --version
ansible 2.2.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```

##### CONFIGURATION
None

##### OS / ENVIRONMENT
- Amazon Linux, stock install

##### SUMMARY
With the release of this module for Ansible 2.2, I am no longer able to get all load balancer information. The module throws a TypeError

##### STEPS TO REPRODUCE
<!--- Paste example playbooks or commands between quotes below -->
```
# Example playbook
- name: Gather elb facts
  action: 
    module: ec2_elb_facts
    region: "{{ ec2_region }}"
    aws_access_key: "{{ aws_access_key }}"
    aws_secret_key: "{{ aws_secret_key }}"
  register: elb_facts
  tags:
   - deploy
```

##### EXPECTED RESULTS
- Not a failure

##### ACTUAL RESULTS
```
# Job output
TASK [deploy_elb_deregister : Gather elb facts] ********************************
fatal: [10.90.30.119]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to 10.90.30.119 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_49PnSI/ansible_module_ec2_elb_facts.py\", line 245, in <module>\r\n    main()\r\n  File \"/tmp/ansible_49PnSI/ansible_module_ec2_elb_facts.py\", line 237, in main\r\n    elbs=elb_information.list_elbs())\r\n  File \"/tmp/ansible_49PnSI/ansible_module_ec2_elb_facts.py\", line 209, in list_elbs\r\n    if existing_lb.name in self.names:\r\nTypeError: argument of type 'NoneType' is not iterable\r\n", "msg": "MODULE FAILURE"}
```

I will have a pull request today.


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
@@ -205,16 +205,19 @@ def list_elbs(self):
             self.module.fail_json(msg = "%s: %s" % (err.error_code, err.error_message))
 
         if all_elbs:
-            for existing_lb in all_elbs:
-                if existing_lb.name in self.names:
-                    elb_array.append(self._get_elb_info(existing_lb))
-
-        return elb_array
+            if self.names:
+                for existing_lb in all_elbs:
+                    if existing_lb.name in self.names:
+                        elb_array.append(existing_lb)
+            else:
+                elb_array = all_elbs
+                    
+        return list(map(self._get_elb_info, elb_array))
 
 def main():
     argument_spec = ec2_argument_spec()
     argument_spec.update(dict(
-            names={'default': None, 'type': 'list'}
+            names={'default': [], 'type': 'list'}
         )
     )
     module = AnsibleModule(argument_spec=argument_spec)


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

Issue:
ec2_lc_find not returning AssociatePublicIpAddress
##### ISSUE TYPE
Bug Report

##### COMPONENT NAME
ec2_lc_find

##### ANSIBLE VERSION
```
ansible 2.2.0.0
  config file = /home/centos/ansiblebase/ansible.cfg
  configured module search path = Default w/o overrides
```

##### CONFIGURATION
No significant changes

##### OS / ENVIRONMENT
Started with Ansible Tower 3.0.3 on CentOS 7 x86_64
Did a yum update on ansible to 2.2.
Did pip install boto3.

##### SUMMARY
Running ec2_lc_find fails with a missing key for AssociatePublicIpAddress

##### STEPS TO REPRODUCE
```
- ec2_lc_find:
    region: "{{ region }}"
    name_regex: lc_name-*"
    sort_order: ascending
    limit: 3
  register: old_lc_result
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
Correctly returns load configurations matching regex.

##### ACTUAL RESULTS
```
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: 'AssociatePublicIpAddress'
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_dJ3ho0/ansible_module_ec2_lc_find.py\", line 225, in <module>\n    main()\n  File \"/tmp/ansible_dJ3ho0/ansible_module_ec2_lc_find.py\", line 217, in main\n    find_launch_configs(client, module)\n  File \"/tmp/ansible_dJ3ho0/ansible_module_ec2_lc_find.py\", line 187, in find_launch_configs\n    'associate_public_address': lc['AssociatePublicIpAddress'],\nKeyError: 'AssociatePublicIpAddress'\n", "module_stdout": "", "msg": "MODULE FAILURE"}
```



Discussion:
<!-- @jsteinich: Thanks for filing this bug report! -->

@fiunchinho ping, this issue is waiting for your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_bug_new --->


Resolving patch:
diff --git a/cloud/amazon/ec2_lc_find.py b/cloud/amazon/ec2_lc_find.py
--- a/cloud/amazon/ec2_lc_find.py
+++ b/cloud/amazon/ec2_lc_find.py
@@ -184,7 +184,7 @@ def find_launch_configs(client, module):
                 'security_groups': lc['SecurityGroups'],
                 'kernel_id': lc['KernelId'],
                 'ram_disk_id': lc['RamdiskId'],
-                'associate_public_address': lc['AssociatePublicIpAddress'],
+                'associate_public_address': lc.get('AssociatePublicIpAddress', False),
             }
 
             results.append(data)


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

Issue:
locale_gen fails when using Python 3
##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report

##### COMPONENT NAME
`locale_gen`

##### ANSIBLE VERSION
```
ansible 2.2.0.0
```

##### CONFIGURATION
```ansible_python_interpreter: "python3"```

##### OS / ENVIRONMENT
Ubuntu Xenial 16.04

##### SUMMARY
When using Python 3, running a task with `locale_gen` fails.

##### STEPS TO REPRODUCE
1. Set a task using `locale_gen`; in my case it was:
    ```
    - name: ensure the required locale exists
      locale_gen:
        name: "{{ db_locale }}"
        state: present
    ```
2. Set `--ansible_python_interpreter=python3` when running the task. (Or `/usr/bin/python3` or whatever works on your system.)

##### EXPECTED RESULTS
```
TASK [postgresql : ensure the required locale exists] **************************
changed: [default] => {"changed": true, "msg": "OK", "name": "en_GB.UTF-8"}
```

##### ACTUAL RESULTS
```
TASK [postgresql : ensure the required locale exists] **************************
fatal: [default]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to 127.0.0.1 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_23qigrzr/ansible_module_locale_gen.py\", line 239, in <module>\r\n    main()\r\n  File \"/tmp/ansible_23qigrzr/ansible_module_locale_gen.py\", line 217, in main\r\n    if is_present(name):\r\n  File \"/tmp/ansible_23qigrzr/ansible_module_locale_gen.py\", line 96, in is_present\r\n    return any(fix_case(name) == fix_case(line) for line in output.splitlines())\r\n  File \"/tmp/ansible_23qigrzr/ansible_module_locale_gen.py\", line 96, in <genexpr>\r\n    return any(fix_case(name) == fix_case(line) for line in output.splitlines())\r\n  File \"/tmp/ansible_23qigrzr/ansible_module_locale_gen.py\", line 101, in fix_case\r\n    for s, r in LOCALE_NORMALIZATION.iteritems():\r\nAttributeError: 'dict' object has no attribute 'iteritems'\r\n", "msg": "MODULE FAILURE"}```




Discussion:
<!-- @berislavlopac: Thanks for filing this bug report! -->

@AugustusKling ping, this issue is waiting for your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_bug_new --->

The culprit is the use of `LOCALE_NORMALIZATION.iteritems()` instead of `LOCALE_NORMALIZATION.items()`, which should not be a problem even in Python 2 since `LOCALE_NORMALIZATION` is quite small. I'm already working on the pull request.


Resolving patch:
diff --git a/system/locale_gen.py b/system/locale_gen.py
--- a/system/locale_gen.py
+++ b/system/locale_gen.py
@@ -98,7 +98,7 @@ def is_present(name):
 def fix_case(name):
     """locale -a might return the encoding in either lower or upper case.
     Passing through this function makes them uniform for comparisons."""
-    for s, r in LOCALE_NORMALIZATION.iteritems():
+    for s, r in LOCALE_NORMALIZATION.items():
         name = name.replace(s, r)
     return name
 


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

Issue:
Remove ESXi hostname requirement from vmware_guest module
##### ISSUE TYPE
 - Feature Idea

##### COMPONENT NAME
vmware_guest

##### ANSIBLE VERSION
```
ansible 2.3.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides

```

##### CONFIGURATION
<!---
Vanilla
-->

##### OS / ENVIRONMENT
<!---
N/A (Ubuntu Yakkety)
-->

##### SUMMARY
When using VMWare vCenter either via the GUI or powershell, vCenter itself is the mechanism by which your destination ESXi host is chosen yet this vmware_guest ansible module is requiring you to manually specify the destination ESXi host which completely defeats the purpose of vCenter and DRS balancing and forces you to do some nasty hacks to work around it.

##### STEPS TO REPRODUCE
<!---
The new feature should be able to offload the decision of what ESXi host your new virtual machine ends up on based on parameters passed to vCenter such as vCenter server name, cluster, destination folder etc similarly to how it works in PowerCLI/Powershell currently.  We should be specifying the chosen data store, VLAN etc in the playbook, however the destination ESXi host in a vCenter environment should be 100% vCenter's decision and not having to be specified manually.
-->




Discussion:
<!-- @stomplee: Thanks for filing this feature idea! -->

@jctanner ping, this issue is waiting for your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_bug_new --->

DRS, HA and cluster technologies are defined at the cluster level. @jctanner added cluster support in a previous PR. This should close this issue. I believe he is updating the docs to reflect that. 

@stomplee let me know if I can help further


Resolving patch:
diff --git a/cloud/vmware/vmware_guest.py b/cloud/vmware/vmware_guest.py
--- a/cloud/vmware/vmware_guest.py
+++ b/cloud/vmware/vmware_guest.py
@@ -88,7 +88,7 @@
    esxi_hostname:
         description:
             - The esxi hostname where the VM will run.
-        required: True
+        required: False
    annotation:
         description:
             - A note or annotation to include in the VM


Test patch: