Repository: ansible/ansible

Issue:
ecs_service_facts failed with python3
<!---
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 or feature
Do not include extra details here, e.g. "vyos_command" not "the network module vyos_command" or the full path
-->
- Python 3.5.2
- boto 2.48.0
- boto3 1.5.19
- botocore 1.8.33

- module: ecs_service_facts 

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes below -->
```
ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Nov 20 2017, 18:23:56) [GCC 5.4.0 20160609]
```

##### 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.
-->
ubuntu 16.04

##### SUMMARY
<!--- Explain the problem briefly -->

Module can`t get detail info. if use "ansible_python_interpreter: '/usr/bin/python3' ", module ecs_service_facts failed. But with python 2.7.12 no problem.


##### 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: get cluster service details
    ecs_service_facts:
      region: "us-east-1"
      cluster: "my-cluster"
      service: "my-service"
      details: true
    register: service_facts
    ignore_errors: yes
```

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

fatal: [localhost]: FAILED! => {
    "changed": false, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_tse6m3il/ansible_module_ecs_service_facts.py\", line 234, in <module>\n    main()\n  File \"/tmp/ansible_tse6m3il/ansible_module_ecs_service_facts.py\", line 230, in main\n    module.exit_json(**ecs_facts_result)\n  File \"/tmp/ansible_tse6m3il/ansible_modlib.zip/ansible/module_utils/basic.py\", line 2279, in exit_json\n  File \"/tmp/ansible_tse6m3il/ansible_modlib.zip/ansible/module_utils/basic.py\", line 2272, in _return_formatted\n  File \"/tmp/ansible_tse6m3il/ansible_modlib.zip/ansible/module_utils/basic.py\", line 514, in remove_values\n  File \"/tmp/ansible_tse6m3il/ansible_modlib.zip/ansible/module_utils/basic.py\", line 497, in _remove_values_conditions\nTypeError: Value of unknown type: <class 'map'>, <map object at 0x7fe2757557b8>\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}
<!--- Paste verbatim command output between quotes below -->
```

```

ecs_service_facts failed with python3
<!---
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 or feature
Do not include extra details here, e.g. "vyos_command" not "the network module vyos_command" or the full path
-->
- Python 3.5.2
- boto 2.48.0
- boto3 1.5.19
- botocore 1.8.33

- module: ecs_service_facts 

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes below -->
```
ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Nov 20 2017, 18:23:56) [GCC 5.4.0 20160609]
```

##### 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.
-->
ubuntu 16.04

##### SUMMARY
<!--- Explain the problem briefly -->

Module can`t get detail info. if use "ansible_python_interpreter: '/usr/bin/python3' ", module ecs_service_facts failed. But with python 2.7.12 no problem.


##### 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: get cluster service details
    ecs_service_facts:
      region: "us-east-1"
      cluster: "my-cluster"
      service: "my-service"
      details: true
    register: service_facts
    ignore_errors: yes
```

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

fatal: [localhost]: FAILED! => {
    "changed": false, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_tse6m3il/ansible_module_ecs_service_facts.py\", line 234, in <module>\n    main()\n  File \"/tmp/ansible_tse6m3il/ansible_module_ecs_service_facts.py\", line 230, in main\n    module.exit_json(**ecs_facts_result)\n  File \"/tmp/ansible_tse6m3il/ansible_modlib.zip/ansible/module_utils/basic.py\", line 2279, in exit_json\n  File \"/tmp/ansible_tse6m3il/ansible_modlib.zip/ansible/module_utils/basic.py\", line 2272, in _return_formatted\n  File \"/tmp/ansible_tse6m3il/ansible_modlib.zip/ansible/module_utils/basic.py\", line 514, in remove_values\n  File \"/tmp/ansible_tse6m3il/ansible_modlib.zip/ansible/module_utils/basic.py\", line 497, in _remove_values_conditions\nTypeError: Value of unknown type: <class 'map'>, <map object at 0x7fe2757557b8>\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}
<!--- Paste verbatim command output between quotes below -->
```

```



Discussion:
Files identified in the description:
* [lib/ansible/modules/cloud/amazon/ecs_service_facts.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/amazon/ecs_service_facts.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 @java1guy @kaczynskid @simplesteph @willthames
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Files identified in the description:
* [lib/ansible/modules/cloud/amazon/ecs_service_facts.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/amazon/ecs_service_facts.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 @java1guy @kaczynskid @simplesteph @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/ecs_service_facts.py b/lib/ansible/modules/cloud/amazon/ecs_service_facts.py
--- a/lib/ansible/modules/cloud/amazon/ecs_service_facts.py
+++ b/lib/ansible/modules/cloud/amazon/ecs_service_facts.py
@@ -167,7 +167,9 @@ def describe_services(self, cluster, services):
             fn_args['cluster'] = cluster
         fn_args['services'] = services.split(",")
         response = self.ecs.describe_services(**fn_args)
-        relevant_response = dict(services=map(self.extract_service_from, response['services']))
+        relevant_response = {'services': []}
+        for service in response.get('services', []):
+            relevant_response['services'].append(self.extract_service_from(service))
         if 'failures' in response and len(response['failures']) > 0:
             relevant_response['services_not_running'] = response['failures']
         return relevant_response


Test patch: