mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
ec2_group: description is only required when group state is present (#19791)
* description is only required when group state is present also note that AWS requires a non-empty description when creating a security group * clarify description requirement
This commit is contained in:
parent
e0d38fb137
commit
8e910cce8a
2 changed files with 23 additions and 7 deletions
|
@ -34,8 +34,8 @@ options:
|
||||||
required: true
|
required: true
|
||||||
description:
|
description:
|
||||||
description:
|
description:
|
||||||
- Description of the security group.
|
- Description of the security group. Required when C(state) is C(present).
|
||||||
required: true
|
required: false
|
||||||
vpc_id:
|
vpc_id:
|
||||||
description:
|
description:
|
||||||
- ID of the VPC to create the group in.
|
- ID of the VPC to create the group in.
|
||||||
|
@ -242,7 +242,7 @@ def main():
|
||||||
argument_spec = ec2_argument_spec()
|
argument_spec = ec2_argument_spec()
|
||||||
argument_spec.update(dict(
|
argument_spec.update(dict(
|
||||||
name=dict(type='str', required=True),
|
name=dict(type='str', required=True),
|
||||||
description=dict(type='str', required=True),
|
description=dict(type='str', required=False),
|
||||||
vpc_id=dict(type='str'),
|
vpc_id=dict(type='str'),
|
||||||
rules=dict(type='list'),
|
rules=dict(type='list'),
|
||||||
rules_egress=dict(type='list'),
|
rules_egress=dict(type='list'),
|
||||||
|
@ -269,6 +269,9 @@ def main():
|
||||||
purge_rules = module.params['purge_rules']
|
purge_rules = module.params['purge_rules']
|
||||||
purge_rules_egress = module.params['purge_rules_egress']
|
purge_rules_egress = module.params['purge_rules_egress']
|
||||||
|
|
||||||
|
if state == 'present' and not description:
|
||||||
|
module.fail_json(msg='Must provide description when state is present.')
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
ec2 = ec2_connect(module)
|
ec2 = ec2_connect(module)
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- 'result.failed'
|
- 'result.failed'
|
||||||
- 'result.msg == "missing required arguments: description,name"'
|
- 'result.msg == "missing required arguments: name"'
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: test failure with only name
|
- name: test failure with only name
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- 'result.failed'
|
- 'result.failed'
|
||||||
- 'result.msg == "missing required arguments: description"'
|
- 'result.msg == "Must provide description when state is present."'
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: test failure with only description
|
- name: test failure with only description
|
||||||
|
@ -46,6 +46,21 @@
|
||||||
- 'result.failed'
|
- 'result.failed'
|
||||||
- 'result.msg == "missing required arguments: name"'
|
- 'result.msg == "missing required arguments: name"'
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
- name: test failure with empty description (AWS API requires non-empty string desc)
|
||||||
|
ec2_group:
|
||||||
|
name='{{ec2_group_name}}'
|
||||||
|
description=''
|
||||||
|
region='{{ec2_region}}'
|
||||||
|
register: result
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: assert failure with empty description
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- 'result.failed'
|
||||||
|
- 'result.msg == "Must provide description when state is present."'
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: test invalid region parameter
|
- name: test invalid region parameter
|
||||||
ec2_group:
|
ec2_group:
|
||||||
|
@ -213,7 +228,6 @@
|
||||||
- name: test state=absent (expected changed=true)
|
- name: test state=absent (expected changed=true)
|
||||||
ec2_group:
|
ec2_group:
|
||||||
name='{{ec2_group_name}}'
|
name='{{ec2_group_name}}'
|
||||||
description='{{ec2_group_description}}'
|
|
||||||
state=absent
|
state=absent
|
||||||
environment:
|
environment:
|
||||||
EC2_REGION: '{{ec2_region}}'
|
EC2_REGION: '{{ec2_region}}'
|
||||||
|
@ -231,7 +245,6 @@
|
||||||
- name: test state=absent (expected changed=false)
|
- name: test state=absent (expected changed=false)
|
||||||
ec2_group:
|
ec2_group:
|
||||||
name='{{ec2_group_name}}'
|
name='{{ec2_group_name}}'
|
||||||
description='{{ec2_group_description}}'
|
|
||||||
state=absent
|
state=absent
|
||||||
environment:
|
environment:
|
||||||
EC2_REGION: '{{ec2_region}}'
|
EC2_REGION: '{{ec2_region}}'
|
||||||
|
|
Loading…
Reference in a new issue