1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-04 07:11:49 +00:00

Improve ports idempotency and support UDP

This commit is contained in:
Sagi Shnaidman 2020-07-09 13:10:14 +03:00
parent 7cf4b5e63a
commit e84ad74e27
2 changed files with 23 additions and 21 deletions

View file

@ -1627,20 +1627,12 @@ class PodmanContainerDiff:
# TODO(sshnaidm) Need to add port ranges support
def diffparam_publish(self):
ports = self.info['networksettings']['ports']
# before 2.0.0 we have ports as a list, after 2.0.0 it's a dictionary
if isinstance(ports, list):
before = [":".join([
i['hostip'],
str(i["hostport"]),
str(i["containerport"])
]).strip(':') for i in ports]
elif isinstance(ports, dict):
before = [":".join([
j[0]['hostip'],
str(j[0]["hostport"]),
i.replace('/tcp', '')
]).strip(':') for i, j in ports.items()]
ports = self.info['hostconfig']['portbindings']
before = [":".join([
j[0]['hostip'],
str(j[0]["hostport"]),
i.replace('/tcp', '')
]).strip(':') for i, j in ports.items()]
after = self.params['publish'] or []
if self.params['publish_all']:
image_ports = self.image_info['config'].get('exposedports', {})

View file

@ -24,11 +24,16 @@
image: "{{ idem_image }}"
name: idempotency
state: present
ports:
- 7777:8080/tcp
- 127.0.0.1:8888:1929
- 127.0.0.1:5555:9000
command: 1h
ports:
- "4444:4444/tcp"
- "1212:5555"
- "8888:19191/udp"
- "1900:1900/udp"
- "127.0.0.1:7671:7676/udp"
- "127.0.0.1:12122:8876/udp"
- "127.0.0.1:13122:8871/tcp"
- "127.0.0.1:43423:8872"
register: test2
- name: check test2
@ -41,9 +46,14 @@
state: present
command: 1h
ports:
- 7777:8080/tcp
- 127.0.0.1:8888:1929
- 127.0.0.1:5555:9000
- "4444:4444/tcp"
- "1212:5555"
- "8888:19191/udp"
- "1900:1900/udp"
- "127.0.0.1:7671:7676/udp"
- "127.0.0.1:12122:8876/udp"
- "127.0.0.1:13122:8871/tcp"
- "127.0.0.1:43423:8872"
register: test3
- name: check test3