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

Issue:
validate_checksum parameter of fetch module is actually default to "no" does not match the document.
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and master branch are affected too.
-->

##### ISSUE TYPE
 - Documentation Report

##### COMPONENT NAME
fetch

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.3.0.0
  config file = /home/xufan/.ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.12 (default, Sep 28 2016, 15:46:00) [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)]
```

##### CONFIGURATION
<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->
nothing

##### 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.
-->
anything

##### SUMMARY
<!--- Explain the problem briefly -->
In the ansible [document](http://docs.ansible.com/ansible/fetch_module.html) the validate_checksum is default set to yes. But actually is "no" in the [fetch.py](https://github.com/ansible/ansible/blob/v2.3.0.0-1/lib/ansible/plugins/action/fetch.py)

##### STEPS TO REPRODUCE
nothing

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
Change the validate_checksum of document default to "no".

##### ACTUAL RESULTS
nothing



Discussion:
The module/action does look like it will default to false/no when not specified which doesn't match the docs. 

I'm not sure which is actually correct.
Docs are correct, code is wrong.  validate_checksum should default to True.

Resolving patch:
diff --git a/lib/ansible/plugins/action/fetch.py b/lib/ansible/plugins/action/fetch.py
--- a/lib/ansible/plugins/action/fetch.py
+++ b/lib/ansible/plugins/action/fetch.py
@@ -46,7 +46,7 @@ def run(self, tmp=None, task_vars=None):
         dest              = self._task.args.get('dest', None)
         flat              = boolean(self._task.args.get('flat'))
         fail_on_missing   = boolean(self._task.args.get('fail_on_missing'))
-        validate_checksum = boolean(self._task.args.get('validate_checksum', self._task.args.get('validate_md5')))
+        validate_checksum = boolean(self._task.args.get('validate_checksum', self._task.args.get('validate_md5', True)))
 
         if 'validate_md5' in self._task.args and 'validate_checksum' in self._task.args:
             result['failed'] = True


Test patch:
Repository: ansible/ansible

Issue:
ec2_elb_facts module broken on 2.2.3.0
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
ec2_elb_facts

##### ANSIBLE VERSION
```
[ansible@host ~]$ ansible --version
ansible 2.3.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.12 (default, Sep  1 2016, 22:14:00) [GCC 4.8.3 20140911 (Red Hat 4.8.3-9)]
```

##### CONFIGURATION
redis fact caching is enabled

##### OS / ENVIRONMENT
Running and managing Amazon Linux although N/A because we're dealing with ELBs

##### SUMMARY
There is no self any more and so line 260 in the module is wrong

```python
except BotoServerError as err:
    self.module.fail_json(msg="{0}: {1}".format(err.error_code, err.error_message),
                              exception=traceback.format_exc())
```

##### STEPS TO REPRODUCE
Try to gather facts of an ELB and get an error

```yaml
- name: Gather elb facts
  action: 
    module: ec2_elb_facts
    region: "{{ ec2_region }}"
    aws_access_key: "{{ aws_access_key }}"
    aws_secret_key: "{{ aws_secret_key }}"
    names: "{{ ec2_elbs }}"
  register: elb_facts
  delegate_to: localhost
  run_once: yes
```

##### EXPECTED RESULTS
In the case of AWS error, ansible should report the error and not crash.

##### ACTUAL RESULTS
```
fatal: [10.30.0.143 -> localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_eFbJEs/ansible_module_ec2_elb_facts.py\", line 267, in <module>\n    main()\n  File \"/tmp/ansible_eFbJEs/ansible_module_ec2_elb_facts.py\", line 260, in main\n    self.module.fail_json(msg=\"{0}: {1}\".format(err.error_code, err.error_message),\nNameError: global name 'self' is not defined\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1}
```

I will have a PR up later today for this.


Discussion:
cc @mjschultz
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/modules/cloud/amazon/ec2_elb_facts.py b/lib/ansible/modules/cloud/amazon/ec2_elb_facts.py
--- a/lib/ansible/modules/cloud/amazon/ec2_elb_facts.py
+++ b/lib/ansible/modules/cloud/amazon/ec2_elb_facts.py
@@ -257,8 +257,8 @@ def main():
                                 elbs=elb_information.list_elbs())
 
     except BotoServerError as err:
-        self.module.fail_json(msg="{0}: {1}".format(err.error_code, err.error_message),
-                              exception=traceback.format_exc())
+        module.fail_json(msg="{0}: {1}".format(err.error_code, err.error_message),
+                         exception=traceback.format_exc())
 
     module.exit_json(**ec2_facts_result)
 


Test patch:
Repository: ansible/ansible

Issue:
SVN module in check mode should check modified files
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
subversion module

##### ANSIBLE VERSION
```
ansible 2.2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```

##### CONFIGURATION
Default

##### OS / ENVIRONMENT
N/A

##### SUMMARY
For our deployment purposes using Ansible and SVN we would need to test (check mode, dry-run) before run the deployment playbook. If there is some missing file in the destination it will pass the check-mode but not the definitive one.

I looked at the code and I think it will do the job to add in current line 287:

if module.check_mode or not update:
if (svn.has_local_mods() && !force)
module.fail_json(msg="ERROR: modified files exist in the repository.")
check, before, after = svn.needs_update()
module.exit_json(changed=check, before=before, after=after)

I am far from an expert on this, so I prefer to post it here so maybe someone can help and implement it! :)

##### STEPS TO REPRODUCE

```yaml
- subversion:
    repo: svn+ssh://an.example.org/path/to/repo
    dest: /src/checkout
ansible-playbook example.yml --check
```

##### EXPECTED RESULTS
If there are modified files should give an ERROR.

##### ACTUAL RESULTS
Everything is OK.



Discussion:
cc @dsummersl
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
anyone? :(
@vjcalvo I'm sorry I haven't had a chance to look at this recently - I'll take a look tonight.
thanks, no hurries! (it's my first reported issue, don't know how it goes) Anything I can do for help, just let me know. regards!

Resolving patch:
diff --git a/lib/ansible/modules/source_control/subversion.py b/lib/ansible/modules/source_control/subversion.py
--- a/lib/ansible/modules/source_control/subversion.py
+++ b/lib/ansible/modules/source_control/subversion.py
@@ -285,6 +285,8 @@ def main():
         # positives. Need to switch before revert to ensure we are reverting to
         # correct repo.
         if module.check_mode or not update:
+            if svn.has_local_mods() and not force:
+                module.fail_json(msg="ERROR: modified files exist in the repository.")
             check, before, after = svn.needs_update()
             module.exit_json(changed=check, before=before, after=after)
         before = svn.get_revision()


Test patch:
Repository: ansible/ansible

Issue:
pywinrm warnings if ansible_winrm_kinit_mode=manual is used
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
winrm / kerberos

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.3.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, Feb 28 2017, 11:34:48) [GCC 5.4.0]
```

##### CONFIGURATION
added option ansible_winrm_kinit_mode=manual to as variable since we use kinit outside ansible.

##### OS / ENVIRONMENT
Gentoo Linux
pywinrm-0.2.2
requests-kerberos-0.11.0

##### SUMMARY
Since the update to ansible 2.3 kerberos doesn't work anymore if there already is a kerberos ticket available.
This can be overridden by setting ansible_winrm_kinit_mode=manual  as mentioned in #20416 . But this keeps producing lots of warnings.
```
 [WARNING]: ansible_winrm_kinit_mode unsupported by pywinrm (is an up-to-date version of pywinrm installed?)
```

##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->

<!--- Paste example playbooks or commands between quotes below -->
```yaml
ansible server.domain.com -m setup
 [WARNING]: ansible_winrm_kinit_mode unsupported by pywinrm (is an up-to-date version of pywinrm installed?)

server.domain.com | SUCCESS => {
.....
server facts
.....
```

##### EXPECTED RESULTS
If set to manual there shouldn't be any warning that it's unsupported by winrm.


Discussion:

Resolving patch:
diff --git a/lib/ansible/plugins/connection/winrm.py b/lib/ansible/plugins/connection/winrm.py
--- a/lib/ansible/plugins/connection/winrm.py
+++ b/lib/ansible/plugins/connection/winrm.py
@@ -143,10 +143,10 @@ def set_host_overrides(self, host, hostvars=None):
         elif kinit_mode == "manual":
             self._kerb_managed = False
         else:
-            raise AnsibleError('Unknown ansible_winrm_kinit_mode value: %s' % kinit_mode)
+            raise AnsibleError('Unknown ansible_winrm_kinit_mode value: "%s" (must be "managed" or "manual")' % kinit_mode)
 
         # arg names we're going passing directly
-        internal_kwarg_mask = set(['self', 'endpoint', 'transport', 'username', 'password', 'scheme', 'path'])
+        internal_kwarg_mask = set(['self', 'endpoint', 'transport', 'username', 'password', 'scheme', 'path', 'kinit_mode', 'kinit_cmd'])
 
         self._winrm_kwargs = dict(username=self._winrm_user, password=self._winrm_pass)
         argspec = inspect.getargspec(Protocol.__init__)


Test patch:
Repository: ansible/ansible

Issue:
Ansible should fail when CloudFormation ends up in a `ROLLBACK_COMPLETE` status
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
cloudformation

##### ANSIBLE VERSION
```
ansible 2.3.0.0
  config file = /Users/jose.armesto/.ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, Feb  7 2017, 22:08:53) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
```

##### CONFIGURATION
N/A

##### OS / ENVIRONMENT
N/A

##### SUMMARY
Ansible should fail when CloudFormation ends up in a `ROLLBACK_COMPLETE` status.

##### EXPECTED RESULTS
```
PLAY RECAP *********************************************************************
localhost                  : ok=33   changed=8    unreachable=0    failed=1  
```

##### ACTUAL RESULTS
```
PLAY RECAP *********************************************************************
localhost                  : ok=33   changed=8    unreachable=0    failed=0
```



Discussion:
cc @tedder @ryansb
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
It seems like in the boto3 rewrite, [the case when the stack status was ROLLBACK_COMPLETE was forgotten](https://github.com/ansible/ansible-modules-core/commit/f040d63403f6c459a278918fa48fa8cb87754506#diff-68a48645e655d4879298e03d72b70d11L205).

Resolving patch:
diff --git a/lib/ansible/modules/cloud/amazon/cloudformation.py b/lib/ansible/modules/cloud/amazon/cloudformation.py
--- a/lib/ansible/modules/cloud/amazon/cloudformation.py
+++ b/lib/ansible/modules/cloud/amazon/cloudformation.py
@@ -343,8 +343,10 @@ def stack_operation(cfn, stack_name, operation):
             else:
                 ret.update({'changed': False, 'failed': True, 'output' : 'Stack not found.'})
                 return ret
-        elif stack['StackStatus'].endswith('_ROLLBACK_COMPLETE'):
-            ret.update({'changed': True, 'failed' :True, 'output': 'Problem with %s. Rollback complete' % operation})
+        # it covers ROLLBACK_COMPLETE and UPDATE_ROLLBACK_COMPLETE
+        # Possible states: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-describing-stacks.html#w1ab2c15c17c21c13
+        elif stack['StackStatus'].endswith('ROLLBACK_COMPLETE'):
+            ret.update({'changed': True, 'failed': True, 'output': 'Problem with %s. Rollback complete' % operation})
             return ret
         # note the ordering of ROLLBACK_COMPLETE and COMPLETE, because otherwise COMPLETE will match both cases.
         elif stack['StackStatus'].endswith('_COMPLETE'):


Test patch:
Repository: ansible/ansible

Issue:
Potential fix for setup ansible_selinux var incorrect on Fedora 23
Not 100% certain that this is the verbage we want, but it makes more sense than "False".

Fixes http://github.com/ansible/ansible-modules-core/issues/2432



Discussion:
What about people who are specifically keying off of the value being `False`?  Changing it to a populated string makes this truthy.

Hmm. The copy module seems to knows if selinux is absent (should be False) even without this. Because it only allows to proceed if selinux is absent.

`fatal: [localhost]: FAILED! => {"changed": false, "checksum": "c0d11c949e67c16d49020bc1262646d5de787835", "failed": true, "msg": "Aborting, target uses selinux but python bindings (libselinux-python) aren't installed!"}`

I think this ties into the point @sivel made. We may be running on a system where there's no package at all for `libselinux-python`, because the distribution doesn't support selinux. In that case it would be best to avoid a truthy `ansible_selinux`. Could the code from the `copy` module be re-used here, so `ansible_selinux` is only truthy when "target uses selinux"?

@goozbach This PR was tested by travis-ci.org, which is no longer used. Please [rebase your branch](http://docs.ansible.com/ansible/dev_guide/developing_rebasing.html) to trigger running of current tests.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: travis_notify --->
@goozbach Greetings! Thanks for taking the time to open this pullrequest. In order for the community to handle your pullrequest effectively, we need a bit more information. 

Here are the items we could not find in your description:
- issue type

Please set the description of this pullrequest with this template:
https://raw.githubusercontent.com/ansible/ansible/devel/.github/PULL_REQUEST_TEMPLATE.md

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: issue_missing_data --->

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
@@ -443,8 +443,10 @@ def get_lsb_facts(self):
     def get_selinux_facts(self):
         if not HAVE_SELINUX:
             self.facts['selinux'] = False
+            self.facts['selinux_python_present'] = False
             return
         self.facts['selinux'] = {}
+        self.facts['selinux_python_present'] = True
         if not selinux.is_selinux_enabled():
             self.facts['selinux']['status'] = 'disabled'
         else:


Test patch:
Repository: ansible/ansible

Issue:
os_volume always returns `changed=true`
_From @ericcitaire on November 17, 2016 14:41_

##### ISSUE TYPE
Bug Report

##### COMPONENT NAME
Module `os_volume`

##### ANSIBLE VERSION
```
ansible 2.2.0.0
  config file = 
  configured module search path = Default w/o overrides
```

##### CONFIGURATION
Default

##### OS / ENVIRONMENT
Running from Mac OS 10.11.6 with virtualenv, managing Open Stack API

##### SUMMARY
When destroying an OpenStack volume, the module always resturns `changed=true`

##### STEPS TO REPRODUCE
```yaml
- os_volume:
    cloud: mycloud
    display_name: myvol
    state: absent
```

##### EXPECTED RESULTS
```
ok: [localhost]
```
##### ACTUAL RESULTS
```
changed: [localhost]
```


_Copied from original issue: ansible/ansible-modules-core#5649_


Discussion:
_From @ansibot on November 17, 2016 15:17_

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

@emonty, @shrews, @juliakreger, @j2sol, @rcarrillocruz, @thingee, 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_bug_new --->

_From @j2sol on November 18, 2016 0:43_

Yup, this module doesn't check to see if work is needed first.

_From @ansibot on December 7, 2016 20:5_

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the <a href="http://docs.ansible.com/ansible/dev_guide/repomerge.html#move-issues-and-prs-to-new-repo">repomerge</a> page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo.

<!-- boilerplate: repomerge -->

Resolving patch:
diff --git a/lib/ansible/modules/cloud/openstack/os_volume.py b/lib/ansible/modules/cloud/openstack/os_volume.py
--- a/lib/ansible/modules/cloud/openstack/os_volume.py
+++ b/lib/ansible/modules/cloud/openstack/os_volume.py
@@ -131,14 +131,16 @@ def _present_volume(module, cloud):
 
 
 def _absent_volume(module, cloud):
-    try:
-        cloud.delete_volume(
-            name_or_id=module.params['display_name'],
-            wait=module.params['wait'],
-            timeout=module.params['timeout'])
-    except shade.OpenStackCloudTimeout:
-        module.exit_json(changed=False)
-    module.exit_json(changed=True)
+    changed = False
+    if cloud.volume_exists(module.params['display_name']):
+        try:
+            changed = cloud.delete_volume(name_or_id=module.params['display_name'],
+                                          wait=module.params['wait'],
+                                          timeout=module.params['timeout'])
+        except shade.OpenStackCloudTimeout:
+            module.exit_json(changed=changed)
+
+    module.exit_json(changed=changed)
 
 
 def main():


Test patch:
Repository: ansible/ansible

Issue:
Docker containers always redeployed when security_opts are specified
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and master branch are affected too.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report

##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
docker_container

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```

##### CONFIGURATION
```
security_opts:
    - "apparmor:unconfined"
    - "seccomp:unconfined"
```

##### OS / ENVIRONMENT
Ubuntu 16.04.2

##### SUMMARY
When security_opts are specified the docker container is always rebuilt with the config:

```
- name: deploy gitlab
  docker_container:
    name: gitlab
    image: gitlab/gitlab-ce
    state: started
    restart_policy: always
    security_opts:
    - "apparmor:unconfined"
    - "seccomp:unconfined"
```

##### STEPS TO REPRODUCE
```
1.) Create a playbook with the following content:

---
- name: deploy gitlab
  docker_container:
    name: gitlab
    image: gitlab/gitlab-ce
    state: started
    restart_policy: always
    security_opts:
    - "apparmor:unconfined"
    - "seccomp:unconfined"

2.) Run the playbook (container is built as expected!)

3.) Run the playbook again (container is re-built - not expected.)
```


Discussion:

Resolving patch:
diff --git a/lib/ansible/modules/cloud/docker/docker_container.py b/lib/ansible/modules/cloud/docker/docker_container.py
--- a/lib/ansible/modules/cloud/docker/docker_container.py
+++ b/lib/ansible/modules/cloud/docker/docker_container.py
@@ -1277,7 +1277,7 @@ def has_different_configuration(self, image):
             restart_retries=restart_policy.get('MaximumRetryCount'),
             # Cannot test shm_size, as shm_size is not included in container inspection results.
             # shm_size=host_config.get('ShmSize'),
-            security_opts=host_config.get("SecuriytOpt"),
+            security_opts=host_config.get("SecurityOpt"),
             stop_signal=config.get("StopSignal"),
             tty=config.get('Tty'),
             expected_ulimits=host_config.get('Ulimits'),


Test patch:
Repository: ansible/ansible

Issue:
Documentation for win_stat is missing the 'exist' attribute
##### ISSUE TYPE
 - Documentation Report

##### COMPONENT NAME
win_stat

##### ANSIBLE VERSION
```
2.3.0
```

##### SUMMARY
the 'win_stat' module emits a number of properties in its "stat" return object, among these "exists". This is not documented, although it's arguably the most important property.



Discussion:
cc @nitzmahone
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/modules/windows/win_stat.py b/lib/ansible/modules/windows/win_stat.py
--- a/lib/ansible/modules/windows/win_stat.py
+++ b/lib/ansible/modules/windows/win_stat.py
@@ -130,11 +130,21 @@
             returned: success, path exists
             type: float
             sample: 1477984205.15
+        exists:
+            description: if the path exists or not
+            returned: success
+            type: boolean
+            sample: True
         extension:
             description: the extension of the file at path
             returned: success, path exists, path is a file
             type: string
             sample: ".ps1"
+        filename:
+            description: the name of the file (without path)
+            returned: success, path exists, path is a file
+            type: string
+            sammple: foo.ini
         isarchive:
             description: if the path is ready for archiving or not
             returned: success, path exists
@@ -192,9 +202,9 @@
             sample: BUILTIN\Administrators
         path:
             description: the full absolute path to the file
-            returned: success, path exists
+            returned: success, path exists, file exists
             type: string
-            sample: BUILTIN\Administrators
+            sample: C:\foo.ini
         sharename:
             description: the name of share if folder is shared
             returned: success, path exists, file is a directory and isshared == True


Test patch: