mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-02-04 07:11:49 +00:00
Add check and fixed for v5 network diff
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
parent
ace1f5896a
commit
453be5c5fd
5 changed files with 128 additions and 45 deletions
|
|
@ -1246,6 +1246,9 @@ class PodmanContainerDiff:
|
|||
s = ":".join(
|
||||
[str(h["hostport"]), p.replace('/tcp', '')]
|
||||
).strip(":")
|
||||
if h['hostip'] == '0.0.0.0' and LooseVersion(self.version) >= LooseVersion('5.0.0'):
|
||||
self.module.log("PODMAN NNNNET %s" % s)
|
||||
return s
|
||||
if h['hostip']:
|
||||
return ":".join([h['hostip'], s])
|
||||
return s
|
||||
|
|
|
|||
|
|
@ -15,6 +15,11 @@
|
|||
podman_version: 4
|
||||
when: podman_v.stdout is version('4.0.0', '>=')
|
||||
|
||||
- name: Set podman version to 5
|
||||
set_fact:
|
||||
podman_version: 5
|
||||
when: podman_v.stdout is version('5.0.0', '>=')
|
||||
|
||||
- name: Delete all container leftovers from tests
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,24 @@
|
|||
---
|
||||
|
||||
- name: Discover podman version
|
||||
shell: podman version | grep "^Version:" | awk {'print $2'}
|
||||
register: podman_v
|
||||
|
||||
- name: Set podman version to 3
|
||||
set_fact:
|
||||
podman_version: 3
|
||||
when: podman_v.stdout is version('4.0.0', 'lt')
|
||||
|
||||
- name: Set podman version to 4
|
||||
set_fact:
|
||||
podman_version: 4
|
||||
when: podman_v.stdout is version('4.0.0', '>=')
|
||||
|
||||
- name: Set podman version to 5
|
||||
set_fact:
|
||||
podman_version: 5
|
||||
when: podman_v.stdout is version('5.0.0', '>=')
|
||||
|
||||
- name: Prepare a container
|
||||
include_tasks: build_test_container.yml
|
||||
|
||||
|
|
|
|||
|
|
@ -109,53 +109,108 @@
|
|||
that:
|
||||
- info5 is changed
|
||||
|
||||
- name: Run container with slirp4netns options
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: rootlessnet
|
||||
image: "{{ idem_image }}"
|
||||
command: 1h
|
||||
state: present
|
||||
network:
|
||||
- slirp4netns:allow_host_loopback=true,cidr=10.0.3.0/24
|
||||
register: info6
|
||||
- when: podman_version < 5
|
||||
name: Run container tasks with slirp4netns options before v5
|
||||
block:
|
||||
- name: Run container with slirp4netns options
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: rootlessnet
|
||||
image: "{{ idem_image }}"
|
||||
command: 1h
|
||||
state: present
|
||||
network:
|
||||
- slirp4netns:allow_host_loopback=true,cidr=10.0.3.0/24
|
||||
register: info6
|
||||
|
||||
- name: Check info with slirp4netns options
|
||||
assert:
|
||||
that:
|
||||
- info6 is changed
|
||||
- name: Check info with slirp4netns options
|
||||
assert:
|
||||
that:
|
||||
- info6 is changed
|
||||
|
||||
- name: Run container with slirp4netns options - again
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: rootlessnet
|
||||
image: "{{ idem_image }}"
|
||||
command: 1h
|
||||
state: present
|
||||
network:
|
||||
- slirp4netns:allow_host_loopback=true,cidr=10.0.3.0/24
|
||||
register: info7
|
||||
- name: Run container with slirp4netns options - again
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: rootlessnet
|
||||
image: "{{ idem_image }}"
|
||||
command: 1h
|
||||
state: present
|
||||
network:
|
||||
- slirp4netns:allow_host_loopback=true,cidr=10.0.3.0/24
|
||||
register: info7
|
||||
|
||||
- name: Check info with slirp4netns options - again
|
||||
assert:
|
||||
that:
|
||||
- info7 is not changed
|
||||
- name: Check info with slirp4netns options - again
|
||||
assert:
|
||||
that:
|
||||
- info7 is not changed
|
||||
|
||||
- name: Run container with different slirp4netns options
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: rootlessnet
|
||||
image: "{{ idem_image }}"
|
||||
command: 1h
|
||||
state: present
|
||||
network:
|
||||
- slirp4netns:allow_host_loopback=true,cidr=10.0.4.0/24
|
||||
register: info8
|
||||
- name: Run container with different slirp4netns options
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: rootlessnet
|
||||
image: "{{ idem_image }}"
|
||||
command: 1h
|
||||
state: present
|
||||
network:
|
||||
- slirp4netns:allow_host_loopback=true,cidr=10.0.4.0/24
|
||||
register: info8
|
||||
|
||||
- name: Check info with different slirp4netns options
|
||||
assert:
|
||||
that:
|
||||
- info8 is changed
|
||||
- name: Check info with different slirp4netns options
|
||||
assert:
|
||||
that:
|
||||
- info8 is changed
|
||||
|
||||
|
||||
- when: podman_version >= 5
|
||||
name: Run container tasks with pasta options for v5 and later
|
||||
block:
|
||||
- name: Run container with pasta options
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: rootlessnet
|
||||
image: "{{ idem_image }}"
|
||||
command: 1h
|
||||
state: present
|
||||
network:
|
||||
- "pasta:-4,-t,8007,-u,4443,-T,3000"
|
||||
register: info6
|
||||
|
||||
- name: Check info with pasta options
|
||||
assert:
|
||||
that:
|
||||
- info6 is changed
|
||||
|
||||
- name: Run container with pasta options - again
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: rootlessnet
|
||||
image: "{{ idem_image }}"
|
||||
command: 1h
|
||||
state: present
|
||||
network:
|
||||
- "pasta:-4,-t,8007,-u,4443,-T,3000"
|
||||
register: info7
|
||||
|
||||
- name: Check info with pasta options - again
|
||||
assert:
|
||||
that:
|
||||
- info7 is not changed
|
||||
|
||||
- name: Run container with different pasta options
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: rootlessnet
|
||||
image: "{{ idem_image }}"
|
||||
command: 1h
|
||||
state: present
|
||||
network:
|
||||
- "pasta:-4,-t,8008,-u,4443,-T,3000"
|
||||
register: info8
|
||||
|
||||
- name: Check info with different pasta options
|
||||
assert:
|
||||
that:
|
||||
- info8 is changed
|
||||
|
||||
- name: Run container without options
|
||||
containers.podman.podman_container:
|
||||
|
|
|
|||
|
|
@ -26,15 +26,15 @@
|
|||
that:
|
||||
- info.containers.0.State.Running == true
|
||||
- '"FOO=bar" in info.containers.0.Config.Env'
|
||||
|
||||
|
||||
- name: Cleanup pod
|
||||
containers.podman.podman_play:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
kube_file: "{{ kube_dir }}/{{ kube_file }}"
|
||||
state: absent
|
||||
register: remove_pod
|
||||
|
||||
|
||||
- name: Check if the pod was removed as expected
|
||||
assert:
|
||||
that:
|
||||
- remove_pod is changed
|
||||
- remove_pod is changed
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue