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
This commit is contained in:
parent
ed3a3dc080
commit
e8d7e511ff
4 changed files with 87 additions and 4 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue