update ec2_ami_find to allow product-code filter (#18896)

CentOS's cloud image wiki page (wiki.centos.org/Cloud/AWS) gives an
example of using their product code to search for AMIs. This commit
adds an optional parameter to ec2_ami_find to allow this filtering.
This commit is contained in:
Troy Ready 2017-02-22 13:36:59 -08:00 committed by René Moser
parent 4b320ce0e4
commit 3f391f5a23

View file

@ -83,6 +83,12 @@ options:
- Platform type to match. - Platform type to match.
default: null default: null
required: false required: false
product_code:
description:
- Marketplace product code to match.
default: null
required: false
version_added: "2.3"
sort: sort:
description: description:
- Optional attribute which with to sort the results. - Optional attribute which with to sort the results.
@ -307,6 +313,7 @@ def main():
is_public = dict(required=False, type='bool'), is_public = dict(required=False, type='bool'),
name = dict(required=False), name = dict(required=False),
platform = dict(required=False), platform = dict(required=False),
product_code = dict(required=False),
sort = dict(required=False, default=None, sort = dict(required=False, default=None,
choices=['name', 'description', 'tag', 'architecture', 'block_device_mapping', 'creationDate', 'hypervisor', 'is_public', 'location', 'owner_id', 'platform', 'root_device_name', 'root_device_type', 'state', 'virtualization_type']), choices=['name', 'description', 'tag', 'architecture', 'block_device_mapping', 'creationDate', 'hypervisor', 'is_public', 'location', 'owner_id', 'platform', 'root_device_name', 'root_device_type', 'state', 'virtualization_type']),
sort_tag = dict(required=False), sort_tag = dict(required=False),
@ -336,6 +343,7 @@ def main():
name = module.params.get('name') name = module.params.get('name')
owner = module.params.get('owner') owner = module.params.get('owner')
platform = module.params.get('platform') platform = module.params.get('platform')
product_code = module.params.get('product_code')
sort = module.params.get('sort') sort = module.params.get('sort')
sort_tag = module.params.get('sort_tag') sort_tag = module.params.get('sort_tag')
sort_order = module.params.get('sort_order') sort_order = module.params.get('sort_order')
@ -362,6 +370,8 @@ def main():
filter['name'] = name filter['name'] = name
if platform: if platform:
filter['platform'] = platform filter['platform'] = platform
if product_code:
filter['product-code'] = product_code
if virtualization_type: if virtualization_type:
filter['virtualization_type'] = virtualization_type filter['virtualization_type'] = virtualization_type