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

Issue:
Fix string/binary encoding issue in pull.py
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
lib/ansible/cli/pull.py

##### ANSIBLE VERSION
Current

##### CONFIGURATION
Python 3

##### OS / ENVIRONMENT
Linux

##### SUMMARY
``` diff
-        elif self.options.ifchanged and '"changed": true' not in out:
+        elif self.options.ifchanged and b'"changed": true' not in out:
```

The value in out is always binary encoded, because it's returned that way from `run_cmd`.

##### STEPS TO REPRODUCE
Run ansible-pull

##### EXTRA
Replaces #36364 - I'm closing that PR, because that bot annoys the crap out of me.


Discussion:
Files identified in the description:
* [lib/ansible/cli/pull.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/pull.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 --->
+label affects_2.1
+label affects_2.2
+label affects_2.3
+label affects_2.4
+label affects_2.5

Yeah, no, not just 2.6.

Resolving patch:
diff --git a/lib/ansible/cli/pull.py b/lib/ansible/cli/pull.py
--- a/lib/ansible/cli/pull.py
+++ b/lib/ansible/cli/pull.py
@@ -30,7 +30,7 @@
 
 from ansible.cli import CLI
 from ansible.errors import AnsibleOptionsError
-from ansible.module_utils._text import to_native
+from ansible.module_utils._text import to_native, to_text
 from ansible.plugins.loader import module_loader
 from ansible.utils.cmd_functions import run_cmd
 
@@ -238,14 +238,14 @@ def run(self):
         # RUN the Checkout command
         display.debug("running ansible with VCS module to checkout repo")
         display.vvvv('EXEC: %s' % cmd)
-        rc, out, err = run_cmd(cmd, live=True)
+        rc, b_out, b_err = run_cmd(cmd, live=True)
 
         if rc != 0:
             if self.options.force:
                 display.warning("Unable to update repository. Continuing with (forced) run of playbook.")
             else:
                 return rc
-        elif self.options.ifchanged and '"changed": true' not in out:
+        elif self.options.ifchanged and b'"changed": true' not in b_out:
             display.display("Repository has not changed, quitting.")
             return 0
 
@@ -287,14 +287,14 @@ def run(self):
         # RUN THE PLAYBOOK COMMAND
         display.debug("running ansible-playbook to do actual work")
         display.debug('EXEC: %s' % cmd)
-        rc, out, err = run_cmd(cmd, live=True)
+        rc, b_out, b_err = run_cmd(cmd, live=True)
 
         if self.options.purge:
             os.chdir('/')
             try:
                 shutil.rmtree(self.options.dest)
             except Exception as e:
-                display.error("Failed to remove %s: %s" % (self.options.dest, str(e)))
+                display.error(u"Failed to remove %s: %s" % (self.options.dest, to_text(e)))
 
         return rc
 


Test patch:
Repository: ansible/ansible

Issue:
cloudstack: do not rely on APIs list queries for names
##### ISSUE TYPE
<!--- Pick one below and delete the rest -->
 - Bug 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
-->
cs_configuration
cloudstack

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes below -->
```
2.4, 2.5

```

##### CONFIGURATION
<!---
If using Ansible 2.4 or above, paste the results of "ansible-config dump --only-changed"
Otherwise, mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->
NA

##### 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.
-->
NA

##### SUMMARY
<!--- Explain the problem briefly -->
cloudstack may use %name% in query which may find more results as expected.

- Configurations (I was about to submit a fix)
- Counters
- PhysicalNetwork (PR #25647 should be affected)
- OsCategories

Also see #37783


Discussion:

Resolving patch:
diff --git a/lib/ansible/modules/cloud/cloudstack/cs_configuration.py b/lib/ansible/modules/cloud/cloudstack/cs_configuration.py
--- a/lib/ansible/modules/cloud/cloudstack/cs_configuration.py
+++ b/lib/ansible/modules/cloud/cloudstack/cs_configuration.py
@@ -219,7 +219,9 @@ def get_configuration(self):
         configurations = self.query_api('listConfigurations', **args)
         if not configurations:
             self.module.fail_json(msg="Configuration %s not found." % args['name'])
-        configuration = configurations['configuration'][0]
+        for config in configurations['configuration']:
+            if args['name'] == config['name']:
+                configuration = config
         return configuration
 
     def get_value(self):


Test patch:
Repository: ansible/ansible

Issue:
Ansible 2.5 Gathering Facts fails on some hosts
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
core

##### ANSIBLE VERSION
```
 2.5.0-1ppa~artful 
```

##### CONFIGURATION
-

##### OS / ENVIRONMENT
Ubuntu Linux 17.10

##### SUMMARY
Gathering the facts fails with the new Ansible version 2.5 on some hosts

##### EXPECTED RESULTS
The facts would be gathered correctly like with Ansible 2.3

##### ACTUAL RESULTS
```
TASK [Gathering Facts] **********************************************************************************************************************
fatal: [personalauswahl]: FAILED! => {"changed": false, "cmd": "None -s system-product-name", "msg": "[Errno 2] No such file or directory: 'None'", "rc": 2} 
```



Discussion:
@JanMalte Do those systems have 'dmidecode' installed?

The error makes me think 'dmidecode' is not installed  (and that the code using dmidecode should handle not having it better...)
@alikins Seems like it is/was not installed:
```
root@host ~ # dmidecode
-bash: dmidecode: command not found
```

Maybe ansible should throw a more verbose error message if the package is not installed.
See #34925 and #37850 

Resolving patch:
diff --git a/lib/ansible/module_utils/facts/virtual/linux.py b/lib/ansible/module_utils/facts/virtual/linux.py
--- a/lib/ansible/module_utils/facts/virtual/linux.py
+++ b/lib/ansible/module_utils/facts/virtual/linux.py
@@ -236,13 +236,15 @@ def get_virtual_facts(self):
         # In older Linux Kernel versions, /sys filesystem is not available
         # dmidecode is the safest option to parse virtualization related values
         dmi_bin = self.module.get_bin_path('dmidecode')
-        (rc, out, err) = self.module.run_command('%s -s system-product-name' % dmi_bin)
-        if rc == 0:
-            # Strip out commented lines (specific dmidecode output)
-            vendor_name = ''.join([line.strip() for line in out.splitlines() if not line.startswith('#')])
-            if vendor_name in ['VMware Virtual Platform', 'VMware7,1']:
-                virtual_facts['virtualization_type'] = 'VMware'
-                virtual_facts['virtualization_role'] = 'guest'
+        # We still want to continue even if dmidecode is not available
+        if dmi_bin is not None:
+            (rc, out, err) = self.module.run_command('%s -s system-product-name' % dmi_bin)
+            if rc == 0:
+                # Strip out commented lines (specific dmidecode output)
+                vendor_name = ''.join([line.strip() for line in out.splitlines() if not line.startswith('#')])
+                if vendor_name.startwith('VMware'):
+                    virtual_facts['virtualization_type'] = 'VMware'
+                    virtual_facts['virtualization_role'] = 'guest'
 
         # If none of the above matches, return 'NA' for virtualization_type
         # and virtualization_role. This allows for proper grouping.


Test patch:
Repository: ansible/ansible

Issue:
cloudstack: do not rely on APIs list queries for names
##### ISSUE TYPE
<!--- Pick one below and delete the rest -->
 - Bug 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
-->
cs_configuration
cloudstack

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes below -->
```
2.4, 2.5

```

##### CONFIGURATION
<!---
If using Ansible 2.4 or above, paste the results of "ansible-config dump --only-changed"
Otherwise, mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->
NA

##### 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.
-->
NA

##### SUMMARY
<!--- Explain the problem briefly -->
cloudstack may use %name% in query which may find more results as expected.

- Configurations (I was about to submit a fix)
- Counters
- PhysicalNetwork (PR #25647 should be affected)
- OsCategories

Also see #37783


Discussion:
Files identified in the description:
* [contrib/inventory/cloudstack.py](https://github.com/ansible/ansible/blob/devel/contrib/inventory/cloudstack.py)
* [lib/ansible/modules/cloud/cloudstack/cs_configuration.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/cloudstack/cs_configuration.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 @dpassante
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
!component contrib/inventory/cloudstack.py

Resolving patch:
diff --git a/lib/ansible/modules/cloud/cloudstack/cs_configuration.py b/lib/ansible/modules/cloud/cloudstack/cs_configuration.py
--- a/lib/ansible/modules/cloud/cloudstack/cs_configuration.py
+++ b/lib/ansible/modules/cloud/cloudstack/cs_configuration.py
@@ -228,7 +228,9 @@ def get_configuration(self):
         configurations = self.query_api('listConfigurations', **args)
         if not configurations:
             self.module.fail_json(msg="Configuration %s not found." % args['name'])
-        configuration = configurations['configuration'][0]
+        for config in configurations['configuration']:
+            if args['name'] == config['name']:
+                configuration = config
         return configuration
 
     def get_value(self):


Test patch:
Repository: ansible/ansible

Issue:
Remove edgeos modules from Ansible-Maintained list
##### ISSUE TYPE
 - Documentation Report

##### COMPONENT NAME
edgeos_config

##### ANSIBLE VERSION
2.5 and higher

##### SUMMARY
We've mistakenly included two `edgeos` modules in the list of Ansible-maintained network modules. We do not maintain those modules.



Discussion:
Files identified in the description:
None

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 --->
Will need cherry-picking into `stable-2.5` which is when these modules were added
Files identified in the description:
* [lib/ansible/modules/network/edgeos/edgeos_config.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/edgeos/edgeos_config.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 @qalthos @samdoran
[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/edgeos/edgeos_config.py b/lib/ansible/modules/network/edgeos/edgeos_config.py
--- a/lib/ansible/modules/network/edgeos/edgeos_config.py
+++ b/lib/ansible/modules/network/edgeos/edgeos_config.py
@@ -9,7 +9,7 @@
 
 ANSIBLE_METADATA = {'metadata_version': '1.1',
                     'status': ['preview'],
-                    'supported_by': 'network'}
+                    'supported_by': 'community'}
 
 DOCUMENTATION = """
 ---
diff --git a/lib/ansible/modules/network/edgeos/edgeos_facts.py b/lib/ansible/modules/network/edgeos/edgeos_facts.py
--- a/lib/ansible/modules/network/edgeos/edgeos_facts.py
+++ b/lib/ansible/modules/network/edgeos/edgeos_facts.py
@@ -9,7 +9,7 @@
 
 ANSIBLE_METADATA = {'metadata_version': '1.1',
                     'status': ['preview'],
-                    'supported_by': 'network'}
+                    'supported_by': 'community'}
 
 
 DOCUMENTATION = """


Test patch:
Repository: ansible/ansible

Issue:
ec2_instance: does not documents its example
##### ISSUE TYPE
 - Documentation Report

##### COMPONENT NAME
ec2_instance

##### SUMMARY
ec2_instance document describes ec2_instance_facts examples, but not describes ec2_instance examples.


Discussion:

Resolving patch:
diff --git a/lib/ansible/modules/cloud/amazon/ec2_instance.py b/lib/ansible/modules/cloud/amazon/ec2_instance.py
--- a/lib/ansible/modules/cloud/amazon/ec2_instance.py
+++ b/lib/ansible/modules/cloud/amazon/ec2_instance.py
@@ -162,26 +162,48 @@
 EXAMPLES = '''
 # Note: These examples do not set authentication details, see the AWS Guide for details.
 
-# Terminate every instance in a region. Use with caution.
-- ec2_instance_facts:
+# Terminate every running instance in a region. Use with EXTREME caution.
+- ec2_instance:
     state: absent
     filters:
       instance-state-name: running
 
-# Gather facts about all instances in AZ ap-southeast-2a
-- ec2_instance_facts:
-    filters:
-      availability-zone: ap-southeast-2a
-
-# Gather facts about a particular instance using ID
-- ec2_instance_facts:
+# restart a particular instance by its ID
+- ec2_instance:
+    state: restarted
     instance_ids:
       - i-12345678
 
-# Gather facts about any instance with a tag key Name and value Example
-- ec2_instance_facts:
-    filters:
-      "tag:Name": Example
+# start an instance with a public IP address
+- ec2_instance:
+    name: "public-compute-instance"
+    key_name: "prod-ssh-key"
+    vpc_subnet_id: subnet-5ca1ab1e
+    instance_type: c5.large
+    security_group: default
+    network:
+      assign_public_ip: true
+    image_id: ami-123456
+    tags:
+      Environment: Testing
+
+# start an instance and have it begin a Tower callback on boot
+- ec2_instance:
+    name: "tower-callback-test"
+    key_name: "prod-ssh-key"
+    vpc_subnet_id: subnet-5ca1ab1e
+    security_group: default
+    tower_callback:
+      # IP or hostname of tower server
+      tower_address: 1.2.3.4
+      job_template_id: 876
+      host_config_key: '[secret config key goes here]'
+    network:
+      assign_public_ip: true
+    image_id: ami-123456
+    cpu_credit_specification: unlimited
+    tags:
+      SomeThing: "A value"
 '''
 
 RETURN = '''


Test patch:
Repository: ansible/ansible

Issue:
cloudfront_distribution: Update valid minimum_protocol_versions 
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
cloudfront_distribution

##### ANSIBLE VERSION
```
ansible 2.5.0
...
  ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.14 (default, Mar 25 2018, 16:06:33) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]
```

##### OS / ENVIRONMENT
N/A

##### SUMMARY
AWS now supports 4 values for `minimum_protocol_version` (designated as "Security Policy" in the Cloudfront console):
* TLSv1
* TLSv1_2016
* TLSv1.1_2016
* TLSv1.2_2018

Ansible (as of 2.5.0) only allows:
* SSLv3
* TLSv1

AWS recommends the `TLSv1.1_2016` setting and some users may want to specify the `TLSv1.2_2018` setting.



Discussion:
Files identified in the description:
* [lib/ansible/modules/cloud/amazon/cloudfront_distribution.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/amazon/cloudfront_distribution.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 @willthames @wilvk
[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/cloudfront_distribution.py b/lib/ansible/modules/cloud/amazon/cloudfront_distribution.py
--- a/lib/ansible/modules/cloud/amazon/cloudfront_distribution.py
+++ b/lib/ansible/modules/cloud/amazon/cloudfront_distribution.py
@@ -1319,7 +1319,10 @@ def __init__(self, module):
         ])
         self.__valid_viewer_certificate_minimum_protocol_versions = set([
             'SSLv3',
-            'TLSv1'
+            'TLSv1',
+            'TLSv1_2016',
+            'TLSv1.1_2016',
+            'TLSv1.2_2018'
         ])
         self.__valid_viewer_certificate_certificate_sources = set([
             'cloudfront',


Test patch:
Repository: ansible/ansible

Issue:
cloudfront_distribution: Update valid minimum_protocol_versions 
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
cloudfront_distribution

##### ANSIBLE VERSION
```
ansible 2.5.0
...
  ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.14 (default, Mar 25 2018, 16:06:33) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]
```

##### OS / ENVIRONMENT
N/A

##### SUMMARY
AWS now supports 4 values for `minimum_protocol_version` (designated as "Security Policy" in the Cloudfront console):
* TLSv1
* TLSv1_2016
* TLSv1.1_2016
* TLSv1.2_2018

Ansible (as of 2.5.0) only allows:
* SSLv3
* TLSv1

AWS recommends the `TLSv1.1_2016` setting and some users may want to specify the `TLSv1.2_2018` setting.



Discussion:
Files identified in the description:
* [lib/ansible/modules/cloud/amazon/cloudfront_distribution.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/amazon/cloudfront_distribution.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 @willthames @wilvk
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Can you test #38644 to see if it fixes the issue?
@willthames #38644 checks OK. Thanks!

Resolving patch:
diff --git a/lib/ansible/modules/cloud/amazon/cloudfront_distribution.py b/lib/ansible/modules/cloud/amazon/cloudfront_distribution.py
--- a/lib/ansible/modules/cloud/amazon/cloudfront_distribution.py
+++ b/lib/ansible/modules/cloud/amazon/cloudfront_distribution.py
@@ -1319,7 +1319,10 @@ def __init__(self, module):
         ])
         self.__valid_viewer_certificate_minimum_protocol_versions = set([
             'SSLv3',
-            'TLSv1'
+            'TLSv1',
+            'TLSv1_2016',
+            'TLSv1.1_2016',
+            'TLSv1.2_2018'
         ])
         self.__valid_viewer_certificate_certificate_sources = set([
             'cloudfront',


Test patch:
Repository: ansible/ansible

Issue:
include_role module docs list 'None' as default for `private` parameter

##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME

include_role

##### ANSIBLE VERSION
```
ansible 2.2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```

(also devel)

##### CONFIGURATION

##### OS / ENVIRONMENT

CentOS 7, Fedora

##### SUMMARY

include_role takes a `private` parameter, described as:
"If True the variables from defaults/ and vars/ in a role will not be made available to the rest of the play."

module docs list the default as 'None', which is ambiguous. Presumably the default is actually one of 'True' or 'False'.

##### STEPS TO REPRODUCE

1. look at docs.




Discussion:
Not sure what the docs should say here. The 'default=None" kind of matches lib/ansible/playbook/role_include.py.IncludeRole's _private attribute 

```
_private = FieldAttribute(isa='bool', default=None, private=True)
```

Resolving patch:
diff --git a/lib/ansible/modules/utilities/logic/import_role.py b/lib/ansible/modules/utilities/logic/import_role.py
--- a/lib/ansible/modules/utilities/logic/import_role.py
+++ b/lib/ansible/modules/utilities/logic/import_role.py
@@ -53,6 +53,7 @@
       - If C(yes) the variables from C(defaults/) and C(vars/) in a role will not be made available to the rest of the
         play.
     type: bool
+    default: 'no'
 notes:
   - Handlers are made available to the whole play.
 '''
diff --git a/lib/ansible/modules/utilities/logic/include_role.py b/lib/ansible/modules/utilities/logic/include_role.py
--- a/lib/ansible/modules/utilities/logic/include_role.py
+++ b/lib/ansible/modules/utilities/logic/include_role.py
@@ -52,6 +52,7 @@
       - If C(yes) the variables from C(defaults/) and C(vars/) in a role will not be made available to the rest of the
         play.
     type: bool
+    default: 'no'
 notes:
   - Handlers are made available to the whole play.
   - Before Ansible 2.4, as with C(include), this task could be static or dynamic, If static, it implied that it won't


Test patch: