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

Issue:
docker_service: check minimum version of docker-compose required 
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME

docker_service
##### ANSIBLE VERSION

```
[root@bc0523ab43d3 /]# rpm -q ansible       
ansible-2.1.0.0-1.fc23.noarch
[root@bc0523ab43d3 /]# ansible --version
ansible 2.1.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```
##### OS / ENVIRONMENT

Fedora 23
docker-compose-1.6.2-1.fc23.noarch
##### SUMMARY

When using docker_service module ansible complains:

```
There was an error running ansible-playbook: exit status 2
output is:  
PLAY [opencompose] *************************************************************

TASK [docker_service] **********************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Unable to load docker-compose. Try `pip install docker-compose`. Error: cannot import name build_action_from_opts"}

NO MORE HOSTS LEFT *************************************************************
        to retry, use: --limit @./fooplaybook.retry

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

I think this is because the docker-compose version is docker-compose-1.6.2-1.fc23.noarch vs 1.7 like in Fedora 24. Should we update the module to check minimum version required. 
##### STEPS TO REPRODUCE

on Fedora 23:
dnf install -y docker-compose ansible
run a playbook with the docker_service module in it. 



Discussion:

Resolving patch:
diff --git a/cloud/docker/docker_service.py b/cloud/docker/docker_service.py
--- a/cloud/docker/docker_service.py
+++ b/cloud/docker/docker_service.py
@@ -404,12 +404,15 @@
 
 HAS_COMPOSE = True
 HAS_COMPOSE_EXC = None
+MINIMUM_COMPOSE_VERSION = '1.7.0'
 
 import yaml
+from distutils.version import LooseVersion
 
 from ansible.module_utils.basic import *
 
 try:
+    from compose import __version__ as compose_version
     from compose.cli.command import project_from_options
     from compose.service import ConvergenceStrategy
     from compose.cli.main import convergence_strategy_from_opts, build_action_from_opts, image_type_from_opt
@@ -474,6 +477,11 @@ def __init__(self, client):
         if self.files:
             self.options[u'--file'] = self.files
 
+        if LooseVersion(compose_version) < LooseVersion(MINIMUM_COMPOSE_VERSION):
+            self.client.fail("Found docker-compose version %s. Minimum required version is %s. "
+                             "Upgrade docker-compose to a min version of %s." %
+                             (compose_version, MINIMUM_COMPOSE_VERSION, MINIMUM_COMPOSE_VERSION))
+
         if not HAS_COMPOSE:
             self.client.fail("Unable to load docker-compose. Try `pip install docker-compose`. Error: %s" % HAS_COMPOSE_EXC)
 


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

Issue:
docker_container: by default will always remove volumes associated with container
<!--- Verify first that your issue/request is not already reported in GitHub -->
##### ISSUE TYPE

<!--- Pick one below and delete the rest: -->
- Bug Report
##### COMPONENT NAME

<!--- Name of the plugin/module/task -->

docker_container
##### ANSIBLE VERSION

<!--- Paste verbatim output from “ansible --version” between quotes below -->

```
ansible 2.2.0
  config file = 
  configured module search path = Default w/o overrides

```
##### OS / ENVIRONMENT

<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say “N/A” for anything that is not platform-specific.
-->

N/A
##### SUMMARY

<!--- Explain the problem briefly -->

docker-py remove_container function is wrongly used. 

Default value for keep_volumes is True,  which is passed to remove_container as is, but remove_container "v" parameter should be True only if volumes need to be removed. So by default all volumes associated with container are removed.

see https://github.com/ansible/ansible-modules-core/blob/1eb63c7567430e5f5b862b348dc9c3f61a1ede4e/cloud/docker/docker_container.py#L1780

> v – 1/True/true or 0/False/false, Remove the volumes associated to the container. Default false.



Discussion:

Resolving patch:
diff --git a/cloud/docker/docker_container.py b/cloud/docker/docker_container.py
--- a/cloud/docker/docker_container.py
+++ b/cloud/docker/docker_container.py
@@ -1776,10 +1776,10 @@ def container_start(self, container_id):
                 self.fail("Error starting container %s: %s" % (container_id, str(exc)))
         return self._get_container(container_id)
 
-    def container_remove(self, container_id, v=False, link=False, force=False):
-        volume_state = (True if self.parameters.keep_volumes else False)
-        self.log("remove container container:%s v:%s link:%s force%s" % (container_id, v, link, force))
-        self.results['actions'].append(dict(removed=container_id, volume_state=volume_state))
+    def container_remove(self, container_id, link=False, force=False):
+        volume_state = (not self.parameters.keep_volumes)  
+        self.log("remove container container:%s v:%s link:%s force%s" % (container_id, volume_state, link, force))
+        self.results['actions'].append(dict(removed=container_id, volume_state=volume_state, link=link, force=force))
         self.results['changed'] = True
         response = None
         if not self.check_mode:


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

Issue:
Docker module fails on reload with labels
##### ISSUE TYPE

Bug Report
##### COMPONENT NAME

_docker module
##### ANSIBLE VERSION

N/A
##### SUMMARY

Docker module fails  on reloading a container with labels.

```
fatal: [******]: FAILED! => {"changed": false, "failed": true, "module_stderr": "", "module_stdout": "build-date
Traceback (most recent call last):
  File \"/root/.ansible/tmp/ansible-tmp-1455098151.93-54009480136008/docker\", line 3962, in <module>
    main()
  File \"/root/.ansible/tmp/ansible-tmp-1455098151.93-54009480136008/docker\", line 1897, in main
    reloaded(manager, containers, count, name)
  File \"/root/.ansible/tmp/ansible-tmp-1455098151.93-54009480136008/docker\", line 1750, in reloaded\r\n    for container in manager.get_differing_containers():
  File \"/root/.ansible/tmp/ansible-tmp-1455098151.93-54009480136008/docker\", line 1264, in get_differing_containers
    name, value = container_label.split('=', 1)
ValueError: need more than 1 value to unpack
", "msg": "MODULE FAILURE", "parsed": false}
```

I managed to track this down to the way the labels are parsed on containers which are already running. The labels are assumed to be a list of strings which are separated with a equal sign. This has changed in docker api 1.18, it became a dictionary.

I have fixed this issue in PR #3005 



Discussion:
Sounds like this is a blocking issue for use of the newer docker APIs...


Resolving patch:
diff --git a/cloud/docker/docker.py b/cloud/docker/docker.py
--- a/cloud/docker/docker.py
+++ b/cloud/docker/docker.py
@@ -1301,9 +1301,12 @@ def get_differing_containers(self):
                 expected_labels[name] = str(value)
 
             actual_labels = {}
-            for container_label in container['Config']['Labels'] or []:
-                name, value = container_label.split('=', 1)
-                actual_labels[name] = value
+            if isinstance(container['Config']['Labels'], dict):
+                actual_labels = container['Config']['Labels']
+            else:
+                for container_label in container['Config']['Labels'] or []:
+                    name, value = container_label.split('=', 1)
+                    actual_labels[name] = value
 
             if actual_labels != expected_labels:
                 self.reload_reasons.append('labels {0} => {1}'.format(actual_labels, expected_labels))


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

Issue:
cron state is changed when using multiline job
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME

cron
##### ANSIBLE VERSION

2.0.2.0
##### CONFIGURATION
##### OS / ENVIRONMENT

Darwin craneworks 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64
##### SUMMARY

When the corn moduled is faced with a multiline jobit can't figure out the correct state of the task. It just reports everytime a changed.
##### STEPS TO REPRODUCE

```
- name: returns a changed every time
  cron:
    name: renewal cron
    job: >
      bash -l -c
      "mkdir -p /tmp/certbot-auto &&
      /opt/certbot/certbot-auto certonly
      -d www.mydomain
      --agree-tos --renew-by-default
      -a webroot --webroot-path=\"/tmp/certbot-auto\" &&
      service nginx reload"
    special_time: "monthly"

- name: works as expected
  cron:
    name: debug cron
    job: bash -l -c "mkdir -p /tmp/certbot-auto && /opt/certbot/certbot-auto certonly -d www.mydomain --agree-tos --renew-by-default -a webroot --webroot-path=\"/tmp/certbot-auto\" && service nginx reload"
    special_time: "monthly"
```
##### EXPECTED RESULTS

A changed the first time it is run and after this just a ok
##### ACTUAL RESULTS

Changed is returned every time



Discussion:
I can confirm that this is still present in 2.1.0.

##### ANSIBLE VERSION

```
$ ansible --version
ansible 2.1.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```

##### OS / ENVIRONMENT

Mac OS X 10.11.5

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

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

This is largely an educated guess, but I expect it has something to do with the job coming in as [folded style yaml](http://www.yaml.org/spec/1.2/spec.html#id2796251), very likely with a trailing newline.

Effectively, the new job _could_ have a trailing newline, but the old job would always be retrieved from the crontab _without_ any trailing newlines...hence a phantom change.

Perhaps the [CronTab.get_cron_job](https://github.com/ansible/ansible-modules-core/blob/a3bae3e6ce059b63d53c8ae8e2bf013c25a5447e/system/cron.py#L385) method should be normalizing any leading and trailing whitespace **before the comparison to the old job is made**?


Resolving patch:
diff --git a/system/cron.py b/system/cron.py
--- a/system/cron.py
+++ b/system/cron.py
@@ -383,6 +383,9 @@ def find_env(self, name):
         return []
 
     def get_cron_job(self,minute,hour,day,month,weekday,job,special,disabled):
+        # normalize any leading/trailing newlines (ansible/ansible-modules-core#3791)
+        job = job.strip('\r\n')
+
         if disabled:
             disable_prefix = '#'
         else:


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

Issue:
ELB documentation does not match reality: listeners are mandatory
##### ISSUE TYPE
- Documentation Report
##### COMPONENT NAME

ec2_elb_lb
##### ANSIBLE VERSION

ansible 2.1.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
##### CONFIGURATION

$ env | grep ANSIBLE
ANSIBLE_HOST_KEY_CHECKING=false
##### OS / ENVIRONMENT

Mac OS X El Capitan
##### SUMMARY

The documentation states that listener is an optional item, when it seems it is not.
##### STEPS TO REPRODUCE

Using the following task:

```
- name: Create ELB for sender servers
  local_action:
    module: ec2_elb_lb
    name: "{{ elb_sender }}"
    state: present
    zones: "{{ availability_zones }}"
    tags:
      Name: "{{ elb_sender }}"
      type: "{{ type_sender }}"
      env: "{{ env }}"
    cross_az_load_balancing: "yes"
    security_group_names: "{{ security_group_sender }}"
    wait: yes
```
##### EXPECTED RESULTS

ELB created without listeners as per documentation
##### ACTUAL RESULTS

```
fatal: [localhost -> localhost]: FAILED! => {"changed": false, "failed": true, "msg": "At least one port is required for ELB creation"}
```



Discussion:
<!-- @minac: Thanks for filing this documentation report! -->

@jsdalton, @rickmendes, ping. This issue is waiting on your response.
[click here for bot help](https://github.com/jctanner/ansibullbot/blob/ISSUE_TRIAGE_CLASS/ISSUE_HELP.md)

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

@minac This looks like a boto3 change. Listeners were not required according to the boto2 docs, but are per the boto3 docs. I will get a PR up this weekend that protects against this and updates the documentation.

Thanks Rick!

## 

Miguel
https://www.migueldavid.eu

On 30 Jul 2016 5:28 p.m., "Rick Mendes" notifications@github.com wrote:

> @minac https://github.com/minac This looks like a boto3 change.
> Listeners were not required according to the boto2 docs, but are per the
> boto3 docs. I will get a PR up this weekend that protects against this and
> updates the documentation.
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> https://github.com/ansible/ansible-modules-core/issues/4227#issuecomment-236374718,
> or mute the thread
> https://github.com/notifications/unsubscribe-auth/AEzKhhsHN0kjLevrSR_8qZXw0EmfrD8Rks5qa3vDgaJpZM4JRulh
> .


Resolving patch:
diff --git a/cloud/amazon/ec2_elb_lb.py b/cloud/amazon/ec2_elb_lb.py
--- a/cloud/amazon/ec2_elb_lb.py
+++ b/cloud/amazon/ec2_elb_lb.py
@@ -1278,7 +1278,7 @@ def main():
     tags = module.params['tags']
     
     if state == 'present' and not listeners:
-        module.fail_json(msg="At least one port is required for ELB creation")
+        module.fail_json(msg="At least one listener is required for ELB creation")
 
     if state == 'present' and not (zones or subnets):
         module.fail_json(msg="At least one availability zone or subnet is required for ELB creation")


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

Issue:
docker_image module always returns changed with state: present
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME

docker_image
##### ANSIBLE VERSION

```
ansible 2.1.0.0
  config file = /Users/otaviomedeiros/MyProjects/my-evernote/setup-automation/ansible.cfg
  configured module search path = Default w/o overrides
```
##### CONFIGURATION

My ansible.cfg

```
[defaults]
inventory=./dev
remote_user = vagrant

```
##### OS / ENVIRONMENT

OSX
##### SUMMARY

`docker_image` module always returns `changed` with `state: present`
##### STEPS TO REPRODUCE

```

---
- hosts: webserver
  become: true
  gather_facts: false
  tasks:
    - name: pull node image
      docker_image:
        name: node:argon
        state: present

```
##### EXPECTED RESULTS

I expect that it only should be `changed` when it is executed the first time
##### ACTUAL RESULTS

```
PLAY [webserver] ***************************************************************

TASK [pull node image] *********************************************************
changed: [192.168.99.120]

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



Discussion:
It is ok when i used this way...

```
tasks:
    - name: pull node image
      docker_image:
        name: node
        state: present
        tag: 'argon'
```

```
TASK [pull node image] *********************************************************
ok: [192.168.99.120]
```

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

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

Yep. This is a bug. Seeing it while running from source as well. We're not handing _name_ parameter correctly when format is image:tag.


Resolving patch:
diff --git a/cloud/docker/docker_image.py b/cloud/docker/docker_image.py
--- a/cloud/docker/docker_image.py
+++ b/cloud/docker/docker_image.py
@@ -116,7 +116,8 @@
   tag:
     description:
       - Used to select an image when pulling. Will be added to the image when pushing, tagging or building. Defaults to
-       C(latest).
+        I(latest).
+      - If C(name) parameter format is I(name:tag), then tag value from C(name) will take precedence.
     default: latest
     required: false
   container_limits:
@@ -258,6 +259,12 @@ def __init__(self, client, results):
         self.http_timeout = parameters.get('http_timeout')
         self.push = parameters.get('push')
 
+        # If name contains a tag, it takes precedence over tag parameter.
+        repo, repo_tag = parse_repository_tag(self.name)
+        if repo_tag:
+           self.name = repo
+           self.tag = repo_tag
+        
         if self.state in ['present', 'build']:
             self.present()
         elif self.state == 'absent':


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

Issue:
git module SHA version not work for clone
In documentation:

```
What version of the repository to check out. This can be the full 40-character SHA-1 hash, the literal string HEAD, a branch name, or a tag name.
```

But it not work for clone, because `git clone` not support this.

So in this case better note about this in documentation.



Discussion:
It should work, if you also provide a refspec (which is then used for clone/fetch). Nevertheless one should specify this better in the docs.

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

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


Resolving patch:
diff --git a/source_control/git.py b/source_control/git.py
--- a/source_control/git.py
+++ b/source_control/git.py
@@ -46,8 +46,9 @@
         default: "HEAD"
         description:
             - What version of the repository to check out.  This can be the
-              full 40-character I(SHA-1) hash, the literal string C(HEAD), a
-              branch name, or a tag name.
+              the literal string C(HEAD), a branch name, a tag name. 
+              It can also be a I(SHA-1) hash, in which case C(refspec) needs 
+              to be specified if the given revision is not already available.
     accept_hostkey:
         required: false
         default: "no"


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

Issue:
Fix #4412: os_security_group_rule support numbered protocols
##### ISSUE TYPE
- Bugfix Pull Request
##### COMPONENT NAME

cloud/openstack/os_security_group_rule.py
##### ANSIBLE VERSION

```
ansible 2.1.1.0
  config file = 
  configured module search path = Default w/o overrides
```
##### SUMMARY

Bugfix correctly points out lack of VRRP support by way of numbered protocol.  This commit adds this functionality, including example usage in the documentation.



Discussion:
Thanks @davidjpeacock. To the current maintainers, @emonty, @shrews, @juliakreger, @j2sol, @rcarrillocruz please review according to guidelines (http://docs.ansible.com/ansible/developing_modules.html#module-checklist) and comment with text 'shipit', 'needs_revision' or 'close_me' as appropriate.

[This message brought to you by your friendly Ansibull-bot.]


Resolving patch:
diff --git a/cloud/openstack/os_security_group_rule.py b/cloud/openstack/os_security_group_rule.py
--- a/cloud/openstack/os_security_group_rule.py
+++ b/cloud/openstack/os_security_group_rule.py
@@ -38,7 +38,7 @@
      required: true
    protocol:
       description:
-        - IP protocol
+        - IP protocols TCP UDP ICMP 112 (VRRP)
       choices: ['tcp', 'udp', 'icmp', 112, None]
       default: None
    port_range_min:


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

Issue:
replace.py is failing with an UnboundLocalError
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME

replace
##### ANSIBLE VERSION

```
ansible 2.2.0 (devel d99c58ee55) last updated 2016/09/01 10:10:05 (GMT -700)
  lib/ansible/modules/core: (detached HEAD 7e79c59d38) last updated 2016/09/01 10:10:05 (GMT -700)
  lib/ansible/modules/extras: (detached HEAD e8a5442345) last updated 2016/09/01 10:10:05 (GMT -700)
  config file = /Users/jgrigonis/projects/omicia_ansible/ansible.cfg
  configured module search path = Default w/o overrides
```
##### OS / ENVIRONMENT

OS X controller
centos 6 target
##### SUMMARY

Seems like a bad commit
5728ef89f0764be9066fc1bf0fbbf7785e60f4cb
##### STEPS TO REPRODUCE

```
- name: fix ctypes file
  replace:
    dest: '/usr/local/lib/python2.7/ctypes/__init__.py'
    regexp: '^(    CFUNCTYPE.c_int..lambda: None.)'
    replace: '    # CFUNCTYPE(c_int)(lambda: None)'
  when: init.stat.exists == True
```
##### EXPECTED RESULTS

Do a replacement
##### ACTUAL RESULTS

```
{"changed": false, "failed": true, "module_stderr": "", "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_Kl6JDv/ansible_module_replace.py\", line 179, in <module>\r\n    main()\r\n  File \"/tmp/ansible_Kl6JDv/ansible_module_replace.py\", line 173, in main\r\n    module.exit_json(changed=changed, msg=msg, diff=diff)\r\nUnboundLocalError: local variable 'diff' referenced before assignment\r\n", "msg": "MODULE FAILURE"}
```



Discussion:
@jgrigonis we are unable to validate that "ansible_ _replace.py" is an existing ansible module.

We are expecting a component name that matches something that can be found in:
- http://docs.ansible.com/ansible/list_of_all_modules.html

Please revise the component name in the description.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_invalid_module --->

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

<!--- boilerplate: issue_notify_maintainer --->


Resolving patch:
diff --git a/files/replace.py b/files/replace.py
--- a/files/replace.py
+++ b/files/replace.py
@@ -131,6 +131,7 @@ def main():
 
     params = module.params
     dest = os.path.expanduser(params['dest'])
+    diff = dict()
 
     if os.path.isdir(dest):
         module.fail_json(rc=256, msg='Destination %s is a directory !' % dest)


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

Issue:
apache2_module fails for php7.0 on Ubuntu Xenial
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME

apache2_module
##### ANSIBLE VERSION

<!--- Paste verbatim output from “ansible --version” between quotes below -->

```
ansible 2.2.0 (devel 982db58aff) last updated 2016/09/08 11:50:49 (GMT +100)
  lib/ansible/modules/core: (detached HEAD db38f0c876) last updated 2016/09/08 13:03:40 (GMT +100)
  lib/ansible/modules/extras: (detached HEAD 8bfdcfcab2) last updated 2016/09/08 11:51:00 (GMT +100)
  config file = /home/rowan/.ansible.cfg
  configured module search path = Default w/o overrides
```
##### CONFIGURATION

N/A
##### OS / ENVIRONMENT

N/A
##### SUMMARY

Ubuntu Xenial lists the php7.0 module as php7_module when running apache2ctl -M this breaks the regexp checking if the module is enabled.

I've made a work around here https://github.com/rwky/ansible-modules-core/commit/00ad6ef035a10dac7c84b7b68f04b00a739b104b but I didn't make a PR since I expect it may break other distros/versions.

Not entirely sure what the best solution to this is.
##### STEPS TO REPRODUCE

Run apache2_module with name=php7.0 state=present on a xenial server.



Discussion:

Resolving patch:
diff --git a/web_infrastructure/apache2_module.py b/web_infrastructure/apache2_module.py
--- a/web_infrastructure/apache2_module.py
+++ b/web_infrastructure/apache2_module.py
@@ -80,6 +80,12 @@ def _module_is_enabled(module):
 
     result, stdout, stderr = module.run_command("%s -M" % control_binary)
 
+    """
+    Work around for Ubuntu Xenial listing php7_module as php7.0
+    """
+    if name == "php7.0":
+        name = "php7"
+
     if result != 0:
         module.fail_json(msg="Error executing %s: %s" % (control_binary, stderr))
 


Test patch: