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

Add IPv6 support for publishing ports (#226)

This commit is contained in:
Sergey 2021-03-31 18:28:46 +03:00 committed by GitHub
parent ed3a3dc080
commit d87777394b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 87 additions and 4 deletions

View file

@ -1043,9 +1043,12 @@ class PodmanContainerDiff:
# TODO(sshnaidm) Need to add port ranges support
def diffparam_publish(self):
def compose(p, h):
return ":".join(
[h['hostip'], str(h["hostport"]), p.replace('/tcp', '')]
s = ":".join(
[str(h["hostport"]), p.replace('/tcp', '')]
).strip(":")
if h['hostip']:
return ":".join([h['hostip'], s])
return s
ports = self.info['hostconfig']['portbindings']
before = []
@ -1057,7 +1060,9 @@ class PodmanContainerDiff:
image_ports = self.image_info['config'].get('exposedports', {})
if image_ports:
after += list(image_ports.keys())
after = [i.replace("/tcp", "") for i in after]
after = [
i.replace("/tcp", "").replace("[", "").replace("]", "")
for i in after]
# No support for port ranges yet
for ports in after:
if "-" in ports:

View file

@ -380,7 +380,9 @@ class PodmanPodDiff:
i.replace('/tcp', '')
]).strip(':') for i, j in ports.items()]
after = self.params['publish'] or []
after = [i.replace("/tcp", "") for i in after]
after = [
i.replace("/tcp", "").replace("[", "").replace("]", "").strip(":")
for i in after]
# No support for port ranges yet
for ports in after:
if "-" in ports:

View file

@ -151,3 +151,43 @@
assert:
that:
- info7 is not changed
- name: Run container with publishing ports and ipv6
containers.podman.podman_container:
image: "{{ idem_image }}"
name: root-idempotency
state: present
command: 1h
ports:
- "4444:4444/tcp"
- "1212:5555"
- "8888:19191/udp"
- "127.0.0.1:7671:7676/udp"
- "127.0.0.3:43423:8872"
- "[::1]:34523:35425"
register: info8
- name: Check that it is recreated
assert:
that:
- info8 is changed
- name: Run container with publishing ports and ipv6 again
containers.podman.podman_container:
image: "{{ idem_image }}"
name: root-idempotency
state: present
command: 1h
ports:
- "4444:4444/tcp"
- "1212:5555"
- "8888:19191/udp"
- "127.0.0.1:7671:7676/udp"
- "127.0.0.3:43423:8872"
- "[::1]:34523:35425"
register: info9
- name: Check that it is recreated
assert:
that:
- info9 is not changed

View file

@ -107,6 +107,42 @@
that:
- pod7_info is changed
- name: Start pod with ports for idempotency and ipv6
containers.podman.podman_pod:
name: pod1
state: started
ports:
- "4444:4444/tcp"
- "8888:19191/udp"
- "127.0.0.1:7671:7676/udp"
- "127.0.0.1:13122:8871/tcp"
- "127.0.0.1:43423:8872"
- "[::1]:8743:8745"
register: pod8_info
- name: Check info
assert:
that:
- pod8_info is changed
- name: Start pod with ports for idempotency and ipv6 again
containers.podman.podman_pod:
name: pod1
state: started
ports:
- "4444:4444/tcp"
- "8888:19191/udp"
- "127.0.0.1:7671:7676/udp"
- "127.0.0.1:13122:8871/tcp"
- "127.0.0.1:43423:8872"
- "[::1]:8743:8745"
register: pod9_info
- name: Check info
assert:
that:
- pod9_info is not changed
always:
- name: Delete all pods leftovers from tests