diff --git a/roles/service/meta/argument_specs.yaml b/roles/service/meta/argument_specs.yaml index 796d2c5..de9a857 100644 --- a/roles/service/meta/argument_specs.yaml +++ b/roles/service/meta/argument_specs.yaml @@ -113,6 +113,14 @@ argument_specs: description: Container port to publish type: int required: true + protocol: + description: Protocol of the port + type: str + required: false + default: tcp + choices: + - tcp + - udp type: description: Whether to publish as a port or socket type: str @@ -495,6 +503,14 @@ argument_specs: description: Container port to publish type: int required: true + protocol: + description: Protocol of the port + type: str + required: false + default: tcp + choices: + - tcp + - udp type: description: Whether to publish as a port or socket type: str diff --git a/roles/service/vars/main/additional.yaml b/roles/service/vars/main/additional.yaml index 2d6cd00..4c1dd68 100644 --- a/roles/service/vars/main/additional.yaml +++ b/roles/service/vars/main/additional.yaml @@ -152,6 +152,7 @@ _service_additional_container_publish_ports: >- _service_additional_container_publish_port_ports | map(attribute='host_port'), _service_additional_container_publish_port_ports | map(attribute='container_port') ) | map('join', ':') + | zip(_service_additional_container_publish_port_ports | map(attribute='protocol')) | map('join', '/') }} _service_additional_volume_mounts: "{{ _service_additional_container.mounts | selectattr('type', '==', 'volume') }}" diff --git a/roles/service/vars/main/publish_ports.yaml b/roles/service/vars/main/publish_ports.yaml index fce6ef4..a777cf2 100644 --- a/roles/service/vars/main/publish_ports.yaml +++ b/roles/service/vars/main/publish_ports.yaml @@ -1,7 +1,7 @@ --- _service_container_publish_ports_with_defaults: >- {{ - ([{ 'type': 'port', 'host_address': '0.0.0.0' }] * service_container_publish_ports | length) + ([{ 'type': 'port', 'host_address': '0.0.0.0', 'protocol': 'tcp' }] * service_container_publish_ports | length) | zip(service_container_publish_ports) | map('combine') }} @@ -13,9 +13,10 @@ _service_container_publish_port_ports: >- _service_container_publish_ports: >- {{ - _service_container_publish_port_ports | map(attribute='host_address') | - zip( + _service_container_publish_port_ports | map(attribute='host_address') + | zip( _service_container_publish_port_ports | map(attribute='host_port'), _service_container_publish_port_ports | map(attribute='container_port') ) | map('join', ':') + | zip(_service_container_publish_port_ports | map(attribute='protocol')) | map('join', '/') }}