Skip to content

Commit

Permalink
ec2_tag - simplified 'required' logic (ansible-collections#847)
Browse files Browse the repository at this point in the history
ec2_tag - simplified 'required' logic

SUMMARY
We removed the 'list' functionality in ansible-collections#829 which now makes tags required for all states, simplify the logic.
ISSUE TYPE

Docs Pull Request
Feature Pull Request

COMPONENT NAME
plugins/modules/ec2_tag.py
ADDITIONAL INFORMATION
Not added a changelog, this rolls up into the change made for ansible-collections#829 which has its own changelog

Reviewed-by: Alina Buzachis <None>
  • Loading branch information
tremble authored May 30, 2022
1 parent 8c4e2d5 commit 456c556
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions plugins/modules/ec2_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
description:
- A dictionary of tags to add or remove from the resource.
- If the value provided for a key is not set and I(state=absent), the tag will be removed regardless of its current value.
- Required when I(state=present) or I(state=absent).
type: dict
required: true
purge_tags:
description:
- Whether unspecified tags should be removed from the resource.
Expand Down Expand Up @@ -124,13 +124,11 @@
def main():
argument_spec = dict(
resource=dict(required=True),
tags=dict(type='dict'),
tags=dict(type='dict', required=True),
purge_tags=dict(type='bool', default=False),
state=dict(default='present', choices=['present', 'absent']),
)
required_if = [('state', 'present', ['tags']), ('state', 'absent', ['tags'])]

module = AnsibleAWSModule(argument_spec=argument_spec, required_if=required_if, supports_check_mode=True)
module = AnsibleAWSModule(argument_spec=argument_spec, supports_check_mode=True)

resource = module.params['resource']
tags = module.params['tags']
Expand Down

0 comments on commit 456c556

Please sign in to comment.