mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-23 00:30:22 -07:00
[ecs_service] fix assign_public_ip network configuration to module parameter rather than fixed string (#41689)
Fix parameter name Use suboptions document suboptions Add a test to assert assign_public_ip is configurable
This commit is contained in:
parent
37293dec3d
commit
1268ce4d4f
5 changed files with 38 additions and 16 deletions
|
@ -100,10 +100,21 @@ options:
|
|||
network_configuration:
|
||||
description:
|
||||
- network configuration of the service. Only applicable for task definitions created with C(awsvpc) I(network_mode).
|
||||
- I(network_configuration) has two keys, I(subnets), a list of subnet IDs to which the task is attached and I(security_groups),
|
||||
a list of group names or group IDs for the task
|
||||
- assign_public_ip requires botocore >= 1.8.4
|
||||
version_added: 2.6
|
||||
suboptions:
|
||||
subnets:
|
||||
description:
|
||||
- A list of subnet IDs to associate with the task
|
||||
version_added: 2.6
|
||||
security_groups:
|
||||
description:
|
||||
- A list of security group names or group IDs to associate with the task
|
||||
version_added: 2.6
|
||||
assign_public_ip:
|
||||
description:
|
||||
- Whether the task's elastic network interface receives a public IP address. This option requires botocore >= 1.8.4.
|
||||
choices: ["ENABLED", "DISABLED"]
|
||||
version_added: 2.7
|
||||
launch_type:
|
||||
description:
|
||||
- The launch type on which to run your service
|
||||
|
@ -312,11 +323,11 @@ class EcsServiceManager:
|
|||
|
||||
def format_network_configuration(self, network_config):
|
||||
result = dict()
|
||||
if 'subnets' in network_config:
|
||||
if network_config['subnets'] is not None:
|
||||
result['subnets'] = network_config['subnets']
|
||||
else:
|
||||
self.module.fail_json(msg="Network configuration must include subnets")
|
||||
if 'security_groups' in network_config:
|
||||
if network_config['security_groups'] is not None:
|
||||
groups = network_config['security_groups']
|
||||
if any(not sg.startswith('sg-') for sg in groups):
|
||||
try:
|
||||
|
@ -325,10 +336,11 @@ class EcsServiceManager:
|
|||
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
|
||||
self.module.fail_json_aws(e, msg="Couldn't look up security groups")
|
||||
result['securityGroups'] = groups
|
||||
if 'assign_public_ip' in network_config and self.module.botocore_at_least('1.8.4'):
|
||||
result['assign_public_ip'] = 'assign_public_ip'
|
||||
else:
|
||||
self.module.fail_json(msg='botocore needs to be version 1.8.4 or higher to use assign_public_ip in network_configuration')
|
||||
if network_config['assign_public_ip'] is not None:
|
||||
if self.module.botocore_at_least('1.8.4'):
|
||||
result['assignPublicIp'] = network_config['assign_public_ip']
|
||||
else:
|
||||
self.module.fail_json(msg='botocore needs to be version 1.8.4 or higher to use assign_public_ip in network_configuration')
|
||||
return dict(awsvpcConfiguration=result)
|
||||
|
||||
def find_in_array(self, array_of_services, service_name, field_name='serviceArn'):
|
||||
|
@ -446,7 +458,11 @@ def main():
|
|||
deployment_configuration=dict(required=False, default={}, type='dict'),
|
||||
placement_constraints=dict(required=False, default=[], type='list'),
|
||||
placement_strategy=dict(required=False, default=[], type='list'),
|
||||
network_configuration=dict(required=False, type='dict'),
|
||||
network_configuration=dict(required=False, type='dict', options=dict(
|
||||
subnets=dict(type='list'),
|
||||
security_groups=dict(type='list'),
|
||||
assign_public_ip=dict(choices=['ENABLED', 'DISABLED']),
|
||||
)),
|
||||
launch_type=dict(required=False, choices=['EC2', 'FARGATE'])
|
||||
))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue