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

Issue:
ASG rolling update ignores lifecycle hooks
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
ec2_asg

##### ANSIBLE VERSION
```
ansible 2.4.3.0
```

##### CONFIGURATION

##### OS / ENVIRONMENT
N/A

##### SUMMARY
When replacing instances, ASG lifecycle hooks are ignored.
The consequence is that it moves on to the next replacement before the hooks are completed.
It's more evident when the lifecycle hooks take a significant time to complete.


##### STEPS TO REPRODUCE
1. Create an ASG with a lifecycle hooks that take few minutes to complete
2. Update the launch configuration
3. Run a rolling deployment
```yaml
- name: Update launch configuration
  ec2_asg:
    name: test_asg
    launch_config_name: new_test_asg_lc
    desired_capacity: 10
    min_size: 3
    max_size: 20
    wait_for_instances: yes
    replace_all_instances: yes
    replace_batch_size: 2
```

##### EXPECTED RESULTS
There are no more than 2 instances at any time in any of these states:
- Terminating
- Terminating:Wait
- Terminating:Proceed

##### ACTUAL RESULTS
As soon as the instances are in Terminating:Wait module move on to the next batch.
More than 2 instances are in Terminating:Wait or Terminating:Proceed state.



Discussion:
Files identified in the description:
* [lib/ansible/modules/cloud/amazon/ec2_asg.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/amazon/ec2_asg.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @garethr @ryansb @s-hertel @willthames
[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_asg.py b/lib/ansible/modules/cloud/amazon/ec2_asg.py
--- a/lib/ansible/modules/cloud/amazon/ec2_asg.py
+++ b/lib/ansible/modules/cloud/amazon/ec2_asg.py
@@ -1344,7 +1344,7 @@ def wait_for_term_inst(connection, term_instances):
             lifecycle = instance_facts[i]['lifecycle_state']
             health = instance_facts[i]['health_status']
             module.debug("Instance %s has state of %s,%s" % (i, lifecycle, health))
-            if lifecycle == 'Terminating' or health == 'Unhealthy':
+            if lifecycle.startswith('Terminating') or health == 'Unhealthy':
                 count += 1
         time.sleep(10)
 


Test patch:
Repository: ansible/ansible

Issue:
Add checksum check to unarchive module [feature_request]
##### ISSUE TYPE
 - Feature Idea

##### COMPONENT NAME
`unarchive` module

##### ANSIBLE VERSION
```
ansible 2.2.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides

```

##### SUMMARY

Very common usage scenario is: download file, download checksum file, check and then unpack. I suppose adding this variables:

`md5 = 47c7....` - for directly specified checksum
`md5src = https://example.com/example.zip.md5` - for checksum in file, local or downloaded
`md5src_raw = https://example.com/example.zip.md5` - for checksum in file, but not in `md5sum` format, just plain checksum. Sometimes checksum is stored that way.

Similar varibales should be created for `sha1`, `sha256`, ...



Discussion:
probably better as a  `checksum=` and `checksum_type=md5(default)|sha1|etc` to keep from having a ton of options and still have full functionality. 

checksum does not need to pull from uri as `lookup('uri', 'https://example.com/example.zip.md5')` can take care of that.

Good idea. And it should automatically detect, if checksum is saved plain or in `md5sum` output format: `3a866116f2dea3d5fa82dfce31316a3a  example.zip`

I'd like to see this as well.

Format should IMHO be the same as for `get_url`: `<algorithm>:<checksum>`
Alright, this is yet another feature request for the download part of **unarchive**. And we are of the opinion that having the **unarchive** module also download files was an historical mistake. Because we got dozen of requests for the download-part, things that **get_url** or **uri** already support. (authentication, certificates, proxy-support, and what not).

As the maintainer I am not inclined to make the module even more complex for the downloading-part. We cannot remove it because people may be using it, but if you desire additional functionality, maybe it is time to consider using **get_url** or **uri** instead.
@dagwieers Would it make sense to treat this as a documentation change for unarchive to discourage use of URLs? 
@acdha Please ! :-) Pull requests are welcome.
cc @pileofrogs
[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/unarchive.py b/lib/ansible/modules/files/unarchive.py
--- a/lib/ansible/modules/files/unarchive.py
+++ b/lib/ansible/modules/files/unarchive.py
@@ -26,6 +26,7 @@
      - By default, it will copy the source file from the local system to the target before unpacking.
      - Set C(remote_src=yes) to unpack an archive which already exists on the target.
      - For Windows targets, use the M(win_unzip) module instead.
+     - If checksum validation is desired, use M(get_url) or M(uri) instead to fetch the file and set C(remote_src=yes).
 options:
   src:
     description:


Test patch:
Repository: ansible/ansible

Issue:
Generating plugin documentation sometimes misses automatic aliases due to file order
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
docs/bin/plugin_formatter.py

##### ANSIBLE VERSION
```
2.6.0
```

##### SUMMARY
One pattern for module renames is to rename the module and create a symlink from the old name (prefixed with `_` to indicate deprecation) to the new name. This is handled in https://github.com/ansible/ansible/blob/devel/docs/bin/plugin_formatter.py#L213-L216 on the documentation generation side. Unfortuntaley, in case the symlink is processed **before** the real module is processed, the `module_info` entry is overwritten by https://github.com/ansible/ansible/blob/devel/docs/bin/plugin_formatter.py#L251-L261 and the determined value of `aliases` is lost.

This can probably fixed by changing https://github.com/ansible/ansible/blob/devel/docs/bin/plugin_formatter.py#L254 to `'aliases': module_info[module].get('aliases', set()),`.

That this bug occurs can be seen at https://docs.ansible.com/ansible/devel/modules/acme_certificate_module.html, where the alias `letsencrypt` is not mentioned. If I reverse the order the files are processed in, the alias data is added to the generated documentation.



Discussion:
Files identified in the description:
* [docs/bin/plugin_formatter.py](https://github.com/ansible/ansible/blob/devel/docs/bin/plugin_formatter.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
@webknjaz can you take a look here as well? I can create a PR if you think this is a good solution.
@dagwieers Since you're around right now, maybe you want to take a look at this as well :)
@felixfontein Makes sense. I'd say make that PR !

Resolving patch:
diff --git a/docs/bin/plugin_formatter.py b/docs/bin/plugin_formatter.py
--- a/docs/bin/plugin_formatter.py
+++ b/docs/bin/plugin_formatter.py
@@ -251,7 +251,7 @@ def get_plugin_info(module_dir, limit_to=None, verbose=False):
         module_info[module] = {'path': module_path,
                                'source': os.path.relpath(module_path, module_dir),
                                'deprecated': deprecated,
-                               'aliases': set(),
+                               'aliases': module_info[module].get('aliases', set()),
                                'metadata': metadata,
                                'doc': doc,
                                'examples': examples,


Test patch:
Repository: ansible/ansible

Issue:
jenkins_plugin: Module always updates installed plugins
##### ISSUE TYPE
 - Bug report

##### COMPONENT NAME
jenkins_plugin

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.2.2.0
```

##### OS / ENVIRONMENT
N/A

##### SUMMARY
When `state` is set to `present` and `version` is not specified, the `install( )` method will always add 'latest' to download URL and update if older version is installed.

##### STEPS TO REPRODUCE
Code in question:

```
if self.params['version'] in [None, 'latest']:
    # Take latest version
    plugin_url = (
        "%s/latest/%s.hpi" % (
            self.params['updates_url'],
            self.params['name']))
```

##### EXPECTED RESULTS
When `state` is `present` and no `version` is defined, I would expect any installed version to stay as is.


Discussion:
cc @jtyr
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Thanks for reporting this, @alexanderteves. I'm working on a fix.

Resolving patch:
diff --git a/lib/ansible/modules/web_infrastructure/jenkins_plugin.py b/lib/ansible/modules/web_infrastructure/jenkins_plugin.py
--- a/lib/ansible/modules/web_infrastructure/jenkins_plugin.py
+++ b/lib/ansible/modules/web_infrastructure/jenkins_plugin.py
@@ -261,7 +261,7 @@
     sample: "present"
 '''
 
-from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.basic import AnsibleModule, to_bytes
 from ansible.module_utils.six.moves.urllib.parse import urlencode
 from ansible.module_utils.urls import fetch_url, url_argument_spec
 from ansible.module_utils._text import to_native
@@ -491,7 +491,7 @@ def install(self):
                 sha1sum_old = base64.b64encode(sha1_old.digest())
 
                 # If the latest version changed, download it
-                if sha1sum_old != plugin_data['sha1']:
+                if sha1sum_old != to_bytes(plugin_data['sha1']):
                     if not self.module.check_mode:
                         r = self._download_plugin(plugin_url)
                         self._write_file(plugin_file, r)


Test patch:
Repository: ansible/ansible

Issue:
Ansible should allow extra vars from "non-file" paths
##### ISSUE TYPE
 - Feature Idea (moved from <https://github.com/ansible/proposals/issues/116>)

##### COMPONENT NAME
dataloader

##### ANSIBLE VERSION
```
2.6.0
```

##### OS / ENVIRONMENT
N/A

##### SUMMARY

Under ansible 1, we were able to use bash process substitution to decrypt our secrets and pass them into ansible, however this no longer works in ansible 2.

##### STEPS TO REPRODUCE

Under ansible 1, we were able to use bash process substitution [http://tldp.org/LDP/abs/html/process-sub.html] to decrypt our secrets and pass them into ansible, approximately as follows:

```
ansible-playbook -e @<(command-to-decrypt-secrets-to-stdout)
```

##### EXPECTED RESULTS

Should accept any valid file descriptor on the command line.

##### ACTUAL RESULTS

```
ERROR! Unable to retrieve file contents
Could not find or access '/dev/fd/63'
```

Ansible 2 refuses to recognise the file descriptor that bash has created as a valid pseudo-file from which to read extra variables.

Our current workaround uses temporary files, which is less secure.


Discussion:
Files identified in the description:
* [lib/ansible/parsing/dataloader.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/parsing/dataloader.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

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

Resolving patch:
diff --git a/lib/ansible/parsing/dataloader.py b/lib/ansible/parsing/dataloader.py
--- a/lib/ansible/parsing/dataloader.py
+++ b/lib/ansible/parsing/dataloader.py
@@ -148,21 +148,20 @@ def _get_file_contents(self, file_name):
         :return: Returns a byte string of the file contents
         '''
         if not file_name or not isinstance(file_name, (binary_type, text_type)):
-            raise AnsibleParserError("Invalid filename: '%s'" % str(file_name))
+            raise AnsibleParserError("Invalid filename: '%s'" % to_native(file_name))
 
         b_file_name = to_bytes(self.path_dwim(file_name))
         # This is what we really want but have to fix unittests to make it pass
         # if not os.path.exists(b_file_name) or not os.path.isfile(b_file_name):
-        if not self.path_exists(b_file_name) or not self.is_file(b_file_name):
+        if not self.path_exists(b_file_name):
             raise AnsibleFileNotFound("Unable to retrieve file contents", file_name=file_name)
 
         try:
             with open(b_file_name, 'rb') as f:
                 data = f.read()
                 return self._decrypt_if_vault_data(data, b_file_name)
-
         except (IOError, OSError) as e:
-            raise AnsibleParserError("an error occurred while trying to read the file '%s': %s" % (file_name, str(e)), orig_exc=e)
+            raise AnsibleParserError("an error occurred while trying to read the file '%s': %s" % (file_name, to_native(e)), orig_exc=e)
 
     def get_basedir(self):
         ''' returns the current basedir '''


Test patch:
Repository: ansible/ansible

Issue:
jenkins_plugin: Module always updates installed plugins
##### ISSUE TYPE
 - Bug report

##### COMPONENT NAME
jenkins_plugin

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.2.2.0
```

##### OS / ENVIRONMENT
N/A

##### SUMMARY
When `state` is set to `present` and `version` is not specified, the `install( )` method will always add 'latest' to download URL and update if older version is installed.

##### STEPS TO REPRODUCE
Code in question:

```
if self.params['version'] in [None, 'latest']:
    # Take latest version
    plugin_url = (
        "%s/latest/%s.hpi" % (
            self.params['updates_url'],
            self.params['name']))
```

##### EXPECTED RESULTS
When `state` is `present` and no `version` is defined, I would expect any installed version to stay as is.


Discussion:
cc @jtyr
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Thanks for reporting this, @alexanderteves. I'm working on a fix.

Resolving patch:
diff --git a/lib/ansible/modules/web_infrastructure/jenkins_plugin.py b/lib/ansible/modules/web_infrastructure/jenkins_plugin.py
--- a/lib/ansible/modules/web_infrastructure/jenkins_plugin.py
+++ b/lib/ansible/modules/web_infrastructure/jenkins_plugin.py
@@ -275,7 +275,7 @@
     sample: "present"
 '''
 
-from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.basic import AnsibleModule, to_bytes
 from ansible.module_utils.six.moves.urllib.parse import urlencode
 from ansible.module_utils.urls import fetch_url, url_argument_spec
 from ansible.module_utils._text import to_native
@@ -505,7 +505,7 @@ def install(self):
                 sha1sum_old = base64.b64encode(sha1_old.digest())
 
                 # If the latest version changed, download it
-                if sha1sum_old != plugin_data['sha1']:
+                if sha1sum_old != to_bytes(plugin_data['sha1']):
                     if not self.module.check_mode:
                         r = self._download_plugin(plugin_url)
                         self._write_file(plugin_file, r)


Test patch:
Repository: ansible/ansible

Issue:
aws_s3 is automaticly decrypting ansible-vault encrypted files before put
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and devel branch are affected too.
Always add information AFTER of these html comments. -->

##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
aws_s3

##### ANSIBLE VERSION
<!--- Paste, BELOW THIS COMMENT, verbatim output from "ansible --version" between quotes below -->
```
2.5.1
```

##### SUMMARY
- I'm trying to upload an ansible-vault encrypted file with aws_s3. But aws_s3 decrypts the src: file before uploading it to S3. 
- aws_s3 in 2.4 didn't decrypt the src: parameter.
- The documentation for aws_s3 doesn't mention that the src: parameter is autodecrypted.
- The aws_s3 module doesn't accept the decrypt: argument.

##### STEPS TO REPRODUCE
<!--- Paste example playbooks or commands between quotes below -->
```yaml
- name: upload vault to s3
  aws_s3:
    bucket: "the bucket"
    object: "file.txt"
    src: "file.txt"
    mode: put
```
1. The file.txt is encrypted with ansible-vault. 
2. The playbook that runs this task is invoked with --vault-password and is able to decrypt the file because other tasks need the file decrypted.

##### EXPECTED RESULTS
Don't autodecrypt the src: argument or be able to specify decrypt: no.

##### ACTUAL RESULTS
The src: argument to aws_s3 is automagicly decrypted without documentation or a way to disable the feature like other modules (ex. copy).



Discussion:
Files identified in the description:
* [lib/ansible/modules/cloud/amazon/aws_s3.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/amazon/aws_s3.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

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

Resolving patch:
diff --git a/lib/ansible/plugins/action/aws_s3.py b/lib/ansible/plugins/action/aws_s3.py
--- a/lib/ansible/plugins/action/aws_s3.py
+++ b/lib/ansible/plugins/action/aws_s3.py
@@ -47,7 +47,7 @@ def run(self, tmp=None, task_vars=None):
                 # For backward compatibility check if the file exists on the remote; it should take precedence
                 if not self._remote_file_exists(source):
                     try:
-                        source = self._loader.get_real_file(self._find_needle('files', source))
+                        source = self._loader.get_real_file(self._find_needle('files', source), decrypt=False)
                         new_module_args['src'] = source
                     except AnsibleFileNotFound as e:
                         # module handles error message for nonexistent files


Test patch:
Repository: ansible/ansible

Issue:
Fix the typos in winrm ports
<!---
Verify first that your issue/request is not already reported on GitHub.
THIS FORM WILL BE READ BY A MACHINE, COMPLETE ALL SECTIONS AS DESCRIBED.
Also test if the latest release, and devel branch are affected too.
ALWAYS add information AFTER (OUTSIDE) these html comments.
Otherwise it may end up being automatically closed by our bot. -->

##### SUMMARY
Winrm docs has a typo for https and http port. It says following

~~~
The default is the https (5896) port, if using http it should be 5895
~~~
Should be:

~~~
The default is the https (5986) port, if using http it should be 5985
~~~

##### ISSUE TYPE
 - Documentation Report

##### COMPONENT NAME
<!--- Insert, BELOW THIS COMMENT, the name of the module, plugin, task or feature.
Do not include extra details here, e.g. "vyos_command" not "the network module vyos_command" or the 
full path-->
winrm.py

##### ANSIBLE VERSION
<!--- Paste, BELOW THIS COMMENT, verbatim output from "ansible --version" between quotes below -->
```
Ansible 2.5
```




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
@@ -37,7 +37,7 @@
       port:
         description:
             - port for winrm to connect on remote target
-            - The default is the https (5896) port, if using http it should be 5895
+            - The default is the https (5986) port, if using http it should be 5985
         vars:
           - name: ansible_port
           - name: ansible_winrm_port


Test patch:
Repository: ansible/ansible

Issue:
create ansible.github.com



Discussion:
done


Resolving patch:
diff --git a/lib/ansible/modules/network/vyos/vyos_vlan.py b/lib/ansible/modules/network/vyos/vyos_vlan.py
--- a/lib/ansible/modules/network/vyos/vyos_vlan.py
+++ b/lib/ansible/modules/network/vyos/vyos_vlan.py
@@ -185,6 +185,10 @@ def map_params_to_obj(module):
                     item[key] = module.params[key]
 
             d = item.copy()
+
+            if not d['vlan_id']:
+                module.fail_json(msg='vlan_id is required')
+
             d['vlan_id'] = str(d['vlan_id'])
             module._check_required_one_of(module.required_one_of, item)
 
@@ -269,7 +273,7 @@ def main():
     """ main entry point for module execution
     """
     element_spec = dict(
-        vlan_id=dict(type='int', required=True),
+        vlan_id=dict(type='int'),
         name=dict(),
         address=dict(),
         interfaces=dict(type='list'),
@@ -293,7 +297,7 @@ def main():
     argument_spec.update(vyos_argument_spec)
 
     required_one_of = [['vlan_id', 'aggregate'],
-                       ['interfaces', 'associated_interfaces']]
+                       ['aggregate', 'interfaces', 'associated_interfaces']]
 
     mutually_exclusive = [['vlan_id', 'aggregate']]
     module = AnsibleModule(argument_spec=argument_spec,


Test patch:
diff --git a/test/integration/targets/vyos_vlan/tests/cli/basic.yaml b/test/integration/targets/vyos_vlan/tests/cli/basic.yaml
--- a/test/integration/targets/vyos_vlan/tests/cli/basic.yaml
+++ b/test/integration/targets/vyos_vlan/tests/cli/basic.yaml
@@ -7,6 +7,8 @@
       - delete interfaces ethernet eth1 vif 100
       - delete interfaces ethernet eth0 vif 5
       - delete interfaces ethernet eth0 vif 100
+      - delete interfaces ethernet eth0 vif 101
+      - delete interfaces ethernet eth1 vif 201
 
 - name: set vlan with name
   vyos_vlan: &name
@@ -68,8 +70,32 @@
     that:
       - "result.changed == false"
 
+- name: Create VLANs using aggregate
+  vyos_vlan: &agg_vlan
+    aggregate:
+      - { vlan_id: 101, name: voice, interfaces: "eth0" }
+      - { vlan_id: 201, name: mgm, interfaces: "eth1" }
+    state: present
+  register: result
+
+- assert:
+    that:
+      - "result.changed == true"
+      - "'set interfaces ethernet eth0 vif 101 description voice' in result.commands"
+      - "'set interfaces ethernet eth1 vif 201 description mgm' in result.commands"
+
+- name: Create VLANs using aggregate (idempotent)
+  vyos_vlan: *agg_vlan
+  register: result
+
+- assert:
+    that:
+      - "result.changed == false"
+
 - name: teardown
   vyos_config:
     lines:
       - delete interfaces ethernet eth1 vif 100
       - delete interfaces ethernet eth0 vif 5
+      - delete interfaces ethernet eth0 vif 101
+      - delete interfaces ethernet eth1 vif 201