1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[cloud] Return AMI info on ec2_ami module when changed=false (#27867)

Fixes #27861
This commit is contained in:
Will Thames 2017-08-24 02:01:49 +10:00 committed by Ryan Brown
parent c39c782282
commit b1df75fc1c
2 changed files with 43 additions and 42 deletions

View file

@ -349,7 +349,10 @@ snapshots_deleted:
]
'''
import sys
# import module snippets
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ec2 import ec2_connect, ec2_argument_spec
import time
try:
@ -526,7 +529,7 @@ def deregister_image(module, ec2):
try:
params = {'image_id': image_id,
'delete_snapshot': delete_snapshot}
res = ec2.deregister_image(**params)
ec2.deregister_image(**params)
except boto.exception.BotoServerError as e:
module.fail_json(msg="%s: %s" % (e.error_code, e.error_message))
else:
@ -575,21 +578,24 @@ def update_image(module, ec2, image_id):
if set_permissions != launch_permissions:
if (('user_ids' in launch_permissions and launch_permissions['user_ids']) or
('group_names' in launch_permissions and launch_permissions['group_names'])):
res = img.set_launch_permissions(**launch_permissions)
img.set_launch_permissions(**launch_permissions)
elif ('user_ids' in set_permissions and set_permissions['user_ids']) or ('group_names' in set_permissions and set_permissions['group_names']):
res = img.remove_launch_permissions(**set_permissions)
img.remove_launch_permissions(**set_permissions)
else:
module.exit_json(msg="AMI not updated", launch_permissions=set_permissions, changed=False)
module.exit_json(msg="AMI launch permissions updated", launch_permissions=launch_permissions, set_perms=set_permissions, changed=True)
module.exit_json(msg="AMI not updated", launch_permissions=set_permissions, changed=False, **get_ami_info(img))
module.exit_json(msg="AMI launch permissions updated", launch_permissions=launch_permissions,
set_perms=set_permissions, changed=True, **get_ami_info(img))
else:
module.exit_json(msg="AMI not updated", launch_permissions=set_permissions, changed=False)
module.exit_json(msg="AMI not updated", launch_permissions=set_permissions, changed=False, **get_ami_info(img))
except boto.exception.BotoServerError as e:
module.fail_json(msg="%s: %s" % (e.error_code, e.error_message))
def main():
argument_spec = ec2_argument_spec()
argument_spec.update(dict(
argument_spec.update(
dict(
instance_id=dict(),
image_id=dict(),
architecture=dict(default="x86_64"),
@ -637,9 +643,5 @@ def main():
create_image(module, ec2)
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()

View file

@ -17,7 +17,6 @@ lib/ansible/modules/cloud/amazon/cloudformation_facts.py
lib/ansible/modules/cloud/amazon/cloudfront_facts.py
lib/ansible/modules/cloud/amazon/cloudwatchevent_rule.py
lib/ansible/modules/cloud/amazon/dynamodb_table.py
lib/ansible/modules/cloud/amazon/ec2_ami.py
lib/ansible/modules/cloud/amazon/ec2_ami_copy.py
lib/ansible/modules/cloud/amazon/ec2_ami_find.py
lib/ansible/modules/cloud/amazon/ec2_eip.py