|
7 | 7 | vars:
|
8 | 8 | podman_use_copr: false # disable copr for CI testing
|
9 | 9 | podman_fail_if_too_old: false
|
| 10 | + __json_secret_data: '{"test": "json"}' |
10 | 11 | __secret_password_env: "{{ lookup('env', 'SYSTEM_ROLES_PODMAN_PASSWORD') }}"
|
11 | 12 | __podman_secrets:
|
12 | 13 | - name: mysql_container_root_password
|
13 | 14 | state: present
|
14 | 15 | skip_existing: true
|
15 | 16 | data: "{{ (__secret_password_env | length > 0) |
|
16 | 17 | ternary(__secret_password_env, mysql_container_root_password) }}"
|
| 18 | + - name: json_secret |
| 19 | + state: present |
| 20 | + data: "{{ __json_secret_data | string }}" |
17 | 21 | __podman_quadlet_specs:
|
18 | 22 | - name: quadlet-basic
|
19 | 23 | type: network
|
|
34 | 38 | Volume: quadlet-basic-mysql.volume:/var/lib/mysql
|
35 | 39 | Network: quadlet-basic.network
|
36 | 40 | # Once 4.5 is released change this line to use the quadlet Secret key
|
37 |
| - PodmanArgs: "--secret=mysql_container_root_password,type=env,\ |
38 |
| - target=MYSQL_ROOT_PASSWORD" |
| 41 | + PodmanArgs: >- |
| 42 | + --secret=mysql_container_root_password,type=env,target=MYSQL_ROOT_PASSWORD |
| 43 | + --secret=json_secret,type=mount,target=/tmp/test.json |
39 | 44 | Environment:
|
40 | 45 | - FOO=/bin/busybox-extras
|
41 | 46 | - BAZ=test
|
|
120 | 125 | - quadlet-basic.network
|
121 | 126 | - quadlet-basic-mysql.volume
|
122 | 127 |
|
| 128 | + - name: Ensure linger |
| 129 | + stat: |
| 130 | + path: /var/lib/systemd/linger/user_quadlet_basic |
| 131 | + register: __stat |
| 132 | + failed_when: not __stat.stat.exists |
| 133 | + |
123 | 134 | # must clean up networks last - cannot remove a network
|
124 | 135 | # in use by a container
|
125 | 136 | - name: Cleanup user
|
|
135 | 146 | (__podman_quadlet_specs | selectattr('type', 'match', '^network$') |
|
136 | 147 | list)) | map('combine', __absent) | list }}"
|
137 | 148 |
|
138 |
| - - name: Set secret var for root testing |
139 |
| - set_fact: |
140 |
| - __root_podman_secrets: "{{ __podman_secrets + __json_secret }}" |
141 |
| - __root_json_data: '{"test": "json"}' |
142 |
| - vars: |
143 |
| - __json_secret: |
144 |
| - - name: json_secret |
145 |
| - state: present |
146 |
| - data: '{"test": "json"}' |
147 |
| - no_log: true |
148 |
| - |
149 |
| - - name: Set container vars for root testing |
150 |
| - set_fact: |
151 |
| - __root_podman_quadlet_specs: "{{ __podman_quadlet_specs + |
152 |
| - __json_container }}" |
153 |
| - vars: |
154 |
| - __json_container: |
155 |
| - - name: json_container |
156 |
| - type: container |
157 |
| - Install: |
158 |
| - WantedBy: default.target |
159 |
| - Container: |
160 |
| - Image: "{{ mysql_image }}" |
161 |
| - ContainerName: json_container |
162 |
| - # Once 4.5 is released change this line to use the quadlet Secret |
163 |
| - PodmanArgs: "--secret=mysql_container_root_password,type=env,\ |
164 |
| - target=MYSQL_ROOT_PASSWORD --secret=json_secret,type=mount,\ |
165 |
| - target=/tmp/test.json" |
| 149 | + - name: Ensure no linger |
| 150 | + stat: |
| 151 | + path: /var/lib/systemd/linger/user_quadlet_basic |
| 152 | + register: __stat |
| 153 | + failed_when: __stat.stat.exists |
166 | 154 |
|
167 | 155 | - name: Run the role - root
|
168 | 156 | include_role:
|
169 | 157 | name: linux-system-roles.podman
|
170 | 158 | vars:
|
171 |
| - podman_secrets: "{{ __root_podman_secrets }}" |
172 |
| - podman_quadlet_specs: "{{ __root_podman_quadlet_specs }}" |
| 159 | + podman_secrets: "{{ __podman_secrets }}" |
| 160 | + podman_quadlet_specs: "{{ __podman_quadlet_specs }}" |
173 | 161 |
|
174 | 162 | - name: Check files
|
175 | 163 | command: cat {{ __dir }}/{{ item }}
|
|
182 | 170 | - quadlet-basic-mysql.volume
|
183 | 171 |
|
184 | 172 | - name: Check JSON
|
185 |
| - command: podman exec json_container cat /tmp/test.json |
| 173 | + command: podman exec quadlet-basic-mysql cat /tmp/test.json |
186 | 174 | register: __result
|
187 |
| - failed_when: __result.stdout != __root_json_data |
| 175 | + failed_when: __result.stdout != __json_secret_data |
188 | 176 | changed_when: false
|
189 | 177 |
|
190 | 178 | - name: Cleanup system - root
|
191 | 179 | include_role:
|
192 | 180 | name: linux-system-roles.podman
|
193 | 181 | vars:
|
194 | 182 | __absent: {"state":"absent"}
|
195 |
| - podman_secrets: "{{ __root_podman_secrets | map('combine', __absent) | |
| 183 | + podman_secrets: "{{ __podman_secrets | map('combine', __absent) | |
196 | 184 | list }}"
|
197 |
| - podman_quadlet_specs: "{{ ((__root_podman_quadlet_specs | |
| 185 | + podman_quadlet_specs: "{{ ((__podman_quadlet_specs | |
198 | 186 | rejectattr('type', 'match', '^network$') | list) +
|
199 |
| - (__root_podman_quadlet_specs | |
| 187 | + (__podman_quadlet_specs | |
200 | 188 | selectattr('type', 'match', '^network$') | list)) |
|
201 | 189 | map('combine', __absent) | list }}"
|
0 commit comments