mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
[aws]Add VPC configuration to ECS modules (#34381)
Enable awsvpc network mode for ECS services and tasks and their underlying task definitions Improve test suite to thoroughly test the changes Use runme.sh technique to run old and new versions of botocore to ensure that the modules work with older botocore and older network modes and fail gracefully if awsvpc network mode is used with older botocore
This commit is contained in:
@@ -58,9 +58,10 @@ options:
|
||||
network_mode:
|
||||
description:
|
||||
- The Docker networking mode to use for the containers in the task.
|
||||
- C(awsvpc) mode was added in Ansible 2.5
|
||||
required: false
|
||||
default: bridge
|
||||
choices: [ 'bridge', 'host', 'none' ]
|
||||
choices: [ 'bridge', 'host', 'none', 'awsvpc' ]
|
||||
version_added: 2.3
|
||||
task_role_arn:
|
||||
description:
|
||||
@@ -166,6 +167,10 @@ class EcsTaskManager:
|
||||
for port in ('hostPort', 'containerPort'):
|
||||
if port in port_mapping:
|
||||
port_mapping[port] = int(port_mapping[port])
|
||||
if network_mode == 'awsvpc' and 'hostPort' in port_mapping:
|
||||
if port_mapping['hostPort'] != port_mapping.get('containerPort'):
|
||||
self.module.fail_json(msg="In awsvpc network mode, host port must be set to the same as "
|
||||
"container port or not be set")
|
||||
|
||||
validated_containers.append(container)
|
||||
|
||||
@@ -227,7 +232,7 @@ def main():
|
||||
revision=dict(required=False, type='int'),
|
||||
force_create=dict(required=False, default=False, type='bool'),
|
||||
containers=dict(required=False, type='list'),
|
||||
network_mode=dict(required=False, default='bridge', choices=['bridge', 'host', 'none'], type='str'),
|
||||
network_mode=dict(required=False, default='bridge', choices=['bridge', 'host', 'none', 'awsvpc'], type='str'),
|
||||
task_role_arn=dict(required=False, default='', type='str'),
|
||||
volumes=dict(required=False, type='list')))
|
||||
|
||||
@@ -390,5 +395,6 @@ def main():
|
||||
|
||||
module.exit_json(**results)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user