mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-15 19:42:06 +00:00
Make docker_swarm_service option publish.published_port optional (#101)
* Change docker_swarm_service option publish.published_port from required to optional. If not specified random high port is assigned by docker. * Update changelogs/fragments/101-make-service-published-port-optional.yaml Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
b42b76fc45
commit
5b74313023
@ -0,0 +1,3 @@
|
||||
minor_changes:
|
||||
- docker_swarm_service - change ``publish.published_port`` option from mandatory
|
||||
to optional. Docker will assign random high port if not specified (https://github.com/ansible-collections/community.docker/issues/99).
|
||||
@ -365,7 +365,7 @@ options:
|
||||
description:
|
||||
- The port to make externally available.
|
||||
type: int
|
||||
required: yes
|
||||
required: no
|
||||
target_port:
|
||||
description:
|
||||
- The port inside the container to expose.
|
||||
@ -2066,9 +2066,10 @@ class DockerService(DockerBaseClass):
|
||||
for port in self.publish:
|
||||
port_spec = {
|
||||
'Protocol': port['protocol'],
|
||||
'PublishedPort': port['published_port'],
|
||||
'TargetPort': port['target_port']
|
||||
}
|
||||
if port.get('published_port'):
|
||||
port_spec['PublishedPort'] = port['published_port']
|
||||
if port.get('mode'):
|
||||
port_spec['PublishMode'] = port['mode']
|
||||
ports.append(port_spec)
|
||||
@ -2214,7 +2215,7 @@ class DockerServiceManager(object):
|
||||
ds.publish.append({
|
||||
'protocol': port['Protocol'],
|
||||
'mode': port.get('PublishMode', None),
|
||||
'published_port': int(port['PublishedPort']),
|
||||
'published_port': port.get('PublishedPort', None),
|
||||
'target_port': int(port['TargetPort'])
|
||||
})
|
||||
|
||||
@ -2618,7 +2619,7 @@ def main():
|
||||
options=dict(type='dict'),
|
||||
)),
|
||||
publish=dict(type='list', elements='dict', options=dict(
|
||||
published_port=dict(type='int', required=True),
|
||||
published_port=dict(type='int', required=False),
|
||||
target_port=dict(type='int', required=True),
|
||||
protocol=dict(type='str', default='tcp', choices=['tcp', 'udp']),
|
||||
mode=dict(type='str', choices=['ingress', 'host']),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user