Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ec2_ami device_mapping is failing on version 2.7 but not 2.4 #49515

Closed
gotenatsiu opened this issue Dec 4, 2018 · 7 comments
Closed

ec2_ami device_mapping is failing on version 2.7 but not 2.4 #49515

gotenatsiu opened this issue Dec 4, 2018 · 7 comments
Assignees
Labels
affects_2.7 This issue/PR affects Ansible v2.7 aws bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. needs_info This issue requires further information. Please answer any outstanding questions. support:community This issue/PR relates to code supported by the Ansible community. traceback This issue/PR includes a traceback.

Comments

@gotenatsiu
Copy link

SUMMARY

ec2_ami fails when using device_mapping

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ec2_ami

ANSIBLE VERSION
ansible 2.7.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/tt/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
CONFIGURATION
OS / ENVIRONMENT

[tt@localhost ansible]$ cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[tt@localhost ansible]$ uname -a
Linux localhost.localdomain 3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

STEPS TO REPRODUCE

Using the ec2_ami module with AMI Creation, excluding a volume attached

---
- hosts: "localhost"
  gather_facts: "True"
  tasks:
    - ec2_ami:
        aws_access_key: "{{ vault.aws.key.access }}"
        aws_secret_key: "{{ vault.aws.key.secret }}"
        region: "{{ aws.region }}"
        instance_id: "{{ ami.instance_id }}"
        name: "new_image_v1"
        device_mapping:
          - device_name: /dev/xvdb
            no_device: True
EXPECTED RESULTS

Register new AMI with name "new_image_v1" which excludes /dev/xvdb in the AMI. Here is the result
using ansible version 2.4.2

ansible-playbook 2.4.2.0
  config file = /home/tt/ansible/ansible.cfg
  configured module search path = [u'/home/tt/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
Using /home/tt/ansible/ansible.cfg as config file
setting up inventory plugins
Parsed /etc/ansible/hosts inventory source with ini plugin
 [WARNING]: Could not match supplied host pattern, ignoring: all

 [WARNING]: provided hosts list is empty, only localhost is available

Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc

PLAYBOOK: testregistration.yml **************************************************************************************************************************************************************************************************************
1 plays in playbooks/testregistration.yml

PLAY [localhost] ****************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] **********************************************************************************************************************************************************************************************************************
Using module file /usr/lib/python2.7/site-packages/ansible/modules/system/setup.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: tt
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/tt/.ansible/tmp/ansible-tmp-1543965979.22-31358253484938 `" && echo ansible-tmp-1543965979.22-31358253484938="` echo /home/tt/.ansible/tmp/ansible-tmp-1543965979.22-31358253484938 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpqq5DjE TO /home/tt/.ansible/tmp/ansible-tmp-1543965979.22-31358253484938/setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/tt/.ansible/tmp/ansible-tmp-1543965979.22-31358253484938/ /home/tt/.ansible/tmp/ansible-tmp-1543965979.22-31358253484938/setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 /home/tt/.ansible/tmp/ansible-tmp-1543965979.22-31358253484938/setup.py; rm -rf "/home/tt/.ansible/tmp/ansible-tmp-1543965979.22-31358253484938/" > /dev/null 2>&1 && sleep 0'
ok: [localhost]
META: ran handlers

TASK [ec2_ami] ******************************************************************************************************************************************************************************************************************************
task path: /home/tt/ansible/playbooks/testregistration.yml:5
Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/amazon/ec2_ami.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: tt
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/tt/.ansible/tmp/ansible-tmp-1543965979.89-280614514786188 `" && echo ansible-tmp-1543965979.89-280614514786188="` echo /home/tt/.ansible/tmp/ansible-tmp-1543965979.89-280614514786188 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpP9QMH9 TO /home/tt/.ansible/tmp/ansible-tmp-1543965979.89-280614514786188/ec2_ami.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/tt/.ansible/tmp/ansible-tmp-1543965979.89-280614514786188/ /home/tt/.ansible/tmp/ansible-tmp-1543965979.89-280614514786188/ec2_ami.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 /home/tt/.ansible/tmp/ansible-tmp-1543965979.89-280614514786188/ec2_ami.py; rm -rf "/home/tt/.ansible/tmp/ansible-tmp-1543965979.89-280614514786188/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
    "architecture": "x86_64",
    "block_device_mapping": {
        "/dev/sda1": {
            "delete_on_termination": true,
            "encrypted": false,
            "size": 10,
            "snapshot_id": "snap-0c6df4d1295ded305",
            "volume_type": "gp2"
        }
    },
    "changed": true,
    "creationDate": "2018-12-04T23:26:21.000Z",
    "description": null,
    "hypervisor": "xen",
    "image_id": "ami-3cb8de5d",
    "invocation": {
        "module_args": {
            "architecture": "x86_64",
            "aws_access_key": "AKIAKOQUSII7GHSHCHZA",
            "aws_secret_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "delete_snapshot": false,
            "description": "",
            "device_mapping": [
                {
                    "no_device": true
                }
            ],
            "ec2_url": null,
            "image_id": null,
            "instance_id": "i-0d0d10124d1382ee8",
            "kernel_id": null,
            "launch_permissions": null,
            "name": "new_image_v1",
            "no_reboot": false,
            "profile": null,
            "region": "us-west-1",
            "root_device_name": null,
            "security_token": null,
            "state": "present",
            "tags": null,
            "validate_certs": true,
            "virtualization_type": "hvm",
            "wait": false,
            "wait_timeout": "900"
        }
    },
    "is_public": false,
    "location": "167223890542/new_image_v1",
    "msg": "AMI creation operation complete",
    "name": "new_image_v1",
    "ownerId": "167223890542",
    "platform": null,
    "root_device_name": "/dev/sda1",
    "root_device_type": "ebs",
    "state": "available",
    "tags": {},
    "virtualization_type": "hvm"
}
META: ran handlers
META: ran handlers

PLAY RECAP **********************************************************************************************************************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0
ACTUAL RESULTS

Error is thrown for invalid parameter on the device_mapping

ansible-playbook 2.7.2
  config file = /home/tt/ansible/ansible.cfg
  configured module search path = [u'/home/tt/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
Using /home/tt/ansible/ansible.cfg as config file
setting up inventory plugins
/etc/ansible/hosts did not meet host_list requirements, check plugin documentation if this is unexpected
/etc/ansible/hosts did not meet script requirements, check plugin documentation if this is unexpected
Parsed /etc/ansible/hosts inventory source with ini plugin
 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/default.pyc

PLAYBOOK: testregistration.yml **************************************************************************************************************************************************************************************************************
1 plays in playbooks/testregistration.yml

PLAY [localhost] ****************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] **********************************************************************************************************************************************************************************************************************
task path: /home/tt/ansible/playbooks/testregistration.yml:2
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: tt
<127.0.0.1> EXEC /bin/sh -c 'echo ~tt && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/tt/.ansible/tmp/ansible-tmp-1543965475.98-58254750026753 `" && echo ansible-tmp-1543965475.98-58254750026753="` echo /home/tt/.ansible/tmp/ansible-tmp-1543965475.98-58254750026753 `" ) && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/system/setup.py
<127.0.0.1> PUT /home/tt/.ansible/tmp/ansible-local-7348kvHIAy/tmpNUVDnB TO /home/tt/.ansible/tmp/ansible-tmp-1543965475.98-58254750026753/AnsiballZ_setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/tt/.ansible/tmp/ansible-tmp-1543965475.98-58254750026753/ /home/tt/.ansible/tmp/ansible-tmp-1543965475.98-58254750026753/AnsiballZ_setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 /home/tt/.ansible/tmp/ansible-tmp-1543965475.98-58254750026753/AnsiballZ_setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/tt/.ansible/tmp/ansible-tmp-1543965475.98-58254750026753/ > /dev/null 2>&1 && sleep 0'
ok: [localhost]
META: ran handlers

TASK [ec2_ami] ******************************************************************************************************************************************************************************************************************************
task path: /home/tt/ansible/playbooks/testregistration.yml:5
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: tt
<127.0.0.1> EXEC /bin/sh -c 'echo ~tt && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/tt/.ansible/tmp/ansible-tmp-1543965476.89-211819615305549 `" && echo ansible-tmp-1543965476.89-211819615305549="` echo /home/tt/.ansible/tmp/ansible-tmp-1543965476.89-211819615305549 `" ) && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/amazon/ec2_ami.py
<127.0.0.1> PUT /home/tt/.ansible/tmp/ansible-local-7348kvHIAy/tmpinzp7w TO /home/tt/.ansible/tmp/ansible-tmp-1543965476.89-211819615305549/AnsiballZ_ec2_ami.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/tt/.ansible/tmp/ansible-tmp-1543965476.89-211819615305549/ /home/tt/.ansible/tmp/ansible-tmp-1543965476.89-211819615305549/AnsiballZ_ec2_ami.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 /home/tt/.ansible/tmp/ansible-tmp-1543965476.89-211819615305549/AnsiballZ_ec2_ami.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/tt/.ansible/tmp/ansible-tmp-1543965476.89-211819615305549/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_ec2_ami_payload_n2hQBO/__main__.py", line 433, in create_image
    image_id = connection.create_image(**params).get('ImageId')
  File "/usr/lib/python2.7/site-packages/botocore/client.py", line 312, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/lib/python2.7/site-packages/botocore/client.py", line 575, in _make_api_call
    api_params, operation_model, context=request_context)
  File "/usr/lib/python2.7/site-packages/botocore/client.py", line 630, in _convert_to_request_dict
    api_params, operation_model)
  File "/usr/lib/python2.7/site-packages/botocore/validate.py", line 291, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())
ParamValidationError: Parameter validation failed:
Invalid type for parameter BlockDeviceMappings[0].NoDevice, value: True, type: <type 'bool'>, valid types: <type 'basestring'>

fatal: [localhost]: FAILED! => {
    "boto3_version": "1.4.6",
    "botocore_version": "1.6.0",
    "changed": false,
    "invocation": {
        "module_args": {
            "architecture": "x86_64",
            "aws_access_key": "AKUSII7GHSHCHZ",
            "aws_secret_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "billing_products": null,
            "delete_snapshot": false,
            "description": "",
            "device_mapping": [
                {
                    "DeviceName": "/dev/xvdb",
                    "Ebs": {},
                    "NoDevice": true
                }
            ],
            "ec2_url": null,
            "enhanced_networking": null,
            "image_id": null,
            "image_location": null,
            "instance_id": "i-0d0d10124d1382ee8",
            "kernel_id": null,
            "launch_permissions": null,
            "name": "new_image_v1",
            "no_reboot": false,
            "profile": null,
            "purge_tags": false,
            "ramdisk_id": null,
            "region": "us-west-1",
            "root_device_name": null,
            "security_token": null,
            "sriov_net_support": null,
            "state": "present",
            "tags": null,
            "validate_certs": true,
            "virtualization_type": "hvm",
            "wait": false,
            "wait_timeout": 900
        }
    },
    "msg": "Error registering image: Parameter validation failed:\nInvalid type for parameter BlockDeviceMappings[0].NoDevice, value: True, type: <type 'bool'>, valid types: <type 'basestring'>"
}
        to retry, use: --limit @/home/tt/ansible/playbooks/testregistration.retry

PLAY RECAP **********************************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1
@ansibot
Copy link
Contributor

ansibot commented Dec 4, 2018

Files identified in the description:

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

@ansibot
Copy link
Contributor

ansibot commented Dec 4, 2018

@ansibot
Copy link
Contributor

ansibot commented Dec 4, 2018

@gotenatsiu, just so you are aware we have a dedicated Working Group for aws.
You can find other people interested in this in #ansible-aws on Freenode IRC
For more information about communities, meetings and agendas see https://github.com/ansible/community

click here for bot help

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 aws bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. traceback This issue/PR includes a traceback. labels Dec 4, 2018
@Akasurde
Copy link
Member

@gotenatsiu Thanks for reporting this issue. Could you please try devel...Akasurde:i49515 and let me know if it works for you ? Thanks.

needs_info

@ansibot ansibot added needs_info This issue requires further information. Please answer any outstanding questions. and removed needs_triage Needs a first human triage before being processed. labels Mar 19, 2019
@ansibot
Copy link
Contributor

ansibot commented Apr 20, 2019

@gotenatsiu This issue is waiting for your response. Please respond or the issue will be closed.

click here for bot help

@Akasurde
Copy link
Member

resolved_by_pr #55565

@ansibot
Copy link
Contributor

ansibot commented May 22, 2019

@gotenatsiu You have not responded to information requests in this issue so we will assume it no longer affects you. If you are still interested in this, please create a new issue with the requested information.

click here for bot help

@ansibot ansibot closed this as completed May 22, 2019
@ansible ansible locked and limited conversation to collaborators Aug 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 aws bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. needs_info This issue requires further information. Please answer any outstanding questions. support:community This issue/PR relates to code supported by the Ansible community. traceback This issue/PR includes a traceback.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants