mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 11:10:21 -07:00
Add option to toggle describe_image_attribute lookups (#34977)
This commit is contained in:
parent
20824b8f3d
commit
5a9562a101
1 changed files with 11 additions and 4 deletions
|
@ -35,6 +35,11 @@ options:
|
||||||
description:
|
description:
|
||||||
- Filter images by users with explicit launch permissions. Valid options are an AWS account ID, self, or all (public AMIs).
|
- Filter images by users with explicit launch permissions. Valid options are an AWS account ID, self, or all (public AMIs).
|
||||||
aliases: [executable_user]
|
aliases: [executable_user]
|
||||||
|
describe_image_attributes:
|
||||||
|
description:
|
||||||
|
- Describe attributes (like launchPermission) of the images found.
|
||||||
|
default: no
|
||||||
|
choices: ["yes", "no"]
|
||||||
|
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- aws
|
- aws
|
||||||
|
@ -127,7 +132,7 @@ images:
|
||||||
sample: machine
|
sample: machine
|
||||||
launch_permissions:
|
launch_permissions:
|
||||||
description: launch permissions of the ami
|
description: launch permissions of the ami
|
||||||
returned: when image is owned by calling account
|
returned: when image is owned by calling account and describe_image_attributes is yes
|
||||||
type: complex
|
type: complex
|
||||||
sample: [{"group": "all"}, {"user_id": "408466080000"}]
|
sample: [{"group": "all"}, {"user_id": "408466080000"}]
|
||||||
name:
|
name:
|
||||||
|
@ -222,6 +227,7 @@ def list_ec2_images(ec2_client, module):
|
||||||
for image in images:
|
for image in images:
|
||||||
try:
|
try:
|
||||||
image['tags'] = boto3_tag_list_to_ansible_dict(image.get('tags', []))
|
image['tags'] = boto3_tag_list_to_ansible_dict(image.get('tags', []))
|
||||||
|
if module.params.get("describe_image_attributes"):
|
||||||
launch_permissions = ec2_client.describe_image_attribute(Attribute='launchPermission', ImageId=image['image_id'])['LaunchPermissions']
|
launch_permissions = ec2_client.describe_image_attribute(Attribute='launchPermission', ImageId=image['image_id'])['LaunchPermissions']
|
||||||
image['launch_permissions'] = [camel_dict_to_snake_dict(perm) for perm in launch_permissions]
|
image['launch_permissions'] = [camel_dict_to_snake_dict(perm) for perm in launch_permissions]
|
||||||
except (ClientError, BotoCoreError) as err:
|
except (ClientError, BotoCoreError) as err:
|
||||||
|
@ -239,7 +245,8 @@ def main():
|
||||||
image_ids=dict(default=[], type='list', aliases=['image_id']),
|
image_ids=dict(default=[], type='list', aliases=['image_id']),
|
||||||
filters=dict(default={}, type='dict'),
|
filters=dict(default={}, type='dict'),
|
||||||
owners=dict(default=[], type='list', aliases=['owner']),
|
owners=dict(default=[], type='list', aliases=['owner']),
|
||||||
executable_users=dict(default=[], type='list', aliases=['executable_user'])
|
executable_users=dict(default=[], type='list', aliases=['executable_user']),
|
||||||
|
describe_image_attributes=dict(default=False, type='bool')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue