{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/2641","repository_url":"https://api.github.com/repos/ansible/ansible-modules-extras","labels_url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/2641/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/2641/comments","events_url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/2641/events","html_url":"https://github.com/ansible/ansible-modules-extras/issues/2641","id":168533404,"number":2641,"title":"ecs_taskdefinition bug when looping with_items","user":{"login":"anryko","id":3940391,"avatar_url":"https://avatars.githubusercontent.com/u/3940391?v=3","gravatar_id":"","url":"https://api.github.com/users/anryko","html_url":"https://github.com/anryko","followers_url":"https://api.github.com/users/anryko/followers","following_url":"https://api.github.com/users/anryko/following{/other_user}","gists_url":"https://api.github.com/users/anryko/gists{/gist_id}","starred_url":"https://api.github.com/users/anryko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anryko/subscriptions","organizations_url":"https://api.github.com/users/anryko/orgs","repos_url":"https://api.github.com/users/anryko/repos","events_url":"https://api.github.com/users/anryko/events{/privacy}","received_events_url":"https://api.github.com/users/anryko/received_events","type":"User","site_admin":false},"labels":[{"id":437719857,"url":"https://api.github.com/repos/ansible/ansible-modules-extras/labels/affects_2.1","name":"affects_2.1","color":"5319e7","default":false},{"id":382551938,"url":"https://api.github.com/repos/ansible/ansible-modules-extras/labels/aws","name":"aws","color":"c5def5","default":false},{"id":132898023,"url":"https://api.github.com/repos/ansible/ansible-modules-extras/labels/bug_report","name":"bug_report","color":"fbca04","default":false},{"id":132898074,"url":"https://api.github.com/repos/ansible/ansible-modules-extras/labels/cloud","name":"cloud","color":"c7def8","default":false},{"id":415779102,"url":"https://api.github.com/repos/ansible/ansible-modules-extras/labels/waiting_on_maintainer","name":"waiting_on_maintainer","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-07-31T19:17:50Z","updated_at":"2016-11-01T00:39:55Z","closed_at":null,"body":"<!--- Verify first that your issue/request is not already reported in GitHub -->\n##### ISSUE TYPE\n\n<!--- Pick one below and delete the rest: -->\n- Bug Report\n##### COMPONENT NAME\n\n<!--- Name of the plugin/module/task -->\n\necs_taskdefinition.py\n##### ANSIBLE VERSION\n\n<!--- Paste verbatim output from “ansible --version” between quotes below -->\n\n```\n2.1.0.0\n```\n##### CONFIGURATION\n\n<!---\nMention any settings you have changed/added/removed in ansible.cfg\n(or using the ANSIBLE_* environment variables).\n-->\n##### OS / ENVIRONMENT\n\n<!---\nMention the OS you are running Ansible from, and the OS you are\nmanaging, or say “N/A” for anything that is not platform-specific.\n-->\n\nRunning on: OS X El Capitan\nManaging: aws esc\n##### SUMMARY\n\n<!--- Explain the problem briefly -->\n\nWhen using module ecs_taskdefinition in an ansible loop (with_items), all item<dict> values are converted to <string>. This causes ecs task definition validator to break the module on submit.\n\n```\nThe error was: Invalid type for parameter containerDefinitions[0].cpu, value\n: 128, type: <type 'str'>, valid types: <type 'int'>, <type 'long'>\n```\n##### STEPS TO REPRODUCE\n\n<!---\nFor bugs, show exactly how to reproduce the problem.\nFor new features, show how the feature would be used.\n-->\n\n<!--- Paste example playbooks or commands between quotes below -->\n\n```\n---\n- name: ECS tasks\n  hosts: localhost\n  gather_facts: no\n\n  vars:\n    ecs_cluster_name: \"ecsAnsibleTest\"\n    ecs_syslog_server: \"tcp://syslogserver.ecample.com:514\"\n\n    tasks:\n      - name: \"some-task\"\n        revision: 1\n        state: present\n        cont_name: \"contname\"\n        cont_cpu: 128\n        cont_memory: 256\n        cont_image: \"someorg/someimage:latest\"\n        cont_command:\n          - \"/some/command\"\n        cont_bind_port: 9999\n        cont_env:\n          - name: \"APPLICATION_SECRET\"\n            value: \"!!!somesecret!!!\"\n\n  tasks:\n    - name: Manage ECS tasks\n      local_action:\n        module: ecs_taskdefinition\n        family: \"{{ item.name }}\"\n        revision: \"{{ item.revision }}\"\n        state: \"{{ item.state }}\"\n        containers:\n          - name: \"{{ item.cont_name }}\"\n            command: \"{{ item.cont_command }}\"\n            cpu: \"{{ item.cont_cpu | int }}\"\n            memory: \"{{ item.cont_memory | default(128) }}\"\n            image: \"{{ item.cont_image }}\"\n            essential: true\n            portMappings:\n              - containerPort: \"{{ item.cont_port | default(8888) }}\"\n                hostPort: \"{{ item.cont_bind_port }}\"\n            logConfiguration:\n              logDriver: \"syslog\"\n              options:\n                syslog-address: \"{{ ecs_syslog_server }}\"\n            environment: \"{{ item.cont_env }}\"\n      register: manage_tasks_output\n      with_items: \"{{ tasks }}\"\n\n    - debug:\n        var: \"{{ manage_tasks_output }}\"\n        verbosity: 4\n      with_items:\n        - \"{{ manage_tasks_output }}\"\n```\n\n<!--- You can also paste gist.github.com links for larger files -->\n##### EXPECTED RESULTS\n\n<!--- What did you expect to happen when running the steps above? -->\n\nI expect it to work :)\n##### ACTUAL RESULTS\n\n<!--- What actually happened? If possible run with high verbosity (-vvvv) -->\n\n```\nInvalid type for parameter containerDefinitions[0].memory, value: 256, type: <type 'str'>, valid types: <type 'int'>, <type 'long'>\nInvalid type for parameter containerDefinitions[0].portMappings[0].containerPort, value: 8888, type: <type 'str'>, valid types: <type 'int'>, <type 'long'>\nInvalid type for parameter containerDefinitions[0].portMappings[0].hostPort, value: 9999, type: <type 'str'>, valid types: <type 'int'>, <type 'long'>\nInvalid type for parameter containerDefinitions[0].cpu, value: 128, type: <type 'str'>, valid types: <type 'int'>, <type 'long'>\n```\n\n<!--- Paste verbatim command output between quotes below -->\n\nIn the meantime i solved it with this patch. However, I don't PR it because it solves just my specific issue and the fix is kinda ugly. Probably there is a much better way to fix this.\n\n```\n--- ecs_taskdefinition.py       2016-07-31 20:50:33.000000000 +0200\n+++ /usr/local/Cellar/ansible/2.1.0.0/libexec/lib/python2.7/site-packages/ansible/modules/extras/cloud/amazon/ecs_taskdefinition.py     2016-07-31 20:51:22.000000000 +0200\n@@ -192,6 +192,19 @@\n                     volumes = module.params['volumes']\n                 if volumes is None:\n                     volumes = []\n+\n+                def setIntTypesInContainers(c):\n+                  ck = c.keys()\n+                  if 'cpu' in ck: c['cpu'] = int(c['cpu'])\n+                  if 'memory' in ck: c['memory'] = int(c['memory'])\n+                  if 'portMappings' in ck:\n+                    for m in c['portMappings']:\n+                      mk = m.keys()\n+                      if 'containerPort' in mk: m['containerPort'] = int(m['containerPort'])\n+                      if 'hostPort' in mk: m['hostPort'] = int(m['hostPort'])\n+\n+                map(setIntTypesInContainers, module.params['containers'])\n+\n                 results['taskdefinition'] = task_mgr.register_task(module.params['family'],\n                     module.params['containers'], volumes)\n             results['changed'] = True\n```\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/comments/257462108","html_url":"https://github.com/ansible/ansible-modules-extras/issues/2641#issuecomment-257462108","issue_url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/2641","id":257462108,"user":{"login":"simplesteph","id":20851561,"avatar_url":"https://avatars.githubusercontent.com/u/20851561?v=3","gravatar_id":"","url":"https://api.github.com/users/simplesteph","html_url":"https://github.com/simplesteph","followers_url":"https://api.github.com/users/simplesteph/followers","following_url":"https://api.github.com/users/simplesteph/following{/other_user}","gists_url":"https://api.github.com/users/simplesteph/gists{/gist_id}","starred_url":"https://api.github.com/users/simplesteph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simplesteph/subscriptions","organizations_url":"https://api.github.com/users/simplesteph/orgs","repos_url":"https://api.github.com/users/simplesteph/repos","events_url":"https://api.github.com/users/simplesteph/events{/privacy}","received_events_url":"https://api.github.com/users/simplesteph/received_events","type":"User","site_admin":false},"created_at":"2016-11-01T00:39:55Z","updated_at":"2016-11-01T00:39:55Z","body":"This PR also addresses it a bit https://github.com/ansible/ansible-modules-extras/pull/1715"}}
{"actor":{"display_login":"simplesteph"}}