{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/19238","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/19238/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/19238/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/19238/events","html_url":"https://github.com/ansible/ansible/pull/19238","id":195024085,"number":19238,"title":"Fixed ec2_eip.py when assigning a standard elastic IP.","user":{"login":"nikolovivan","id":3465575,"avatar_url":"https://avatars.githubusercontent.com/u/3465575?v=3","gravatar_id":"","url":"https://api.github.com/users/nikolovivan","html_url":"https://github.com/nikolovivan","followers_url":"https://api.github.com/users/nikolovivan/followers","following_url":"https://api.github.com/users/nikolovivan/following{/other_user}","gists_url":"https://api.github.com/users/nikolovivan/gists{/gist_id}","starred_url":"https://api.github.com/users/nikolovivan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikolovivan/subscriptions","organizations_url":"https://api.github.com/users/nikolovivan/orgs","repos_url":"https://api.github.com/users/nikolovivan/repos","events_url":"https://api.github.com/users/nikolovivan/events{/privacy}","received_events_url":"https://api.github.com/users/nikolovivan/received_events","type":"User","site_admin":false},"labels":[{"id":454885231,"url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.3","name":"affects_2.3","color":"5319e7","default":false},{"id":379680333,"url":"https://api.github.com/repos/ansible/ansible/labels/aws","name":"aws","color":"c5def5","default":false},{"id":48276098,"url":"https://api.github.com/repos/ansible/ansible/labels/bugfix_pull_request","name":"bugfix_pull_request","color":"ded270","default":false},{"id":61528803,"url":"https://api.github.com/repos/ansible/ansible/labels/cloud","name":"cloud","color":"c7def8","default":false},{"id":496359346,"url":"https://api.github.com/repos/ansible/ansible/labels/module","name":"module","color":"1d76db","default":false},{"id":231201931,"url":"https://api.github.com/repos/ansible/ansible/labels/needs_rebase","name":"needs_rebase","color":"eb6420","default":false},{"id":61436281,"url":"https://api.github.com/repos/ansible/ansible/labels/needs_revision","name":"needs_revision","color":"eb6450","default":false},{"id":88746767,"url":"https://api.github.com/repos/ansible/ansible/labels/plugin","name":"plugin","color":"bfe5bf","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-12T16:45:31Z","updated_at":"2016-12-19T16:51:52Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ansible/ansible/pulls/19238","html_url":"https://github.com/ansible/ansible/pull/19238","diff_url":"https://github.com/ansible/ansible/pull/19238.diff","patch_url":"https://github.com/ansible/ansible/pull/19238.patch"},"body":"##### ISSUE TYPE\n- Bugfix Pull Request\n##### COMPONENT NAME\n\nec2_eip.py\n##### ANSIBLE VERSION\n\n```\nansible 2.0.2.0\n  config file = /home/ivan/.ansible.cfg\n  configured module search path = Default w/o overrides\n```\n##### SUMMARY\n\nThe ec2_eip module was failing when assigning a standard elastic IP (not a VPC one). It was used as a part of a role (if you're curious):\n\n```\n\n---\n- name: Create EC2 Group\n  ec2_group:\n    name: \"{{ security_group_name }}\"\n    region: \"{{ region }}\"\n    description: \"{{ security_group_description }}\"\n    rules:\n      - proto: tcp\n        from_port: 22\n        to_port: 22\n        cidr_ip: 0.0.0.0/0\n\n- name: Launch instances\n  ec2:\n    key_name: \"{{ key_name }}\"\n    instance_type: \"{{ instance }}\"\n    ebs_optimized: \"{{ ebs_optimized | default(false)  }}\"\n    image: \"{{ ami_version }}\"\n    wait: yes\n    region: \"{{ region }}\"\n    group: \"{{ security_group_name }}\"\n    count: 1\n  register: ec2\n\n- name: Add tags to the newly created instances\n  ec2_tag: resource={{ item.id }} region={{ region }} state=present\n  with_items: ec2.instances\n  args:\n    tags:\n      Name: \"{{ instance_tag_name }}\"\n\n- name: Assign elastic IP\n  ec2_eip: instance_id={{ item.id }} public_ip={{ elastic_ip }} reuse_existing_ip_allowed=yes region={{ region }} state=present in_vpc=no\n  with_items: ec2.instances\n\n- name: Add the new instances to a hostname group\n  add_host: hostname={{ elastic_ip }} groupname={{ host_group_name }}\n            public_ip={{ elastic_ip }} public_dns={{ item.public_dns_name }}\n            private_ip={{ item.private_ip }} host_id={{ item.id }}\n  with_items: ec2.instances\n\n- name: Wait for SSH to be available...\n  wait_for: host={{ elastic_ip }} port=22 delay=60 timeout=320 state=started\n  with_items: ec2.instances\n```\n\nThe output before the fix was:\n\n```\nAn exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: object of type 'NoneType' has no len()\nfailed: [127.0.0.1] (item={u'kernel': u'aki-52a34525', u'root_device_type': u'ebs', u'private_dns_name': u'ip-10-37-181-251.eu-west-1.compute.internal', u'public_ip': u'54.74.248.81', u'private_ip': u'10.37.181.251', u'id': u'i-b5e1803f', u'ebs_optimized': False, u'state': u'running', u'virtualization_type': u'paravirtual', u'architecture': u'x86_64', u'ramdisk': None, u'block_device_mapping': {u'/dev/sda1': {u'status': u'attached', u'delete_on_termination': True, u'volume_id': u'vol-104924e2'}}, u'key_name': u'awskey', u'image_id': u'ami-be5cf7cd', u'tenancy': u'default', u'groups': {u'sg-2f58aa59': u'dangermouse_ci_staging_security'}, u'public_dns_name': u'ec2-54-74-248-81.eu-west-1.compute.amazonaws.com', u'state_code': 16, u'tags': {}, u'placement': u'eu-west-1a', u'ami_launch_index': u'0', u'dns_name': u'ec2-54-74-248-81.eu-west-1.compute.amazonaws.com', u'region': u'eu-west-1', u'launch_time': u'2016-04-26T08:56:23.000Z', u'instance_type': u'm1.large', u'root_device_name': u'/dev/sda1', u'hypervisor': u'xen'}) => {\"failed\": true, \"item\": {\"ami_launch_index\": \"0\", \"architecture\": \"x86_64\", \"block_device_mapping\": {\"/dev/sda1\": {\"delete_on_termination\": true, \"status\": \"attached\", \"volume_id\": \"vol-104924e2\"}}, \"dns_name\": \"ec2-54-74-248-81.eu-west-1.compute.amazonaws.com\", \"ebs_optimized\": false, \"groups\": {\"sg-2f58aa59\": \"dangermouse_ci_staging_security\"}, \"hypervisor\": \"xen\", \"id\": \"i-b5e1803f\", \"image_id\": \"ami-be5cf7cd\", \"instance_type\": \"m1.large\", \"kernel\": \"aki-52a34525\", \"key_name\": \"awskey\", \"launch_time\": \"2016-04-26T08:56:23.000Z\", \"placement\": \"eu-west-1a\", \"private_dns_name\": \"ip-10-37-181-251.eu-west-1.compute.internal\", \"private_ip\": \"10.37.181.251\", \"public_dns_name\": \"ec2-54-74-248-81.eu-west-1.compute.amazonaws.com\", \"public_ip\": \"54.74.248.81\", \"ramdisk\": null, \"region\": \"eu-west-1\", \"root_device_name\": \"/dev/sda1\", \"root_device_type\": \"ebs\", \"state\": \"running\", \"state_code\": 16, \"tags\": {}, \"tenancy\": \"default\", \"virtualization_type\": \"paravirtual\"}, \"module_stderr\": \"Traceback (most recent call last):\\n  File \\\"/home/ivan/.ansible/tmp/ansible-tmp-1461661004.22-199349937218698/ec2_eip\\\", line 2591, in <module>\\n    main()\\n  File \\\"/home/ivan/.ansible/tmp/ansible-tmp-1461661004.22-199349937218698/ec2_eip\\\", line 356, in main\\n    module.check_mode, isinstance=is_instance)\\n  File \\\"/home/ivan/.ansible/tmp/ansible-tmp-1461661004.22-199349937218698/ec2_eip\\\", line 267, in ensure_present\\n    if len(instance.vpc_id) > 0 and domain is None:\\nTypeError: object of type 'NoneType' has no len()\\n\", \"module_stdout\": \"\", \"msg\": \"MODULE FAILURE\", \"parsed\": false}\n```\n\nAfter the fix it works!\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/268015714","html_url":"https://github.com/ansible/ansible/pull/19238#issuecomment-268015714","issue_url":"https://api.github.com/repos/ansible/ansible/issues/19238","id":268015714,"user":{"login":"ansibot","id":6585283,"avatar_url":"https://avatars.githubusercontent.com/u/6585283?v=3","gravatar_id":"","url":"https://api.github.com/users/ansibot","html_url":"https://github.com/ansibot","followers_url":"https://api.github.com/users/ansibot/followers","following_url":"https://api.github.com/users/ansibot/following{/other_user}","gists_url":"https://api.github.com/users/ansibot/gists{/gist_id}","starred_url":"https://api.github.com/users/ansibot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansibot/subscriptions","organizations_url":"https://api.github.com/users/ansibot/orgs","repos_url":"https://api.github.com/users/ansibot/repos","events_url":"https://api.github.com/users/ansibot/events{/privacy}","received_events_url":"https://api.github.com/users/ansibot/received_events","type":"User","site_admin":false},"created_at":"2016-12-19T16:51:52Z","updated_at":"2016-12-19T16:51:52Z","body":"cc @rickmendes\n[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)\n<!--- boilerplate: notify --->"}}
{"actor":{"display_login":"ansibot"}}