Debian Codegraph @

ansible_collections/containers/podman/tests/integration/targets/podman_quadlet_build/tasks/main.yml

raw
1 - name: Test podman_quadlet_build
2 block:
3 - name: Create a Quadlet for build with filename
4 containers.podman.podman_quadlet_build:
5 executable: "{{ test_executable | default('podman') }}"
6 name: localhost/myimage:1.0
7 file: /var/tmp/build/Dockerfile
8 quadlet_dir: /tmp
9 quadlet_filename: customfile
10
11 - name: Check if files exists
12 stat:
13 path: /tmp/customfile.build
14 register: quadlet_file_custom
15
16 - name: Fail if no file is present or wrong mode
17 assert:
18 that:
19 - quadlet_file_custom.stat.exists
20 - quadlet_file_custom.stat.mode == '0640'
21
22 - name: Create quadlet build file
23 containers.podman.podman_quadlet_build:
24 executable: "{{ test_executable | default('podman') }}"
25 name: localhost/myimage:v1.0
26 file: /var/tmp/build/Dockerfile
27 arch: x86_64
28 validate_certs: false
29 quadlet_dir: /tmp/
30 quadlet_file_mode: '0644'
31 quadlet_options:
32 - |
33 [Install]
34 WantedBy=default.target
35
36 - name: Check if files exists
37 stat:
38 path: /tmp/myimage.build
39 register: quadlet_file
40
41 - name: Check output is correct for Quadlet image in /tmp/myimage.build file
42 assert:
43 that:
44 - quadlet_file.stat.exists
45
46 - name: Check quadlet file mode is correct
47 assert:
48 that:
49 - quadlet_file.stat.mode == '0644'
50
51 - name: Check for the existence of lines in /tmp/myimage.build
52 lineinfile:
53 path: /tmp/myimage.build
54 line: "{{ item }}"
55 state: present
56 check_mode: yes
57 register: line_check
58 loop:
59 - "[Build]"
60 - "ImageTag=localhost/myimage:v1.0"
61 - "WantedBy=default.target"
62 - "Arch=x86_64"
63 - "TLSVerify=false"
64 loop_control:
65 label: "{{ item }}"
66
67 - name: Fail the task if any line is not present
68 fail:
69 msg: "The following line is not present in /tmp/myimage.build: {{ item.item }}"
70 when: item.changed
71 loop: "{{ line_check.results }}"
72 loop_control:
73 label: "{{ item.item }}"
74
75 - name: Create quadlet image file - same
76 containers.podman.podman_quadlet_build:
77 executable: "{{ test_executable | default('podman') }}"
78 name: localhost/myimage:v1.0
79 file: /var/tmp/build/Dockerfile
80 arch: x86_64
81 validate_certs: false
82 quadlet_dir: /tmp/
83 quadlet_file_mode: '0644'
84 quadlet_options:
85 - |
86 [Install]
87 WantedBy=default.target
88 register: quad2
89
90 - name: Check if quadlet changed
91 assert:
92 that:
93 - quad2 is not changed
94
95 - name: Create quadlet image file - different
96 containers.podman.podman_quadlet_build:
97 executable: "{{ test_executable | default('podman') }}"
98 name: localhost/myimage:v1.0
99 file: /var/tmp/build/Dockerfile
100 arch: arm64
101 validate_certs: false
102 quadlet_dir: /tmp/
103 quadlet_file_mode: '0644'
104 quadlet_options:
105 - |
106 [Install]
107 WantedBy=default.target
108 register: quad3
109
110 - name: Print diff
111 debug:
112 var: quad3.diff
113
114 - name: Check if changed and diff
115 assert:
116 that:
117 - quad3 is changed
118 - "'arm64' in quad3.diff.after"
119
120 - name: Create quadlet build file with labels and secret
121 containers.podman.podman_quadlet_build:
122 executable: "{{ test_executable | default('podman') }}"
123 name: localhost/labelimage:latest
124 file: /var/tmp/build/Dockerfile
125 labels:
126 maintainer: testuser
127 version: "1.0"
128 secret:
129 - id=mysecret,src=/run/secrets/mysecret
130 quadlet_dir: /tmp/
131
132 - name: Check for correct Label and Secret keys in /tmp/labelimage.build
133 lineinfile:
134 path: /tmp/labelimage.build
135 line: "{{ item }}"
136 state: present
137 check_mode: yes
138 register: label_check
139 loop:
140 - "Label=maintainer=testuser"
141 - "Label=version=1.0"
142 - "Secret=id=mysecret,src=/run/secrets/mysecret"
143 loop_control:
144 label: "{{ item }}"
145
146 - name: Fail if Label or Secret lines are not present
147 fail:
148 msg: "The following line is not present in /tmp/labelimage.build: {{ item.item }}"
149 when: item.changed
150 loop: "{{ label_check.results }}"
151 loop_control:
152 label: "{{ item.item }}"