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:
parent
c39c782282
commit
b1df75fc1c
2 changed files with 43 additions and 42 deletions
|
@ -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
|
import time
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -526,7 +529,7 @@ def deregister_image(module, ec2):
|
||||||
try:
|
try:
|
||||||
params = {'image_id': image_id,
|
params = {'image_id': image_id,
|
||||||
'delete_snapshot': delete_snapshot}
|
'delete_snapshot': delete_snapshot}
|
||||||
res = ec2.deregister_image(**params)
|
ec2.deregister_image(**params)
|
||||||
except boto.exception.BotoServerError as e:
|
except boto.exception.BotoServerError as e:
|
||||||
module.fail_json(msg="%s: %s" % (e.error_code, e.error_message))
|
module.fail_json(msg="%s: %s" % (e.error_code, e.error_message))
|
||||||
else:
|
else:
|
||||||
|
@ -575,21 +578,24 @@ def update_image(module, ec2, image_id):
|
||||||
if set_permissions != launch_permissions:
|
if set_permissions != launch_permissions:
|
||||||
if (('user_ids' in launch_permissions and launch_permissions['user_ids']) or
|
if (('user_ids' in launch_permissions and launch_permissions['user_ids']) or
|
||||||
('group_names' in launch_permissions and launch_permissions['group_names'])):
|
('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']):
|
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:
|
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))
|
||||||
module.exit_json(msg="AMI launch permissions updated", launch_permissions=launch_permissions, set_perms=set_permissions, changed=True)
|
module.exit_json(msg="AMI launch permissions updated", launch_permissions=launch_permissions,
|
||||||
|
set_perms=set_permissions, changed=True, **get_ami_info(img))
|
||||||
else:
|
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:
|
except boto.exception.BotoServerError as e:
|
||||||
module.fail_json(msg="%s: %s" % (e.error_code, e.error_message))
|
module.fail_json(msg="%s: %s" % (e.error_code, e.error_message))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
argument_spec = ec2_argument_spec()
|
argument_spec = ec2_argument_spec()
|
||||||
argument_spec.update(dict(
|
argument_spec.update(
|
||||||
|
dict(
|
||||||
instance_id=dict(),
|
instance_id=dict(),
|
||||||
image_id=dict(),
|
image_id=dict(),
|
||||||
architecture=dict(default="x86_64"),
|
architecture=dict(default="x86_64"),
|
||||||
|
@ -637,9 +643,5 @@ def main():
|
||||||
create_image(module, ec2)
|
create_image(module, ec2)
|
||||||
|
|
||||||
|
|
||||||
# import module snippets
|
|
||||||
from ansible.module_utils.basic import *
|
|
||||||
from ansible.module_utils.ec2 import *
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -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/cloudfront_facts.py
|
||||||
lib/ansible/modules/cloud/amazon/cloudwatchevent_rule.py
|
lib/ansible/modules/cloud/amazon/cloudwatchevent_rule.py
|
||||||
lib/ansible/modules/cloud/amazon/dynamodb_table.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_copy.py
|
||||||
lib/ansible/modules/cloud/amazon/ec2_ami_find.py
|
lib/ansible/modules/cloud/amazon/ec2_ami_find.py
|
||||||
lib/ansible/modules/cloud/amazon/ec2_eip.py
|
lib/ansible/modules/cloud/amazon/ec2_eip.py
|
||||||
|
|
Loading…
Reference in a new issue