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

Issue:
Update docs for junos module
<!---
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: -->
  - Documentation Report

##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
junos_* modules

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
2.3.0.0
```

##### CONFIGURATION
<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->

##### 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.
-->

##### SUMMARY
<!--- Explain the problem briefly -->
With Ansible 2.3 junos modules dont need junos-eznc as dependency. But the docs for few of junos module still mention junos-eznc as required dependency. So just need to update the docs.

##### 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

```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->
```

```



Discussion:
cc @Qalthos @ganeshrn

Resolving patch:
diff --git a/lib/ansible/modules/network/junos/_junos_template.py b/lib/ansible/modules/network/junos/_junos_template.py
--- a/lib/ansible/modules/network/junos/_junos_template.py
+++ b/lib/ansible/modules/network/junos/_junos_template.py
@@ -87,8 +87,6 @@
     required: false
     default: null
     choices: ['text', 'xml', 'set']
-requirements:
-  - junos-eznc
 notes:
   - This module requires the netconf system service be enabled on
     the remote device being managed
diff --git a/lib/ansible/modules/network/junos/junos_command.py b/lib/ansible/modules/network/junos/junos_command.py
--- a/lib/ansible/modules/network/junos/junos_command.py
+++ b/lib/ansible/modules/network/junos/junos_command.py
@@ -102,6 +102,8 @@
     aliases: ['format', 'output']
     choices: ['text', 'json', 'xml']
     version_added: "2.3"
+requirements:
+  - jxmlease
 """
 
 EXAMPLES = """
diff --git a/lib/ansible/modules/network/junos/junos_config.py b/lib/ansible/modules/network/junos/junos_config.py
--- a/lib/ansible/modules/network/junos/junos_config.py
+++ b/lib/ansible/modules/network/junos/junos_config.py
@@ -137,8 +137,6 @@
     default: merge
     choices: ['merge', 'override', 'replace']
     version_added: "2.3"
-requirements:
-  - junos-eznc
 notes:
   - This module requires the netconf system service be enabled on
     the remote device being managed.


Test patch:
Repository: ansible/ansible

Issue:
AIX hardware facts fail on single core AIX5 series
<!---
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
module_utils/facts/hardware/aix.py

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
2.4.0

Also affects 2.1.0, 2.2.0, 2.3.0
```

##### CONFIGURATION
<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->

##### 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.
-->
Running from any supported Linux platform.   Managing AIX5 series

##### SUMMARY
AIX hardware facts fail when run on single core AIX5 (attribute smt_threads is not defined)

/usr/sbin/lsattr -El proc0 -a smt_threads
lsattr: 0514-528 The "smt_threads" attribute does not exist in the predefined
        device configuration database.

##### 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 all -m setup -i aix5boxname_redacted, -u root 
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
Should include hardware facts such as:
        "ansible_processor": "PowerPC_POWER4",
        "ansible_processor_count": 4,
        "ansible_memfree_mb": 5126,
        "ansible_memtotal_mb": 8192,



##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->
No hardware facts present.  facts/hardware/aix.py failing silently.   Facts redacted due to sensitive info (internal hostnames/ip addresses).

<!--- Paste verbatim command output between quotes below -->
```

```



Discussion:

Resolving patch:
diff --git a/lib/ansible/module_utils/facts/hardware/aix.py b/lib/ansible/module_utils/facts/hardware/aix.py
--- a/lib/ansible/module_utils/facts/hardware/aix.py
+++ b/lib/ansible/module_utils/facts/hardware/aix.py
@@ -74,9 +74,9 @@ def get_cpu_facts(self):
             cpu_facts['processor'] = data[1]
 
             rc, out, err = self.module.run_command("/usr/sbin/lsattr -El " + cpudev + " -a smt_threads")
-
-            data = out.split(' ')
-            cpu_facts['processor_cores'] = int(data[1])
+            if out:
+                data = out.split(' ')
+                cpu_facts['processor_cores'] = int(data[1])
 
         return cpu_facts
 


Test patch:
Repository: ansible/ansible

Issue:
Wrong ansible_os_family returned on Linux Mint
<!---
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 -->
module_utils

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.3.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, Feb 11 2017, 12:22:40) [GCC 6.3.1 20170109]
```

##### CONFIGURATION
<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->

##### 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.
-->
Linux Mint

##### SUMMARY
Ansible does not return the correct ansible_os_family when gathering facts on a Linux Mint host.
Linux Mint is derived from Ubuntu and ansible_os_family should therefore be set to 'Debian'.

##### 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 -->
```
ansible -m setup linux-mint-host
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
ansible_os_family set to 'Debian'

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->
ansible_os_family set to 'Linuxmint'

<!--- Paste verbatim command output between quotes below -->
```

```



Discussion:

Resolving patch:
diff --git a/lib/ansible/module_utils/facts/system/distribution.py b/lib/ansible/module_utils/facts/system/distribution.py
--- a/lib/ansible/module_utils/facts/system/distribution.py
+++ b/lib/ansible/module_utils/facts/system/distribution.py
@@ -393,7 +393,8 @@ class Distribution(object):
     OS_FAMILY_MAP = {'RedHat': ['RedHat', 'Fedora', 'CentOS', 'Scientific', 'SLC',
                                 'Ascendos', 'CloudLinux', 'PSBM', 'OracleLinux', 'OVS',
                                 'OEL', 'Amazon', 'Virtuozzo', 'XenServer'],
-                     'Debian': ['Debian', 'Ubuntu', 'Raspbian', 'Neon', 'KDE neon'],
+                     'Debian': ['Debian', 'Ubuntu', 'Raspbian', 'Neon', 'KDE neon',
+                                'Linux Mint'],
                      'Suse': ['SuSE', 'SLES', 'SLED', 'openSUSE', 'openSUSE Tumbleweed',
                               'SLES_SAP', 'SUSE_LINUX', 'openSUSE Leap'],
                      'Archlinux': ['Archlinux', 'Antergos', 'Manjaro'],


Test patch:
Repository: ansible/ansible

Issue:
dynamodb requires hash_key_name for state=absent
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
module `dynamodb_table`

##### ANSIBLE VERSION
```
$ ansible --version
ansible 2.2.1.0
  config file =
  configured module search path = Default w/o overrides
```

##### SUMMARY
`dynamodb_table` module documentation states that `hash_key_name`  option is mandatory only for `state=present` though it's required always in code

##### STEPS TO REPRODUCE
Trying to delete table from ad-hoc command fails:
```bash
$ ansible localhost -m dynamodb_table -a "name=service_name state=absent"
 [WARNING]: Host file not found: /etc/ansible/hosts
 [WARNING]: provided hosts list is empty, only localhost is available
localhost | FAILED! => {
    "changed": false, 
    "failed": true, 
    "msg": "missing required arguments: hash_key_name"
}
```

##### EXPECTED RESULTS
Table is deleted

##### ACTUAL RESULTS
Error is returned


Discussion:
cc @loia
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
@mente the website docs are usually for the devel version of ansible. Can you check the module args for your version via "ansible-doc dynamodb_table" ?

needs_info
Before posting i've checked github version and it has same problem. Doc of [module](https://github.com/ansible/ansible-modules-extras/blob/devel/cloud/amazon/dynamodb_table.py#L48) says it's not required. Guess it's coming from [main function](https://github.com/ansible/ansible-modules-extras/blob/devel/cloud/amazon/dynamodb_table.py#L389).

Nevertheless here's grepped ansible-doc from my machine:

```bash
- hash_key_name
        Name of the hash key.
        Required when `state=present'.
        [Default: None]
```

Resolving patch:
diff --git a/lib/ansible/modules/cloud/amazon/dynamodb_table.py b/lib/ansible/modules/cloud/amazon/dynamodb_table.py
--- a/lib/ansible/modules/cloud/amazon/dynamodb_table.py
+++ b/lib/ansible/modules/cloud/amazon/dynamodb_table.py
@@ -444,7 +444,7 @@ def main():
     argument_spec.update(dict(
         state=dict(default='present', choices=['present', 'absent']),
         name=dict(required=True, type='str'),
-        hash_key_name=dict(required=True, type='str'),
+        hash_key_name=dict(type='str'),
         hash_key_type=dict(default='STRING', type='str', choices=['STRING', 'NUMBER', 'BINARY']),
         range_key_name=dict(type='str'),
         range_key_type=dict(default='STRING', type='str', choices=['STRING', 'NUMBER', 'BINARY']),


Test patch:
Repository: ansible/ansible

Issue:
os_stack fails with AttributeError
##### ISSUE TYPE
Bug Report

##### COMPONENT NAME
os_stack module

##### ANSIBLE VERSION
```
ansible 2.2.1.0
  config file = 
  configured module search path = Default w/o overrides
```

##### CONFIGURATION
N/A

##### OS / ENVIRONMENT
N/A

##### SUMMARY
When the stack creation fails (`stack_status != 'CREATE_COMPLETE'`), the module raises an `AttributeError`.

##### STEPS TO REPRODUCE
1. Create a Heat template `template.yml` like so :
```yaml
# Simple Heat template which will fail quickly
heat_template_version: 2013-05-23
resources:
  wait_condition:
    type: OS::Heat::WaitCondition
    properties:
      handle: {get_resource: wait_handle}
      count: 1
      timeout: 5
  wait_handle:
    type: OS::Heat::WaitConditionHandle
```

2. Run `os_stack` module :
```bash
ansible -m os_stack -a 'name=failing_stack template=template.yml' localhost
```

##### EXPECTED RESULTS
The module should not raise an error in case of a failure. It should call `module.fail_json()` with a proper error message.

##### ACTUAL RESULTS
The module raises an `AttributeError` :
```
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'bool' object has no attribute 'id'
```

Full traceback :
```python
Traceback (most recent call last):
  File "/tmp/ansible_pfxIaX/ansible_module_os_stack.py", line 262, in <module>
    main()
  File "/tmp/ansible_pfxIaX/ansible_module_os_stack.py", line 247, in main
    id=stack.id)
AttributeError: 'bool' object has no attribute 'id'
```



Discussion:
cc @emonty @shrews @juliakreger @j2sol @rcarrillocruz @thingee
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
`CREATE_IN_PROGRESS` is also a problem as the following should be 

https://github.com/openstack-infra/shade/blob/master/shade/_normalize.py#L962

```
stack_status.split('_', 1)
```

but that fix then produces `AttributeError: 'bool' object has no attribute 'id'`
At least part of the problem is at https://github.com/ansible/ansible-modules-extras/blob/devel/cloud/openstack/os_stack.py#L174.
The function returns False, but it should fail the module, which never happens because the module.fail_json instruction is never executed.

Resolving patch:
diff --git a/lib/ansible/modules/cloud/openstack/os_stack.py b/lib/ansible/modules/cloud/openstack/os_stack.py
--- a/lib/ansible/modules/cloud/openstack/os_stack.py
+++ b/lib/ansible/modules/cloud/openstack/os_stack.py
@@ -182,7 +182,6 @@ def _create_stack(module, stack, cloud):
         if stack.stack_status == 'CREATE_COMPLETE':
             return stack
         else:
-            return False
             module.fail_json(msg="Failure in creating stack: {0}".format(stack))
     except shade.OpenStackCloudException as e:
         module.fail_json(msg=str(e))


Test patch:
Repository: ansible/ansible

Issue:
Extensions of variable files are not limited as they should be per documentation. Backup copies thus may take precedence over expected files
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME

initialization
##### ANSIBLE VERSION

```
ansible 2.1.2.0
  configured module search path = Default w/o overrides
```
##### CONFIGURATION

<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->
##### OS / ENVIRONMENT

Host: Ubuntu 14.01
Guest: Scientific Linux release 7.2 (Nitrogen)
##### SUMMARY

Variables loaded from ./group_vars/all/config.yml~ wins over ./group_vars/all/config.yml
According to [docs](http://docs.ansible.com/ansible/intro_inventory.html#splitting-out-host-and-group-specific-data) this should not be allowed: 

> ....Valid file extensions include ‘.yml’, ‘.yaml’, ‘.json’, or no file extension
> And by "include" it means included in a list and not should include a sub-string in an extension.
##### STEPS TO REPRODUCE
1. Create ./group_vars/all/config.yml file with simple content

```

---
varrr: proper_value
```
1. Copy file and concat with tilde at the end of the filename ./group_vars/all/config.yml~ 
   . Change content

```

---
varrr: incorrect_value
```
1. Run simple task to print variable

```
- name: Print varrr
  debug: var=varrr
```
##### EXPECTED RESULTS

Expected content from ./group_vars/all/config.yml
##### ACTUAL RESULTS

Got content from ./group_vars/all/config.yml~



Discussion:
Instead of just warning about this it would be nice to have a configurable pattern of files to exclude. This would make it possible to still have editor backup files.

I got bitten by this several time. I would really appreciate a fix.

Resolving patch:
diff --git a/lib/ansible/plugins/vars/host_group_vars.py b/lib/ansible/plugins/vars/host_group_vars.py
--- a/lib/ansible/plugins/vars/host_group_vars.py
+++ b/lib/ansible/plugins/vars/host_group_vars.py
@@ -23,6 +23,7 @@
     description:
         - Loads YAML vars into corresponding groups/hosts in group_vars/ and host_vars/ directories.
         - Files are restricted by extension to one of .yaml, .json, .yml or no extension.
+        - Hidden (starting with '.') and backup (ending with '~') files and directories are ignored.
         - Only applies to inventory sources that are existing paths.
     notes:
         - It takes the place of the previously hardcoded group_vars/host_vars loading.
@@ -121,7 +122,7 @@ def _get_dir_files(self, path):
 
         found = []
         for spath in os.listdir(path):
-            if not spath.startswith('.'):  # skip hidden
+            if not spath.startswith('.') and not spath.endswith('~'):  # skip hidden and backups
 
                 ext = os.path.splitext(spath)[-1]
                 full_spath = os.path.join(path, spath)


Test patch:
Repository: ansible/ansible

Issue:
eos deprecation warning on transport even when not used and when used in provider
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and master branch are affected too.
-->
##### SUMMARY

eos throws deprecation warning on transport even when the param is not used explicitly and when used in provider. 

This issue exists only for `2.3`.

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report


##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
module_utils/eos.py
##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
2.3
```

##### 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.
-->
```
---
- name: Config using the core module
  hosts: eoshost

  tasks:
    - name: Config Using Core Module
      eos_facts:
        authorize: yes
        gather_subset: all
      register: response
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
The playbook should run with no warning
##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->
Throws deprecation warning on transport.
<!--- Paste verbatim command output between quotes below -->
```
PLAY [Config using the core module] *******************************************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************************************************
ok: [eoshost]

TASK [Config Using Core Module] ***********************************************************************************************************************************************************************************
 [WARNING]: argument transport has been deprecated and will be removed in a future version

ok: [eoshost]

PLAY RECAP ********************************************************************************************************************************************************************************************************
eoshost                    : ok=2    changed=0    unreachable=0    failed=0   
```



Discussion:

Resolving patch:
diff --git a/lib/ansible/module_utils/eos.py b/lib/ansible/module_utils/eos.py
--- a/lib/ansible/module_utils/eos.py
+++ b/lib/ansible/module_utils/eos.py
@@ -54,11 +54,12 @@
     'timeout': dict(type='int'),
 
     'provider': dict(type='dict'),
-    'transport': dict(choices=['cli', 'eapi'], default='cli')
+    'transport': dict(choices=['cli', 'eapi'])
 }
 
 # Add argument's default value here
 ARGS_DEFAULT_VALUE = {
+    'transport': 'cli',
     'port': 443,
     'use_ssl': True,
     'validate_certs': True


Test patch:
Repository: ansible/ansible

Issue:
Add playbook duration in logstash callback stats
##### ISSUE TYPE
 - Feature Idea

##### COMPONENT NAME
lib/ansible/plugins/callback/logstash.py

##### 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.9 (default, Jun 29 2016, 13:08:31) [GCC 4.9.2]
```

##### CONFIGURATION
<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->
Simply enabled logstash callback:
```
callback_whitelist = logstash
```

##### SUMMARY
The  event sent to logstash does not contain the playbook runtime statistic.
The information seems pretty useful and should be added to allow fast statistic creation on playbook execution time.


##### EXPECTED RESULTS
A field in the logstash event that contains the paybook runtime duration.

##### ACTUAL RESULTS
We currently only have the timestamp associated to the ansible_type "finish". One would have to retrieve the timestamp of the playbook start time and compute the duration to be able to do stats on playbook duration.




Discussion:

Resolving patch:
diff --git a/lib/ansible/plugins/callback/logstash.py b/lib/ansible/plugins/callback/logstash.py
--- a/lib/ansible/plugins/callback/logstash.py
+++ b/lib/ansible/plugins/callback/logstash.py
@@ -22,6 +22,7 @@
 import json
 import socket
 import uuid
+from datetime import datetime
 
 import logging
 
@@ -86,6 +87,7 @@ def __init__(self):
             self.hostname = socket.gethostname()
             self.session = str(uuid.uuid1())
             self.errors = 0
+        self.start_time = datetime.utcnow()
 
     def v2_playbook_on_start(self, playbook):
         self.playbook = playbook._file_name
@@ -99,6 +101,8 @@ def v2_playbook_on_start(self, playbook):
         self.logger.info("ansible start", extra=data)
 
     def v2_playbook_on_stats(self, stats):
+        end_time = datetime.utcnow()
+        runtime = end_time - self.start_time
         summarize_stat = {}
         for host in stats.processed.keys():
             summarize_stat[host] = stats.summarize(host)
@@ -114,6 +118,7 @@ def v2_playbook_on_stats(self, stats):
             'session': self.session,
             'ansible_type': "finish",
             'ansible_playbook': self.playbook,
+            'ansible_playbook_duration': runtime.total_seconds(),
             'ansible_result': json.dumps(summarize_stat),
         }
         self.logger.info("ansible stats", extra=data)


Test patch: