Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

ec2 volume creation breaks with older boto in v2 #1773

Closed
amenonsen opened this issue Jul 22, 2015 · 13 comments
Closed

ec2 volume creation breaks with older boto in v2 #1773

amenonsen opened this issue Jul 22, 2015 · 13 comments

Comments

@amenonsen
Copy link
Contributor

amenonsen commented Jul 22, 2015

Issue type: Bug report
Ansible version: devel
Ansible configuration: NA
Environment: boto 2.25
Summary:

Creating an EC2 instance using the task below fails with a traceback: "TypeError: init() got an unexpected keyword argument 'encrypted".

Support for encrypted volumes seems to have been added in boto 2.33, and I have 2.25. Can this be handled more gracefully somehow? Or make the module require the appropriate version?

Steps to reproduce:

# Create EC2 instances using the VPC subnets and security groups and
# access key we configured above.

- name: Set up EC2 instances
  ec2:
    exact_count: 1
    count_tag: "{{ cluster_tags }}"
    image: "{{ item.0.image }}"
    region: "{{ item.0.region }}"
    group_id: "{{ item.2.group_id }}"
    instance_type: "{{ item.0.type }}"
    vpc_subnet_id: "{{ item.1.subnets[0].id }}"
    instance_tags: "{{ cluster_tags | merge(item.0.tags) }}"
    key_name: "{{ ec2_key_name }}"
    assign_public_ip: yes
    volumes: "{{ item.0.volumes }}"
    wait: yes
  with_together:
    - instances
    - vpcs.results
    - security_groups.results
  register: ec2_instances

Expected results:

That the instance is created correctly (which it is, with stable-1.9; 1.9 supports volumes: but not 'encrypted'). Note that I'm not trying to create an encrypted volume.

Actual results:

"exception": "Traceback (most recent call last):\n  File \"/home/ams/.ansible/tmp/ansible-tmp-1437541681.83-138879933302241/ec2\", line 3174, in <module>\n    main()\n  File \"/home/ams/.ansible/tmp/ansible-tmp-1437541681.83-138879933302241/ec2\", line 1313, in main\n    (tagged_instances, instance_dict_array, new_instance_ids, changed) = enforce_count(module, ec2, vpc)\n  File \"/home/ams/.ansible/tmp/ansible-tmp-1437541681.83-138879933302241/ec2\", line 745, in enforce_count\n    = create_instances(module, ec2, vpc, override_count=to_create)\n  File \"/home/ams/.ansible/tmp/ansible-tmp-1437541681.83-138879933302241/ec2\", line 932, in create_instances\n    bdm[volume['device_name']] = create_block_device(module, ec2, volume)\n  File \"/home/ams/.ansible/tmp/ansible-tmp-1437541681.83-138879933302241/ec2\", line 707, in create_block_device\n    encrypted=volume.get('encrypted', None))\nTypeError: __init__() got an unexpected keyword argument 'encrypted'\n", 
@bcoca
Copy link
Member

bcoca commented Jul 22, 2015

the code does this to prevent old versions from breaking:

return hasattr(boto, 'Version') and LooseVersion(boto.Version) >= LooseVersion('2.29.0')

can you check that this expression works on your loaded boto library?

@amenonsen
Copy link
Contributor Author

I can't test directly, I'm afraid. I had the Debian python-boto 2.25 package installed, and when I understood the problem above, I did "sudo pip install -U boto" because I needed to get it working. I haven't uninstalled 2.25, but I don't know how to use it (or even if the more recent version overwrote some of the packaged files).

If someone can give me instructions on how to do it, I'm willing to test.

@jctanner jctanner added the cloud label May 6, 2016
@laurentgo
Copy link

I have the same issue on Centos 7.2 with ansible 2.1.0.0 and python-boto 2.25.0-2.el7.

The stack trace is:

An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible__Y_tM4/ansible_module_ec2.py", line 1434, in
main()
File "/tmp/ansible__Y_tM4/ansible_module_ec2.py", line 1424, in main
(instance_dict_array, new_instance_ids, changed) = create_instances(module, ec2, vpc)
File "/tmp/ansible__Y_tM4/ansible_module_ec2.py", line 1014, in create_instances
bdm[volume['device_name']] = create_block_device(module, ec2, volume)
File "/tmp/ansible__Y_tM4/ansible_module_ec2.py", line 768, in create_block_device
encrypted=volume.get('encrypted', None))
TypeError: init() got an unexpected keyword argument 'encrypted'

The version check mentionned in the comment from @bcoca is present in ec2_vol module, but not on ec2 module, when setting directly a device block mapping.

@ansibot
Copy link

ansibot commented Aug 1, 2016

@ansible, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Sep 12, 2016

@ansible, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Oct 6, 2016

@ansible, ping. This issue is still waiting on your response.
click here for bot help

1 similar comment
@ansibot
Copy link

ansibot commented Oct 22, 2016

@ansible, ping. This issue is still waiting on your response.
click here for bot help

@vuninh
Copy link

vuninh commented Oct 25, 2016

i got the same issue, and i tried to upgrade boto using below command and i fixed it

pip install boto --upgrade

root@ansible:/etc/ansible# pip install boto --upgrade
Downloading/unpacking boto from https://pypi.python.org/packages/29/64/51e30f48b0e160d384d13aeab66d416b68e404525a34a87aded0da82f32a/boto-2.43.0-py2.py3-none-any.whl#md5=c524e27de9900cb4b58feea092992ba8
Downloading boto-2.43.0-py2.py3-none-any.whl (1.3MB): 1.3MB downloaded
Installing collected packages: boto
Found existing installation: boto 2.20.1
Not uninstalling boto at /usr/lib/python2.7/dist-packages, owned by OS
Successfully installed boto
Cleaning up...

@laurentgo
Copy link

laurentgo commented Oct 25, 2016

@vuninh I understand that upgrading boto will make the problem go away, but this module is supposed to detect which boto version is present and gracefully handle it. This bug is about a specific case not being handled properly.

@ansibot
Copy link

ansibot commented Nov 10, 2016

@ansible, ping. This issue is still waiting on your response.
click here for bot help

laurentgo added a commit to laurentgo/ansible-modules-core that referenced this issue Nov 19, 2016
…le#1773)

Fix issue which prevents creating ec2 instance with extra volumes when
using a older version of boto not supporting volume encryption.

Fix issue ansible#1173
@ansibot
Copy link

ansibot commented Nov 26, 2016

@ansible, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Dec 7, 2016

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo.

@laurentgo
Copy link

This issue was moved to ansible/ansible#19724

@ansibot ansibot closed this as completed Jan 2, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants