You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the ec2_image module with the option for tagging specified, tagging of volumes fails due to the presences of ephemeral volumes in the AMI metadata. Those volumes don't have a populated EBS property nor related snapshots, so tagging fails.
When executing AMI creation, image should be created with snapshots tagged successfully. Ephemeral volumes should not be tagged (that doesn't work). Recommend ensuring that a volume has EBS data before attempting to fetch the snapshot id.
Actual Results
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'get'fatal: [localhost]: FAILED! => changed=false module_stderr: |- Traceback (most recent call last): File "/root/.ansible/tmp/ansible-tmp-1632318788.9606068-145-264789969155637/AnsiballZ_ec2_ami.py", line 100, in <module> _ansiballz_main() File "/root/.ansible/tmp/ansible-tmp-1632318788.9606068-145-264789969155637/AnsiballZ_ec2_ami.py", line 92, in _ansiballz_main invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS) File "/root/.ansible/tmp/ansible-tmp-1632318788.9606068-145-264789969155637/AnsiballZ_ec2_ami.py", line 40, in invoke_module runpy.run_module(mod_name='ansible_collections.amazon.aws.plugins.modules.ec2_ami', init_globals=dict(_module_fqn='ansible_collections.amazon.aws.plugins.modules.ec2_ami', _modlib_path=modlib_path), File "/usr/local/lib/python3.9/runpy.py", line 210, in run_module return _run_module_code(code, init_globals, run_name, mod_spec) File "/usr/local/lib/python3.9/runpy.py", line 97, in _run_module_code _run_code(code, mod_globals, init_globals, File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/tmp/ansible_ec2_ami_payload_9wbc0zrk/ansible_ec2_ami_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_ami.py", line 773, in <module> File "/tmp/ansible_ec2_ami_payload_9wbc0zrk/ansible_ec2_ami_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_ami.py", line 769, in main File "/tmp/ansible_ec2_ami_payload_9wbc0zrk/ansible_ec2_ami_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_ami.py", line 525, in create_image AttributeError: 'NoneType' object has no attribute 'get' module_stdout: '' msg: |- MODULE FAILURE See stdout/stderr for the exact error rc: 1
When verifying against a RHEL AMI that does not have ephemeral volumes in the AMI, image creation succeeds. Output of the EBS volumes reference in that image:
After failing to tag a Windows AMI during creation, which does have ephemeral volumes, I verified that, while the volumes are listed, they do not have any EBS data, so would fail to tag.
Thanks for taking the time to report this issue. #520 should fix the issue you're seeing, and updates our integration tests to cover the issue you've hit.
If you're able to confirm that #520 fixes your issue, adding a comment on the PR will help the folks reviewing know if it's the right change. (If it doesn't fix the issue, then it'll also let me know there's another issue somewhere).
Summary
When using the ec2_image module with the option for tagging specified, tagging of volumes fails due to the presences of ephemeral volumes in the AMI metadata. Those volumes don't have a populated EBS property nor related snapshots, so tagging fails.
The offending line seems to be in this file at line 525: https://github.com/ansible-collections/amazon.aws/blame/main/plugins/modules/ec2_ami.py
Recommend checking if the value returned by
mapping.get('Ebs')
is not 'None' before attempting to fetch the SnapshotId.Issue Type
Bug Report
Component Name
ec2_image
Ansible Version
Collection Versions
AWS SDK versions
Configuration
$ ansible-config dump --only-changed
OS / Environment
Python3-Alpine Docker Image on RHEL GitLab Runner
Steps to Reproduce
Expected Results
When executing AMI creation, image should be created with snapshots tagged successfully. Ephemeral volumes should not be tagged (that doesn't work). Recommend ensuring that a volume has EBS data before attempting to fetch the snapshot id.
Actual Results
When verifying against a RHEL AMI that does not have ephemeral volumes in the AMI, image creation succeeds. Output of the EBS volumes reference in that image:
After failing to tag a Windows AMI during creation, which does have ephemeral volumes, I verified that, while the volumes are listed, they do not have any EBS data, so would fail to tag.
Code of Conduct
The text was updated successfully, but these errors were encountered: