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

Add quadlet file mode option to specify file permission (#867)

* Add quadlet file mode option

Signed-off-by: ghoudmon <guillaume@houdmon.com>

* Fix file mode only change test

Signed-off-by: ghoudmon <guillaume@houdmon.com>

---------

Signed-off-by: ghoudmon <guillaume@houdmon.com>
This commit is contained in:
Guillaume HOUDMON 2024-10-22 14:20:26 +02:00 committed by GitHub
parent 84cff745f9
commit 2deadf069a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 193 additions and 6 deletions

View file

@ -1191,6 +1191,69 @@
that:
- quadlet_file_custom3.stat.exists
- name: Fail if wrong default file mode
assert:
that:
- quadlet_file_custom3.stat.mode == '0640'
- name: Create a Quadlet for container with file mode
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: container-quadlet-mode
image: alpine
state: quadlet
quadlet_file_mode: '0644'
- name: Check file mode
stat:
path: ~/.config/containers/systemd/container-quadlet-mode.container
register: quadlet_file_mode1
- name: Fail if file is present and with correct mode
assert:
that:
- quadlet_file_mode1.stat.exists
- quadlet_file_mode1.stat.mode == '0644'
- name: Create same Quadlet for container without file mode
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: container-quadlet-mode
image: alpine
state: quadlet
register: quad_mode2
- name: Check file mode
stat:
path: ~/.config/containers/systemd/container-quadlet-mode.container
register: quadlet_file_mode2
- name: Check if existing mode is preserve
assert:
that:
- quad_mode2 is not changed
- quadlet_file_mode2.stat.mode == '0644'
- name: Create same Quadlet for container with only file mode changed
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: container-quadlet-mode
image: alpine
state: quadlet
quadlet_file_mode: '0640'
register: quad_mode3
- name: Check file mode
stat:
path: ~/.config/containers/systemd/container-quadlet-mode.container
register: quadlet_file_mode3
- name: Fail if file is present and with correct mode
assert:
that:
- quad_mode3 is changed
- quadlet_file_mode3.stat.mode == '0640'
- name: Create a Quadlet for container
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"

View file

@ -460,10 +460,11 @@
path: /tmp/customfile.image
register: quadlet_file_custom
- name: Fail if no file is present
- name: Fail if no file is present or wrong mode
assert:
that:
- quadlet_file_custom.stat.exists
- quadlet_file_custom.stat.mode == '0640'
- name: Create quadlet image file
containers.podman.podman_image:
@ -476,6 +477,7 @@
password: pass
validate_certs: false
quadlet_dir: /tmp/
quadlet_file_mode: '0644'
quadlet_options:
- "ImageTag=quay.io/coreos/coreos-installer:12345"
- "AllTags=true"
@ -493,6 +495,11 @@
that:
- quadlet_file.stat.exists
- name: Check quadlet file mode is correct
assert:
that:
- quadlet_file.stat.mode == '0644'
- name: Check for the existence of lines in /tmp/coreos-installer.image
lineinfile:
path: /tmp/coreos-installer.image

View file

@ -709,16 +709,18 @@
state: quadlet
quadlet_dir: /tmp
quadlet_filename: customfile
quadlet_file_mode: '0644'
- name: Check if files exists
stat:
path: /tmp/customfile.network
register: quadlet_file_custom
- name: Fail if no file is present
- name: Fail if no file is present or wrong mode
assert:
that:
- quadlet_file_custom.stat.exists
- quadlet_file_custom.stat.mode == '0644'
- name: Create quadlet network file
containers.podman.podman_network:

View file

@ -138,16 +138,18 @@
state: quadlet
quadlet_dir: /tmp
quadlet_filename: customfile
quadlet_file_mode: '0644'
- name: Check if files exists
stat:
path: /tmp/customfile.kube
register: quadlet_file_custom
- name: Fail if no file is present
- name: Fail if no file is present or wrong mode
assert:
that:
- quadlet_file_custom.stat.exists
- quadlet_file_custom.stat.mode == '0644'
- name: Create a kube quadlet without filename
containers.podman.podman_play:

View file

@ -989,16 +989,18 @@
network: examplenet
quadlet_dir: /tmp
quadlet_filename: customfile
quadlet_file_mode: '0644'
- name: Check if files exists
stat:
path: /tmp/customfile.pod
register: quadlet_file_custom
- name: Fail if no file is present
- name: Fail if no file is present or wrong mode
assert:
that:
- quadlet_file_custom.stat.exists
- quadlet_file_custom.stat.mode == '0644'
- name: Create a Quadlet pod file
containers.podman.podman_pod:

View file

@ -241,16 +241,18 @@
state: quadlet
quadlet_dir: /tmp
quadlet_filename: customfile
quadlet_file_mode: '0644'
- name: Check if files exists
stat:
path: /tmp/customfile.volume
register: quadlet_file_custom
- name: Fail if no file is present
- name: Fail if no file is present or wrong mode
assert:
that:
- quadlet_file_custom.stat.exists
- quadlet_file_custom.stat.mode == '0644'
- name: Create quadlet volume file
containers.podman.podman_volume: