Debian Codegraph @

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

raw
1 ---
2 - name: Test podman import
3 block:
4 - name: Start container
5 containers.podman.podman_container:
6 executable: "{{ test_executable | default('podman') }}"
7 name: container
8 image: alpine:3.7
9 state: started
10 command: sleep 1d
11
12 - name: Export container
13 containers.podman.podman_export:
14 executable: "{{ test_executable | default('podman') }}"
15 container: container
16 dest: /tmp/container
17
18 - name: Check file
19 stat:
20 path: /tmp/container
21 register: img
22
23 - name: Check it's saved
24 assert:
25 that:
26 - img.stat.exists
27
28 - name: Import container
29 containers.podman.podman_import:
30 executable: "{{ test_executable | default('podman') }}"
31 src: /tmp/container
32 register: test
33
34 - name: Check it's imported
35 assert:
36 that:
37 - test is success
38 - test.image["Id"] != ''
39
40 - name: Import container with commit message
41 containers.podman.podman_import:
42 executable: "{{ test_executable | default('podman') }}"
43 src: /tmp/container
44 commit_message: 'Test in CI'
45 register: test1
46
47 - name: Check it's imported with commit message
48 assert:
49 that:
50 - test1.image.Comment == "Test in CI"
51
52 - name: Import container with changes
53 containers.podman.podman_import:
54 executable: "{{ test_executable | default('podman') }}"
55 src: /tmp/container
56 change:
57 - "User": "someuser"
58 - "CMD": "/bin/nonsh"
59 register: test2
60
61 - name: Check it's imported with changes
62 assert:
63 that:
64 - test2.image.User == 'someuser'
65 - test2.image["Config"]["Cmd"][2] == "/bin/nonsh"
66
67 - name: Test podman volume import
68 block:
69 - name: Start container
70 containers.podman.podman_container:
71 executable: "{{ test_executable | default('podman') }}"
72 name: container
73 image: alpine:3.7
74 state: started
75 volume:
76 - "volume:/test"
77 command: touch /test/test_file
78
79 - name: Export volume
80 containers.podman.podman_export:
81 executable: "{{ test_executable | default('podman') }}"
82 volume: volume
83 dest: /tmp/volume
84
85 - name: Check file
86 stat:
87 path: /tmp/volume
88 register: vlm
89
90 - name: Check it's exported
91 assert:
92 that:
93 - vlm.stat.exists
94
95 - name: delete container
96 containers.podman.podman_container:
97 state: absent
98 name: container
99
100 - name: delete volume
101 containers.podman.podman_volume:
102 state: absent
103 name: volume
104
105 # podman needs a volume to exist before import
106 - name: creating volume before importing
107 containers.podman.podman_volume:
108 name: volume
109 state: present
110
111 - name: Import volume
112 containers.podman.podman_import:
113 executable: "{{ test_executable | default('podman') }}"
114 src: /tmp/volume
115 volume: "volume"
116 register: volume
117
118 - name: Check it's imported
119 assert:
120 that:
121 - volume is success
122
123 - name: Check file is there
124 containers.podman.podman_container:
125 executable: "{{ test_executable | default('podman') }}"
126 name: container
127 image: alpine:3.7
128 state: started
129 volume:
130 - "volume:/test"
131 command: ls /test/test_file
132 register: ls
133
134 - name: Check it's imported
135 assert:
136 that:
137 - ls is success
138
139 always:
140 - name: Remove container
141 containers.podman.podman_container:
142 executable: "{{ test_executable | default('podman') }}"
143 name: container
144 state: absent
145 - name: Remove volume
146 containers.podman.podman_volume:
147 executable: "{{ test_executable | default('podman') }}"
148 name: volume
149 state: absent