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

Issue:
Docker, pulling image before attempting to create
Added option "pull_latest" that pulls docker image from registry before attempting to create container. Usable when creating containers from images that has been pushed to registry under same tag as earlier (already pulled) builds of image (eg. for tags latest, staging, production).



Discussion:
would this not make more sense in the docker_image module?

I believe `docker_image` is deprecated now.

+1 for this, to me it's not clear that when you use the docker module with state=running or present the new image is not pulled automatically. I was assuming that it was pulling the :latest implicit version (as Docker does)

Does the pull=always parameter of this pull request satisfy your needs? https://github.com/ansible/ansible-modules-core/pull/502

It's now merged into devel and the stable-1.9 branch

Yes, pull always is what i needed. Thanks.


Resolving patch:
diff --git a/cloud/docker/docker.py b/cloud/docker/docker.py
--- a/cloud/docker/docker.py
+++ b/cloud/docker/docker.py
@@ -1460,10 +1460,14 @@ def main():
         if count > 1 and name:
             module.fail_json(msg="Count and name must not be used together")
 
-        # Explicitly pull new container images, if requested.
-        # Do this before noticing running and deployed containers so that the image names will differ
-        # if a newer image has been pulled.
-        if pull == "always":
+        # Explicitly pull new container images, if requested. Do this before
+        # noticing running and deployed containers so that the image names
+        # will differ if a newer image has been pulled.
+        # Missing images should be pulled first to avoid downtime when old
+        # container is stopped, but image for new one is now downloaded yet.
+        # It also prevents removal of running container before realizing
+        # that requested image cannot be retrieved.
+        if pull == "always" or (state == 'reloaded' and manager.get_inspect_image() is None):
             manager.pull_image()
 
         containers = ContainerSet(manager)


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

Issue:
NameError: global name 'aws_connection_kwargs' is not defined
Issue Type: Bug report

Ansible Version:

```
ansible 1.9 (devel e82ba723e2) last updated 2015/04/06 09:16:30 (GMT -400)
  lib/ansible/modules/core: (devel 7e1d63136f) last updated 2015/04/06 09:16:31 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD 21fce8ac73) last updated 2015/04/06 09:16:33 (GMT -400)
  v2/ansible/modules/core: (detached HEAD 34784b7a61) last updated 2015/04/06 09:16:34 (GMT -400)
  v2/ansible/modules/extras: (detached HEAD 21fce8ac73) last updated 2015/04/06 09:16:35 (GMT -400)
  configured module search path = None
```

Environment: Arch linux

Summary:

After updating Ansible due to running into the bug in #1032, I now get this error when using the `rds_subnet_group` module:

```
TASK: [Create Staging PgSQL (RDS) Subnet Group] ******************************* 
failed: [localhost] => {"failed": true, "parsed": false}
Traceback (most recent call last):
  File "/home/kjohnson/.ansible/tmp/ansible-tmp-1428328139.83-220763953997415/rds_subnet_group", line 1954, in <module>
    main()
  File "/home/kjohnson/.ansible/tmp/ansible-tmp-1428328139.83-220763953997415/rds_subnet_group", line 119, in main
    conn = boto.rds.connect_to_region(region, **aws_connection_kwargs)
NameError: global name 'aws_connection_kwargs' is not defined
```



Discussion:

Resolving patch:
diff --git a/cloud/amazon/rds_subnet_group.py b/cloud/amazon/rds_subnet_group.py
--- a/cloud/amazon/rds_subnet_group.py
+++ b/cloud/amazon/rds_subnet_group.py
@@ -116,7 +116,7 @@ def main():
         module.fail_json(msg = str("Either region or AWS_REGION or EC2_REGION environment variable or boto config aws_region or ec2_region must be set."))
 
     try:
-        conn = boto.rds.connect_to_region(region, **aws_connection_kwargs)
+        conn = boto.rds.connect_to_region(region, **aws_connect_kwargs)
     except boto.exception.BotoServerError, e:
         module.fail_json(msg = e.error_message)
 


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

Issue:
wait_for: path or port not mandatory / hint acting like pause
##### Issue Type:

Bug Report
##### Environment:

N/A
##### Summary:

I used the module wait_for how explained here:
https://support.ansible.com/hc/en-us/articles/201958037-Reboot-a-server-and-wait-for-it-to-come-back

```
- name: waiting for server to come back
  local_action: wait_for host={{ inventory_hostname }}
                state=started
  sudo: false
```

It is no port or path given. So the module just wait 300s (default timeout) and finish with "ok" - waiting for server to come back, which was not true in my case.
##### Steps To Reproduce:

```
- name: shutdown the machine
  command: shutdown -h now "Ansible updates triggered"
  async: 0
  poll: 0
  ignore_errors: true

- name: waiting for server to come back
  local_action: wait_for host={{ inventory_hostname }}
                state=started
  sudo: false
```
##### Expected Results:

Some hints that the module is just acting like "pause" without a port/path or make one of them madatory, so that the task would fail after 300s.

Onliner example for the "busy-waiting" http://pastebin.com/MKnvHzkx



Discussion:
Any update on this bug report? 
One of these options ( path, port ) should be set or a hint in the doc is needed, that the module just waits (default 300s)


Resolving patch:
diff --git a/utilities/logic/wait_for.py b/utilities/logic/wait_for.py
--- a/utilities/logic/wait_for.py
+++ b/utilities/logic/wait_for.py
@@ -38,15 +38,15 @@
 module: wait_for
 short_description: Waits for a condition before continuing.
 description:
-     - Waiting for a port to become available is useful for when services 
-       are not immediately available after their init scripts return - 
-       which is true of certain Java application servers. It is also 
+     - You can wait for a set amount of time C(timeout), this is the default if nothing is specified.
+     - Waiting for a port to become available is useful for when services
+       are not immediately available after their init scripts return
+       which is true of certain Java application servers. It is also
        useful when starting guests with the M(virt) module and
-       needing to pause until they are ready. 
+       needing to pause until they are ready.
      - This module can also be used to wait for a regex match a string to be present in a file.
-     - In 1.6 and later, this module can 
-       also be used to wait for a file to be available or absent on the 
-       filesystem.
+     - In 1.6 and later, this module can also be used to wait for a file to be available or
+       absent on the filesystem.
      - In 1.8 and later, this module can also be used to wait for active
        connections to be closed before continuing, useful if a node
        is being rotated out of a load balancer pool.
@@ -57,7 +57,6 @@
       - A resolvable hostname or IP address to wait for
     required: false
     default: "127.0.0.1"
-    aliases: []
   timeout:
     description:
       - maximum number of seconds to wait for


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

Issue:
get_url documentation is confusing
Hello, currently the documentation of get_url is somewhat confusing:

> http://docs.ansible.com/get_url_module.html

At the end there is a note:

```
Note
This module doesn’t yet support configuration for proxies.
```

But at the beginnen there is the following text:

```
By default, if an environment variable <protocol>_proxy is set on the target host, 
requests will be sent  through that proxy. This behaviour can be overridden by setting a variable 
for this task (see setting the environment), or by using the use_proxy option.
```

Currently the note box is just wrong since setting a proxy environement variable works perfectly.



Discussion:

Resolving patch:
diff --git a/network/basics/get_url.py b/network/basics/get_url.py
--- a/network/basics/get_url.py
+++ b/network/basics/get_url.py
@@ -112,8 +112,6 @@
     description:
       - all arguments accepted by the M(file) module also work here
     required: false
-notes:
-    - This module doesn't yet support configuration for proxies.
 # informational: requirements for nodes
 requirements: [ urllib2, urlparse ]
 author: Jan-Piet Mens


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

Issue:
service module is RHLE7 is not disabling service
While this was working in ansible version 1.8 it is not working since  1.9.

For example following code will not disable the services which are enabled and for every item it is finished like OK (like it is in desired state already):

```
- name: DISABLE CLOUD-INIT SERVICES WE DON'T NEED.
  service: name={{ item }}
               enabled=no
  with_items: ["cloud-init-local","cloud-init","cloud-config","cloud-final"]
  when: action == "off"
  sudo: yes
```

---

From module source service.py...

```
        #
        # Systemd's systemctl
        #
        if self.enable_cmd.endswith("systemctl"):
            if self.enable:
                action = 'enable'
            else:
                action = 'disable'

            # Check if we're already in the correct state
            service_enabled = self.get_systemd_service_enabled()
            if self.enable and service_enabled:
                self.changed = False
            elif not self.enable and not service_enabled:
                self.changed = False
            elif not self.enable:
                self.changed = False

            if not self.changed:
                return
```

---

when I commented out the lines

```
           # elif not self.enable:
           #     self.changed = False
```

it is working as needed, but I'm not sure if it will not break something other. But on the other hand, changed = False should be just in case actual and desired are the same, otherwise the status should be changed so the commented lines should not be there, correct me if I'm wrong.

Anyway, thanks for any quick fix.



Discussion:
that whole if is ... ifffy


Resolving patch:
diff --git a/system/service.py b/system/service.py
--- a/system/service.py
+++ b/system/service.py
@@ -703,14 +703,10 @@ def write_to_override_file(file_name, file_contents, ):
 
             # Check if we're already in the correct state
             service_enabled = self.get_systemd_service_enabled()
-            if self.enable and service_enabled:
-                self.changed = False
-            elif not self.enable and not service_enabled:
-                self.changed = False
-            elif not self.enable:
-                self.changed = False
 
-            if not self.changed:
+            # self.changed should already be true
+            if self.enable == service_enabled:
+                self.changed = False
                 return
 
         #


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

Issue:
Invalid public ip address from nova_compute.
_openstack_find_nova_addresses_ in nova_compute munges ip addresses together if an instance has more than one floating ip address.

Instances created with > 1 floating ip address get an invalid response:
{'key': 'public_ip', 'value': '90.216.134.1610.76.71.191'}

```
failed: [90.216.133.1610.75.71.181 -> 127.0.0.1] => {"elapsed": 300, "failed": true}
msg: Timeout when waiting for search string OpenSSH in 90.216.134.1610.76.71.191:22
```



Discussion:

Resolving patch:
diff --git a/cloud/openstack/nova_compute.py b/cloud/openstack/nova_compute.py
--- a/cloud/openstack/nova_compute.py
+++ b/cloud/openstack/nova_compute.py
@@ -518,7 +518,7 @@ def _get_server_state(module, nova):
         (ip_changed, server) = _check_floating_ips(module, nova, server)
         private = openstack_find_nova_addresses(getattr(server, 'addresses'), 'fixed', 'private')
         public = openstack_find_nova_addresses(getattr(server, 'addresses'), 'floating', 'public')
-        module.exit_json(changed = ip_changed, id = server.id, public_ip = ''.join(public), private_ip = ''.join(private), info = server._info)
+        module.exit_json(changed = ip_changed, id = server.id, public_ip = public, private_ip = private, info = server._info)
     if server and module.params['state'] == 'absent':
         return True
     if module.params['state'] == 'absent':


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

Issue:
ec2_scaling_policy: NameError: global name 'AWS_REGIONS' is not defined
When using ec2_scaling_policy I get this error: NameError: global name 'AWS_REGIONS' is not defined (region = dict(aliases=['aws_region', 'ec2_region'], choices=AWS_REGIONS),)

AWS_REGIONS is defined in two other modules, but not in others. Probably should be shared? Or copied across?



Discussion:
actually that line is redundant as it already get's region from the common ec2.py settings

test the PR above, it should solve the issue


Resolving patch:
diff --git a/cloud/amazon/ec2_scaling_policy.py b/cloud/amazon/ec2_scaling_policy.py
--- a/cloud/amazon/ec2_scaling_policy.py
+++ b/cloud/amazon/ec2_scaling_policy.py
@@ -147,7 +147,6 @@ def main():
             scaling_adjustment = dict(type='int'),
             min_adjustment_step = dict(type='int'),
             cooldown = dict(type='int'),
-            region = dict(aliases=['aws_region', 'ec2_region'], choices=AWS_REGIONS),
             state=dict(default='present', choices=['present', 'absent']),
         )
     )


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

Issue:
synchronize adds extra to the --rsh argument and causes failure
failed: [MY_HOST -> 127.0.0.1] => {"cmd": "rsync --delay-updates -F --compress --delete-after --archive --rsh 'ssh  -S none -o StrictHostKeyChecking=no None' --exclude=logs --out-format='<<CHANGED>>%i %n%L' \"/src/file\" \"root@MY_HOST:/root/\"", "failed": true, "rc": 255}

The 'None' after the StrickhostKeyChecking=no causes this command to fail with host not found 'none'



Discussion:
I wanted to chime in that adding:
ssh_args : no 
to the module arguments results in having it insert "False":

TASK: [appserver | Copy Files To Server] **************************************
build   28-Apr-2015 14:09:56    failed: [MY_HOST -> 127.0.0.1] => {"cmd": "rsync --delay-updates -F --compress --delete-after --checksum --recursive --rsh 'ssh -i /home/bamboo/.ssh/id_rsa -S none -o StrictHostKeyChecking=no False' --no-motd --exclude=.git --out-format='<<CHANGED>>%i %n%L' \"/home/bamboo/xml-data/build-dir/131073/24641538-24739847/files/\" \"deployer@MY_HOST:/opt/WebRoot-DEV/"", "failed": true, "rc": 255}
msg: ssh: Could not resolve hostname False: Name or service not known
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(600) [sender=3.0.6]

I was about to open an issue for the same. Here's my task:

```
- name: Apache sites-enabled
  synchronize: src=sites-enabled-prodweb dest=/etc/apache2/sites-enabled delete=yes
  sudo: yes
  notify: restart apache2
```

And the output:

```
failed: [example.com -> 127.0.0.1] => {"cmd": "rsync --delay-updates -F --compress --delete-after --archive --rsh 'ssh -i /var/lib/jenkins/.ssh/ansible/id_dsa_example.com -S none -o StrictHostKeyChecking=no None' --rsync-path=\"sudo rsync\" --out-format='<<CHANGED>>%i %n%L' \"/var/lib/jenkins/workspace/ansible-run/apache-config/files/sites-enabled-prodweb\" \"ansible@172.20.30.165:/etc/apache2/sites-enabled\"", "failed": true, "rc": 255}
msg: ssh: Could not resolve hostname None: Name or service not known
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(605) [sender=3.0.9]
```

Removing `None` after `StrictHostKeyChecking=no` fixes the issue. PR to follow.

The faulty line is here:

https://github.com/ansible/ansible-modules-core/blob/c323ef9233e63cf6538648be68262eb55b35bd06/files/synchronize.py#L319

Testing conditional to get around this, will submit a request in a few minutes.


Resolving patch:
diff --git a/files/synchronize.py b/files/synchronize.py
--- a/files/synchronize.py
+++ b/files/synchronize.py
@@ -316,7 +316,11 @@ def main():
     else:
         private_key = '-i '+ private_key 
 
-    ssh_opts = '-S none -o StrictHostKeyChecking=no %s' % ssh_args
+    if ssh_args:
+      ssh_opts = '-S none -o StrictHostKeyChecking=no %s' % ssh_args
+    else:
+      ssh_opts = '-S none -o StrictHostKeyChecking=no'
+
     if dest_port != 22:
         cmd += " --rsh 'ssh %s %s -o Port=%s'" % (private_key, ssh_opts, dest_port)
     else:


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

Issue:
Unable to set privileges for column specific entrys in mysql_user
Currently the code only allows privileges to be allowed for tables as shown here:

https://github.com/ansible/ansible-modules-core/blob/devel/database/mysql/mysql_user.py#L330-L342. 

However, when attempting to enter privileges for column specified values, the code breaks saying the column is not in the defined frozenset. 

I.E: GRANT SELECT (col3,col4),INSERT (col4) ON music.sheets TO 'tempo'@'%';

Unable to set privileges for column specific entrys in mysql_user
Currently the code only allows privileges to be allowed for tables as shown here:

https://github.com/ansible/ansible-modules-core/blob/devel/database/mysql/mysql_user.py#L330-L342. 

However, when attempting to enter privileges for column specified values, the code breaks saying the column is not in the defined frozenset. 

I.E: GRANT SELECT (col3,col4),INSERT (col4) ON music.sheets TO 'tempo'@'%';



Discussion:
I am not sure this is a 'feature idea' since this action worked prior to the update to the mysq_user.py to explicitly define the privilages. I would think that if adding that to the module, then it should be able to handle all part that come with that addition. This is causing us to use outdated modules in order to make this work will our playbooks. 

I am not sure this is a 'feature idea' since this action worked prior to the update to the mysq_user.py to explicitly define the privilages. I would think that if adding that to the module, then it should be able to handle all part that come with that addition. This is causing us to use outdated modules in order to make this work will our playbooks. 


Resolving patch:
diff --git a/database/mysql/mysql_user.py b/database/mysql/mysql_user.py
--- a/database/mysql/mysql_user.py
+++ b/database/mysql/mysql_user.py
@@ -157,6 +157,7 @@
 
 import getpass
 import tempfile
+import re
 try:
     import MySQLdb
 except ImportError:
@@ -316,13 +317,19 @@ def privileges_unpack(priv):
     not specified in the string, as MySQL will always provide this by default.
     """
     output = {}
+    privs = []
     for item in priv.strip().split('/'):
         pieces = item.strip().split(':')
         dbpriv = pieces[0].rsplit(".", 1)
         pieces[0] = "`%s`.%s" % (dbpriv[0].strip('`'), dbpriv[1])
-
-        output[pieces[0]] = [s.strip() for s in pieces[1].upper().split(',')]
-        new_privs = frozenset(output[pieces[0]])
+        if '(' in pieces[1]:
+            output[pieces[0]] = re.split(r',\s*(?=[^)]*(?:\(|$))', pieces[1].upper())
+            for i in output[pieces[0]]:
+                privs.append(re.sub(r'\(.*\)','',i))
+        else:
+            output[pieces[0]] = pieces[1].upper().split(',')
+            privs = output[pieces[0]]
+        new_privs = frozenset(privs)
         if not new_privs.issubset(VALID_PRIVS):
             raise InvalidPrivsError('Invalid privileges specified: %s' % new_privs.difference(VALID_PRIVS))
 


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

Issue:
apt: state=present for virtual packages always shown as changed
If you already have a package installed which _Provides_ a virtual package, then a
`apt: state=present name=virtual-package`
always appears as changed, apparently because the `apt-get install` output is slightly different (this is not very robust).

Eg:
_exim4-daemon-light_ is installed
Then try:
`- apt: name=default-mta state=present`
There apt output includes these 2 lines which seem to disturb the apt module:

> Note, selecting 'exim4-daemon-light' instead of 'default-mta'
> exim4-daemon-light is already the newest version.



Discussion:
I've tried to fix this a couple of times, but end up hitting infinite loops (specifically with mta dma).


Resolving patch:
diff --git a/packaging/os/apt.py b/packaging/os/apt.py
--- a/packaging/os/apt.py
+++ b/packaging/os/apt.py
@@ -206,8 +206,16 @@ def package_status(m, pkgname, version, cache, state):
     except KeyError:
         if state == 'install':
             try:
-                if cache.get_providing_packages(pkgname):
-                    return False, True, False
+                provided_packages = cache.get_providing_packages(pkgname)
+                if provided_packages:
+		    is_installed = False
+                    # when virtual package providing only one package, look up status of target package 
+                    if cache.is_virtual_package(pkgname) and len(provided_packages) == 1:
+			package = provided_packages[0]
+                        installed, upgradable, has_files = package_status(m, package.name, version, cache, state='install')
+                        if installed:
+                            is_installed = True
+                    return is_installed, True, False
                 m.fail_json(msg="No package matching '%s' is available" % pkgname)
             except AttributeError:
                 # python-apt version too old to detect virtual packages


Test patch: