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

Issue:
ansible-doc does not show option aliases


##### ISSUE TYPE


 - Documentation Report

##### COMPONENT NAME

apt

##### 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, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]

```

##### CONFIGURATION

no custom config

##### OS / ENVIRONMENT

Ubuntu, package from  http://ppa.launchpad.net/ansible/ansible/ubuntu xenial/main amd64 Packages

##### SUMMARY

Running `ansible-doc apt` makes use of `pkg` option in one of the example but never documents it.

##### STEPS TO REPRODUCE

Run `ansible-doc apt`, seek for `pkg` string in it

##### EXPECTED RESULTS

I expect to find what `pkg` option does (as seen in many places around).
Or, in `pkg` is not found (which would be my preference), it should not be used in examples

##### ACTUAL RESULTS

The `pkg` option is used in example but never mentioned before, so you cannot tell what it is about.


Discussion:
This seems to be a general issue for ansible-doc.
It doesn't display aliases for commands (it's the same for i.e. the homebrew module, and probably every other module as well). The code and doc pages online displays the aliases just fine.
Is there another repository for `ansible-doc` issues ?
Also, I noticed that `name` is also an alias, but `ansible-doc apt`
does show that as an option (maybe a different version).
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/packaging/os/apt.py#L806

As far as I can see, it's the same repository, I just wanted to clarify what the issue is :)

As for 'name' also being an alias, that seems to be correct, but 'package' is listed as an alias for 'name' in the documentation: https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/packaging/os/apt.py#L43, so the impact is minimal when 'name' is documented instead of 'package', though might be an idea to change it, but that's up to the devs.
cc @mgwilliams
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py
--- a/lib/ansible/cli/doc.py
+++ b/lib/ansible/cli/doc.py
@@ -312,11 +312,13 @@ def add_fields(self, text, fields, limit, opt_indent):
 
             aliases = ''
             if 'aliases' in opt:
-                choices = "(Aliases: " + ", ".join(str(i) for i in opt['aliases']) + ")"
+                if len(opt['aliases']) > 0:
+                    aliases = "(Aliases: " + ", ".join(str(i) for i in opt['aliases']) + ")"
                 del opt['aliases']
             choices = ''
             if 'choices' in opt:
-                choices = "(Choices: " + ", ".join(str(i) for i in opt['choices']) + ")"
+                if len(opt['choices']) > 0:
+                    choices = "(Choices: " + ", ".join(str(i) for i in opt['choices']) + ")"
                 del opt['choices']
             default = ''
             if 'default' in opt or not required:


Test patch:
Repository: ansible/ansible

Issue:
When creating a lambda, the dead_letter_arn module property is mapped incorrectly to the underlying AWS CLI property
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
modules/cloud/amazon/lambda.py

##### ANSIBLE VERSION
```
ansible 2.3.1.0
  config file = 
  configured module search path = Default w/o overrides
  python version = 2.7.10 (default, Feb  7 2017, 00:08:15) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]
```

##### 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.
Also mention the specific version of what you are trying to control,
e.g. if this is a network bug the version of firmware on the network device.
-->
Mac OS Sierra 10.12.6

##### SUMMARY
When creating a lambda, the dead_letter_arn module property is mapped incorrectly to the underlying AWS CLI property. I receive the following error message:

TASK [app-send-email-service : Uploading lambda zip files] **********************************************************************************************************************************************************************************************************
fatal: [aws_pdev]: FAILED! => {"changed": false, "failed": true, "msg": "Parameter validation failed:\nUnknown parameter in DeadLetterConfig: \"TargetARN\", must be one of: TargetArn"}
   
##### STEPS TO REPRODUCE
Within a role, use the 'lambda' module with the 'dead_letter_arn' property set :
- name: Uploading lambda zip files
  lambda:
    name: "my-send-email"
    ....
    dead_letter_arn: "{{ sqs.queue_arn }}"
 
When it attempts to create the lambda, then the above error message is displayed, when the lambda already exists then the lambda is successfully updated with the dead letter queue.

##### EXPECTED RESULTS
Lambda to be created with a dead letter queue.

##### ACTUAL RESULTS



Discussion:

Resolving patch:
diff --git a/lib/ansible/modules/cloud/amazon/lambda.py b/lib/ansible/modules/cloud/amazon/lambda.py
--- a/lib/ansible/modules/cloud/amazon/lambda.py
+++ b/lib/ansible/modules/cloud/amazon/lambda.py
@@ -464,7 +464,7 @@ def main():
             func_kwargs.update({'Environment': {'Variables': environment_variables}})
 
         if dead_letter_arn:
-            func_kwargs.update({'DeadLetterConfig': {'TargetARN': dead_letter_arn}})
+            func_kwargs.update({'DeadLetterConfig': {'TargetArn': dead_letter_arn}})
 
         # If VPC configuration is given
         if vpc_subnet_ids or vpc_security_group_ids:


Test patch:
Repository: ansible/ansible

Issue:
Documentation example in win_file module is misleading
##### ISSUE TYPE
 - Documentation Report

##### COMPONENT NAME
win_file

##### ANSIBLE VERSION
N/A

##### CONFIGURATION
N/A
##### OS / ENVIRONMENT
N/A

##### SUMMARY
The documentation of [win_file](https://docs.ansible.com/ansible/latest/win_file_module.html#id3) shows that to create a file you have to do the following:
```
- name: Create a file
  win_file:
    path: C:\Temp\foo.conf
    state: file
