|
|
@ -32,7 +32,8 @@ options:
|
|
|
|
choices: ['present', 'absent', 'list']
|
|
|
|
choices: ['present', 'absent', 'list']
|
|
|
|
tags:
|
|
|
|
tags:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- a hash/dictionary of tags to add to the resource; '{"key":"value"}' and '{"key":"value","key":"value"}'
|
|
|
|
- A dictionary of tags to add or remove from the resource.
|
|
|
|
|
|
|
|
- If the value provided for a tag is null and C(state) is I(absent), the tag will be removed regardless of its current value.
|
|
|
|
required: true
|
|
|
|
required: true
|
|
|
|
purge_tags:
|
|
|
|
purge_tags:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
@ -77,6 +78,22 @@ EXAMPLES = '''
|
|
|
|
state: list
|
|
|
|
state: list
|
|
|
|
register: ec2_tags
|
|
|
|
register: ec2_tags
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Remove the Env tag
|
|
|
|
|
|
|
|
ec2_tag:
|
|
|
|
|
|
|
|
region: eu-west-1
|
|
|
|
|
|
|
|
resource: i-xxxxxxxxxxxxxxxxx
|
|
|
|
|
|
|
|
tags:
|
|
|
|
|
|
|
|
Env:
|
|
|
|
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Remove the Env tag if it's currently 'development'
|
|
|
|
|
|
|
|
ec2_tag:
|
|
|
|
|
|
|
|
region: eu-west-1
|
|
|
|
|
|
|
|
resource: i-xxxxxxxxxxxxxxxxx
|
|
|
|
|
|
|
|
tags:
|
|
|
|
|
|
|
|
Env: development
|
|
|
|
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
|
|
|
|
- name: Remove all tags except for Name from an instance
|
|
|
|
- name: Remove all tags except for Name from an instance
|
|
|
|
ec2_tag:
|
|
|
|
ec2_tag:
|
|
|
|
region: eu-west-1
|
|
|
|
region: eu-west-1
|
|
|
@ -149,8 +166,8 @@ def main():
|
|
|
|
remove_tags = {}
|
|
|
|
remove_tags = {}
|
|
|
|
if state == 'absent':
|
|
|
|
if state == 'absent':
|
|
|
|
for key in tags:
|
|
|
|
for key in tags:
|
|
|
|
if key in current_tags and current_tags[key] == tags[key]:
|
|
|
|
if key in current_tags and (tags[key] is None or current_tags[key] == tags[key]):
|
|
|
|
remove_tags[key] = tags[key]
|
|
|
|
remove_tags[key] = current_tags[key]
|
|
|
|
|
|
|
|
|
|
|
|
for key in remove:
|
|
|
|
for key in remove:
|
|
|
|
remove_tags[key] = current_tags[key]
|
|
|
|
remove_tags[key] = current_tags[key]
|
|
|
|