```
This does not work and it is clearly stated above in the Options section that it won't work:
> If file, the file will NOT be created if it does not exist, see the copy or template module if you want that behavior.

##### Proposed Fix
The example should be removed or changed to use `state: touch`



Discussion:
cc @jhawkesworth
[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_file.py b/lib/ansible/modules/windows/win_file.py
--- a/lib/ansible/modules/windows/win_file.py
+++ b/lib/ansible/modules/windows/win_file.py
@@ -59,11 +59,6 @@
 '''
 
 EXAMPLES = r'''
-- name: Create a file
-  win_file:
-    path: C:\Temp\foo.conf
-    state: file
-
 - name: Touch a file (creates if not present, updates modification time if present)
   win_file:
     path: C:\Temp\foo.conf


Test patch:
Repository: ansible/ansible

Issue:
ini_file doesn't match options with leading tab character
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
ini_file

##### ANSIBLE VERSION
ansible 2.3.1.0
  config file = 
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, March 13 2017, 20:56:15) [GCC 5.4.0]

##### CONFIGURATION
N/A

##### OS / ENVIRONMENT
Controller: Cygwin (yes, I know, not relevant to this bug)
Managed: CentOS

##### SUMMARY
ini_files doesn't match options with leading tabs.

##### STEPS TO REPRODUCE
CentOS 7 Samba 4.4.4-14.el7_3 installs a default /etc/samba/smb.conf with leading tabs for all options in each section.

The following task will add, not replace, the specified option:
```yaml
- ini_file:
    path: /etc/samba/smb.conf
    state: present
    section: global
    option: workgroup
    value: ANYTHING
```
##### EXPECTED RESULTS
Task should replace the line.

##### ACTUAL RESULTS
Option did not match, and a second workgroup option is added.

Sorry, output not available--host is on a closed network.



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

Resolving patch:
diff --git a/lib/ansible/modules/files/ini_file.py b/lib/ansible/modules/files/ini_file.py
--- a/lib/ansible/modules/files/ini_file.py
+++ b/lib/ansible/modules/files/ini_file.py
@@ -126,16 +126,16 @@
 
 def match_opt(option, line):
     option = re.escape(option)
-    return re.match(' *%s( |\t)*=' % option, line) \
-      or re.match('# *%s( |\t)*=' % option, line) \
-      or re.match('; *%s( |\t)*=' % option, line)
+    return re.match('( |\t)*%s( |\t)*=' % option, line) \
+      or re.match('#( |\t)*%s( |\t)*=' % option, line) \
+      or re.match(';( |\t)*%s( |\t)*=' % option, line)
 
 # ==============================================================
 # match_active_opt
 
 def match_active_opt(option, line):
     option = re.escape(option)
-    return re.match(' *%s( |\t)*=' % option, line)
+    return re.match('( |\t)*%s( |\t)*=' % option, line)
 
 # ==============================================================
 # do_ini


Test patch:
Repository: ansible/ansible

Issue:
amended s3 plugin to support 'dest' parameter
to allow uploading to custom location.

test.yml follows (though my debug step is incorrect or I don't know how to invoke it...):

```

---

- hosts: 127.0.0.1
  connection: local
  vars:
    projectZipName: build.tgz
    projEnv: dev
    bucketName: my_builds

  tasks:
    - name: Uploading artifact to s3
      action: s3 bucket={{bucketName}} path=build.tgz dest=custom/{{projEnv}}/{{projectZipName}} state=present overwrite=yes expiry=900
      register: downloadUrl
    - name: "{{downloadUrl}} created"
      action: debug msg="{{downloadUrl}} created"
```



Discussion:
in queue for review, thanks!

merged, thanks!


Resolving patch:
diff --git a/lib/ansible/plugins/action/eos.py b/lib/ansible/plugins/action/eos.py
--- a/lib/ansible/plugins/action/eos.py
+++ b/lib/ansible/plugins/action/eos.py
@@ -76,7 +76,7 @@ def run(self, tmp=None, task_vars=None):
             # make sure we are in the right cli context which should be
             # enable mode and not config module
             rc, out, err = connection.exec_command('prompt()')
-            while str(out).strip().endswith(')#'):
+            while '(config' in str(out):
                 display.vvvv('wrong context, sending exit to device', self._play_context.remote_addr)
                 connection.exec_command('exit')
                 rc, out, err = connection.exec_command('prompt()')


Test patch:
Repository: ansible/ansible

Issue:
nxos_interface should not traceback when encountering `fex-fabric`
<!---
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 -->
nxos_interface

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
2.4
```

##### SUMMARY
<!--- Explain the problem briefly -->
See #21442 for context. We do not want to handle fex-fabric directly in nxos_interface, but rather in a new module (#27592). That being said, nxos_interface should not traceback, but rather issue a readable error or warning. 


Discussion:
cc @GGabriele @jedelman8 @mikewiebe @privateip @rahushen @rcarrillocruz @trishnaguha
[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/network/nxos/nxos_interface.py b/lib/ansible/modules/network/nxos/nxos_interface.py
--- a/lib/ansible/modules/network/nxos/nxos_interface.py
+++ b/lib/ansible/modules/network/nxos/nxos_interface.py
@@ -279,6 +279,8 @@ def get_interface(intf, module):
 
     if body:
         interface_table = body['TABLE_interface']['ROW_interface']
+        if interface_table['eth_mode'] == 'fex-fabric':
+            module.fail_json(msg='nxos_interface does not support interfaces with mode "fex-fabric"')
         intf_type = get_interface_type(intf)
         if intf_type in ['portchannel', 'ethernet']:
             if not interface_table.get('eth_mode'):


Test patch:
Repository: ansible/ansible

Issue:
xml module: Add a backup option
##### ISSUE TYPE
 - Feature Idea

##### COMPONENT NAME
xml

##### ANSIBLE VERSION
v2.4

##### SUMMARY
Similar to the copy or template module, it would be nice to also have a backup option.

_Copied from original issue: cmprescott/ansible-xml#94_


Discussion:
cc @magnus919 @tbielawa
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
cc @cmprescott @sm4rk0
[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/files/xml.py b/lib/ansible/modules/files/xml.py
--- a/lib/ansible/modules/files/xml.py
+++ b/lib/ansible/modules/files/xml.py
@@ -91,6 +91,12 @@
     - Type of input for C(add_children) and C(set_children).
     choices: [ xml, yaml ]
     default: yaml
+  backup:
+    description:
+      - Create a backup file including the timestamp information so you can get
+        the original file back if you somehow clobbered it incorrectly.
+    type: bool
+    default: 'no'
 requirements:
 - lxml >= 2.3.0
 notes:
@@ -192,6 +198,11 @@
     type: dict
     returned: success
     sample: {xpath: xpath, namespaces: [namespace1, namespace2], state=present}
+backup_file:
+    description: The name of the backup file that was created
+    type: str
+    returned: when backup=yes
+    sample: /path/to/file.xml.1942.2017-08-24@14:16:01~
 count:
     description: The count of xpath matches.
     type: int
@@ -638,6 +649,9 @@ def finish(module, tree, xpath, namespaces, changed=False, msg="", hitcount=0, m
 
     if module.params['path']:
         if not module.check_mode:
+            if module.params['backup']:
+                result['backup_file'] = module.backup_local(module.params['path'])
+
             tree.write(module.params['path'], xml_declaration=True, encoding='UTF-8', pretty_print=module.params['pretty_print'])
 
     if module.params['xmlstring']:
@@ -662,7 +676,8 @@ def main():
             print_match=dict(type='bool', default=False),
             pretty_print=dict(type='bool', default=False),
             content=dict(type='str', choices=['attribute', 'text']),
-            input_type=dict(type='str', default='yaml', choices=['xml', 'yaml'])
+            input_type=dict(type='str', default='yaml', choices=['xml', 'yaml']),
+            backup=dict(type='bool', default=False),
         ),
         supports_check_mode=True,
         mutually_exclusive=[
@@ -690,6 +705,7 @@ def main():
     input_type = module.params['input_type']
     print_match = module.params['print_match']
     count = module.params['count']
+    backup = module.params['backup']
 
     # Check if we have lxml 2.3.0 or newer installed
     if not HAS_LXML:


Test patch:
Repository: ansible/ansible

Issue:
Unable to set up A record round robin with dnsmadeeasy
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
dnsmadeeasy

##### ANSIBLE VERSION
```
ansible 2.3.2.0
  config file =
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170118]

```

##### CONFIGURATION
Standard

##### OS / ENVIRONMENT
Running Ansible on Debian Stretch

##### SUMMARY
I'd like to set up a round robin configuration, as done in [this tutorial](http://help.dnsmadeeasy.com/managed-dns/records/round-robin/), using ansible and the dnsmadeeasy module.

##### STEPS TO REPRODUCE
If the variable `ips` is a list with two IP addresses

This first creates one record, then replaces it with the next record
```yaml
    - dnsmadeeasy:
        account_key: "{{dns_account_key}}"
        account_secret: "{{dns_account_secret}}"
        state: present
        domain: "{{domainname}}"
        record_name: ""
        record_type: A
        record_ttl: 60
        record_value: "{{item}}"
      with_items: "{{ips}}"
```

This gives a 400 error
```yaml
    - dnsmadeeasy:
        account_key: "{{dns_account_key}}"
        account_secret: "{{dns_account_secret}}"
        state: present
        domain: "{{domainname}}"
        record_name: ""
        record_type: A
        record_ttl: 60
        record_value: "{{ips}}"
```

##### EXPECTED RESULTS
I expected to end up with two A records for my domain, pointing to the two IPs.

##### ACTUAL RESULTS
I end up with one A record pointing to the last IP in the list.

Checking the code it looks to me like `A` and `AAAA` records should be checked in the same manner as `MX` records.
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/net_tools/dnsmadeeasy.py#L474


Discussion:
cc @briceburg
[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/net_tools/dnsmadeeasy.py b/lib/ansible/modules/net_tools/dnsmadeeasy.py
--- a/lib/ansible/modules/net_tools/dnsmadeeasy.py
+++ b/lib/ansible/modules/net_tools/dnsmadeeasy.py
@@ -471,12 +471,12 @@ def getMatchingRecord(self, record_name, record_type, record_value):
         if not self.all_records:
             self.all_records = self.getRecords()
 
-        if record_type in ["A", "AAAA", "CNAME", "ANAME", "HTTPRED", "PTR"]:
+        if record_type in ["CNAME", "ANAME", "HTTPRED", "PTR"]:
             for result in self.all_records:
                 if result['name'] == record_name and result['type'] == record_type:
                     return result
             return False
-        elif record_type in ["MX", "NS", "TXT", "SRV"]:
+        elif record_type in ["A", "AAAA", "MX", "NS", "TXT", "SRV"]:
             for result in self.all_records:
                 if record_type == "MX":
                     value = record_value.split(" ")[1]


Test patch:
Repository: ansible/ansible

Issue:
Host specific messages are not logged to file
Host specific messages are not logged to file due to this line which has no reason around and no way to workaround it: https://github.com/ansible/ansible/blob/498aea8acc2f9eb64228f505547ceedaae4f2687/lib/ansible/utils/display.py#L186

##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
core

##### ANSIBLE VERSION
```
2.4.0.0 (devel)
```

##### SUMMARY
Logging to file should not be crippled (missing information that appears in console). In fact many users may want to opposite: to log to file more than on the console.

##### STEPS TO REPRODUCE
Run any playbook with -vvv so the host massages will be generated

<!--- Paste example playbooks or commands between quotes below -->
```
ANSIBLE_STDOUT_CALLBACK=dense ANSIBLE_VERBOSITY=3 ANSIBLE_FORCE_COLOR=0 ANSIBLE_LOG_PATH={toxinidir}/out.log ansible-playbook sample-a.yml >stdout.log 2>stderr.log
```

##### EXPECTED RESULTS
Log file should contain all information that is on console.



Discussion:

Resolving patch:
diff --git a/lib/ansible/utils/display.py b/lib/ansible/utils/display.py
--- a/lib/ansible/utils/display.py
+++ b/lib/ansible/utils/display.py
@@ -183,7 +183,7 @@ def verbose(self, msg, host=None, caplevel=2):
             if host is None:
                 self.display(msg, color=C.COLOR_VERBOSE)
             else:
-                self.display("<%s> %s" % (host, msg), color=C.COLOR_VERBOSE, screen_only=True)
+                self.display("<%s> %s" % (host, msg), color=C.COLOR_VERBOSE)
 
     def deprecated(self, msg, version=None, removed=False):
         ''' used to print out a deprecation message.'''


Test patch:
Repository: ansible/ansible

Issue:
Add file name extension to temporary files for ansible-vault edit and create
##### ISSUE TYPE
 - Feature Idea

##### COMPONENT NAME
vault

##### ANSIBLE VERSION
```
ansible 2.2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```

##### CONFIGURATION
`-`

##### OS / ENVIRONMENT
Linux

##### SUMMARY
`ansible-vault edit` and `create` create a temporary file, decrypt the content into it and open an editor for editing it. The temporary file often has a completely random name like `/tmp/tmpWOteRO` without any file extension like `.yml`. Editors like vim don't recognize the syntax itself and so there are no syntax specific settings. It was better to create temporary files with the file name extension similar to the encrypted file (like `/tmp/tmpWOteRO.yml` for yaml files).

##### STEPS TO REPRODUCE
- `ansible-vault create test.yml`
- `ansible-vault edit test.yml`

##### EXPECTED RESULTS
- the temporary file should be like `/tmp/tmpDqiQGq.yml`

##### ACTUAL RESULTS
- the file name was `/tmp/tmpDqiQGq`


Discussion:

Resolving patch:
diff --git a/lib/ansible/parsing/vault/__init__.py b/lib/ansible/parsing/vault/__init__.py
--- a/lib/ansible/parsing/vault/__init__.py
+++ b/lib/ansible/parsing/vault/__init__.py
@@ -662,7 +662,8 @@ def _edit_file_helper(self, filename, secret,
                           existing_data=None, force_save=False, vault_id=None):
 
         # Create a tempfile
-        fd, tmp_path = tempfile.mkstemp()
+        root, ext = os.path.splitext(os.path.realpath(filename))
+        fd, tmp_path = tempfile.mkstemp(suffix=ext)
         os.close(fd)
 
         try:


Test patch:
Repository: ansible/ansible

Issue:
function get_vgs_facts deliver no output when a volumegroup is offline
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME

module: facts.py

##### ANSIBLE VERSION

```
ansible 2.3.0 (devel b598575213) last updated 2017/01/13 08:15:07 (GMT +200)
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
```

##### CONFIGURATION
default setting

##### OS / ENVIRONMENT
Ansible is running at RHEL 7.1 and it is managing AIX 7.1

##### SUMMARY
The function get_vgs_facts will not deliver any output when a volumegroup at the managed system is ofline. The command lsvg -p <vgname> can only run at online volume groups.

##### STEPS TO REPRODUCE

place a volumegroup offline and run 
```
ansible all -i inventory -m setup 
```
where the managed node with the offline vg is in the inventory file

This can be fixed by discovering only the online volume groups

line:
```
 cmd = "%s | %s %s -p" % (lsvg_path ,xargs_path,lsvg_path)
```
must be replaced with:
```
 cmd = "%s -o| %s %s -p" % (lsvg_path ,xargs_path,lsvg_path)
```





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
@@ -146,7 +146,7 @@ def get_vgs_facts(self):
         vgs_facts = {}
         lsvg_path = self.module.get_bin_path("lsvg")
         xargs_path = self.module.get_bin_path("xargs")
-        cmd = "%s | %s %s -p" % (lsvg_path, xargs_path, lsvg_path)
+        cmd = "%s -o | %s %s -p" % (lsvg_path, xargs_path, lsvg_path)
         if lsvg_path and xargs_path:
             rc, out, err = self.module.run_command(cmd, use_unsafe_shell=True)
             if rc == 0 and out:


Test patch: