Debian Codegraph @

test/integration/targets/ansible-galaxy-collection/tasks/download.yml

raw
1 ---
2 - name: create test download dir
3 file:
4 path: '{{ galaxy_dir }}/download'
5 state: directory
6
7 - name: download collection with multiple dependencies with --no-deps
8 command: ansible-galaxy collection download parent_dep.parent_collection:1.0.0 --no-deps -s galaxy_ng {{ galaxy_verbosity }}
9 register: download_collection
10 args:
11 chdir: '{{ galaxy_dir }}/download'
12
13 - name: get result of download collection with multiple dependencies
14 find:
15 path: '{{ galaxy_dir }}/download/collections'
16 file_type: file
17 register: download_collection_actual
18
19 - name: assert download collection with multiple dependencies --no-deps
20 assert:
21 that:
22 - >-
23 "Downloading collection 'parent_dep.parent_collection:1.0.0' to '/tmp/"
24 in download_collection.stdout
25 - >-
26 "Downloading collection 'child_dep.child_collection"
27 not in download_collection.stdout
28 - >-
29 "Downloading collection 'child_dep.child_dep2"
30 not in download_collection.stdout
31 - download_collection_actual.examined == 2
32 - download_collection_actual.matched == 2
33 - (download_collection_actual.files[0].path | basename) in ['requirements.yml', 'parent_dep-parent_collection-1.0.0.tar.gz']
34 - (download_collection_actual.files[1].path | basename) in ['requirements.yml', 'parent_dep-parent_collection-1.0.0.tar.gz']
35
36 - name: download collection with multiple dependencies
37 command: ansible-galaxy collection download parent_dep.parent_collection:1.0.0 -s galaxy_ng {{ galaxy_verbosity }}
38 register: download_collection
39 args:
40 chdir: '{{ galaxy_dir }}/download'
41
42 - name: get result of download collection with multiple dependencies
43 find:
44 path: '{{ galaxy_dir }}/download/collections'
45 file_type: file
46 register: download_collection_actual
47
48 - name: assert download collection with multiple dependencies
49 assert:
50 that:
51 - '"Downloading collection ''parent_dep.parent_collection:1.0.0'' to" in download_collection.stdout'
52 - '"Downloading collection ''child_dep.child_collection:0.9.9'' to" in download_collection.stdout'
53 - '"Downloading collection ''child_dep.child_dep2:1.2.2'' to" in download_collection.stdout'
54 - download_collection_actual.examined == 4
55 - download_collection_actual.matched == 4
56 - (download_collection_actual.files[0].path | basename) in ['requirements.yml', 'child_dep-child_dep2-1.2.2.tar.gz', 'child_dep-child_collection-0.9.9.tar.gz', 'parent_dep-parent_collection-1.0.0.tar.gz']
57 - (download_collection_actual.files[1].path | basename) in ['requirements.yml', 'child_dep-child_dep2-1.2.2.tar.gz', 'child_dep-child_collection-0.9.9.tar.gz', 'parent_dep-parent_collection-1.0.0.tar.gz']
58 - (download_collection_actual.files[2].path | basename) in ['requirements.yml', 'child_dep-child_dep2-1.2.2.tar.gz', 'child_dep-child_collection-0.9.9.tar.gz', 'parent_dep-parent_collection-1.0.0.tar.gz']
59 - (download_collection_actual.files[3].path | basename) in ['requirements.yml', 'child_dep-child_dep2-1.2.2.tar.gz', 'child_dep-child_collection-0.9.9.tar.gz', 'parent_dep-parent_collection-1.0.0.tar.gz']
60
61 - name: test install of download requirements file
62 command: ansible-galaxy collection install -r requirements.yml -p '{{ galaxy_dir }}/download' {{ galaxy_verbosity }}
63 args:
64 chdir: '{{ galaxy_dir }}/download/collections'
65 register: install_download
66
67 - name: get result of test install of download requirements file
68 slurp:
69 path: '{{ galaxy_dir }}/download/ansible_collections/{{ collection.namespace }}/{{ collection.name }}/MANIFEST.json'
70 register: install_download_actual
71 loop_control:
72 loop_var: collection
73 loop:
74 - namespace: parent_dep
75 name: parent_collection
76 - namespace: child_dep
77 name: child_collection
78 - namespace: child_dep
79 name: child_dep2
80
81 - name: assert test install of download requirements file
82 assert:
83 that:
84 - '"Installing ''parent_dep.parent_collection:1.0.0'' to" in install_download.stdout'
85 - '"Installing ''child_dep.child_collection:0.9.9'' to" in install_download.stdout'
86 - '"Installing ''child_dep.child_dep2:1.2.2'' to" in install_download.stdout'
87 - (install_download_actual.results[0].content | b64decode | from_json).collection_info.version == '1.0.0'
88 - (install_download_actual.results[1].content | b64decode | from_json).collection_info.version == '0.9.9'
89 - (install_download_actual.results[2].content | b64decode | from_json).collection_info.version == '1.2.2'
90
91 - name: create test requirements file for download
92 copy:
93 content: |
94 collections:
95 - name: namespace1.name1
96 version: 1.1.0-beta.1
97
98 dest: '{{ galaxy_dir }}/download/download.yml'
99
100 - name: download collection with req to custom dir
101 command: ansible-galaxy collection download -r '{{ galaxy_dir }}/download/download.yml' -s galaxy_ng -p '{{ galaxy_dir }}/download/collections-custom' {{ galaxy_verbosity }}
102 register: download_req_custom_path
103
104 - name: get result of download collection with req to custom dir
105 find:
106 path: '{{ galaxy_dir }}/download/collections-custom'
107 file_type: file
108 register: download_req_custom_path_actual
109
110 - name: assert download collection with multiple dependencies
111 assert:
112 that:
113 - '"Downloading collection ''namespace1.name1:1.1.0-beta.1'' to" in download_req_custom_path.stdout'
114 - download_req_custom_path_actual.examined == 2
115 - download_req_custom_path_actual.matched == 2
116 - (download_req_custom_path_actual.files[0].path | basename) in ['requirements.yml', 'namespace1-name1-1.1.0-beta.1.tar.gz']
117 - (download_req_custom_path_actual.files[1].path | basename) in ['requirements.yml', 'namespace1-name1-1.1.0-beta.1.tar.gz']
118
119 # https://github.com/ansible/ansible/issues/68186
120 - name: create test requirements file without roles and collections
121 copy:
122 content: |
123 collections:
124 roles:
125
126 dest: '{{ galaxy_dir }}/download/no_roles_no_collections.yml'
127
128 - name: install collection with requirements
129 command: ansible-galaxy collection install -r '{{ galaxy_dir }}/download/no_roles_no_collections.yml' {{ galaxy_verbosity }}
130 register: install_no_requirements
131
132 - name: assert install collection with no roles and no collections in requirements
133 assert:
134 that:
135 - '"Skipping install, no requirements found" in install_no_requirements.stdout'
136
137 - name: Test downloading a tar.gz collection artifact
138 block:
139
140 - name: get result of build basic collection on current directory
141 stat:
142 path: '{{ galaxy_dir }}/scratch/ansible_test/my_collection/ansible_test-my_collection-1.0.0.tar.gz'
143 register: result
144
145 - name: create default skeleton
146 command: ansible-galaxy collection init ansible_test.my_collection {{ galaxy_verbosity }}
147 args:
148 chdir: '{{ galaxy_dir }}/scratch'
149 when: not result.stat.exists
150
151 - name: build the tar.gz
152 command: ansible-galaxy collection build {{ galaxy_verbosity }}
153 args:
154 chdir: '{{ galaxy_dir }}/scratch/ansible_test/my_collection'
155 when: not result.stat.exists
156
157 - name: download a tar.gz file
158 command: ansible-galaxy collection download '{{ galaxy_dir }}/scratch/ansible_test/my_collection/ansible_test-my_collection-1.0.0.tar.gz'
159 args:
160 chdir: '{{ galaxy_dir }}/download'
161 register: download_collection
162
163 - name: get result of downloaded tar.gz
164 stat:
165 path: '{{ galaxy_dir }}/download/collections/ansible_test-my_collection-1.0.0.tar.gz'
166 register: download_collection_actual
167
168 - assert:
169 that:
170 - '"Downloading collection ''ansible_test.my_collection:1.0.0'' to" in download_collection.stdout'
171 - download_collection_actual.stat.exists
172
173 - block:
174 - name: create skeleton collection for trailing slash test
175 command: ansible-galaxy collection init trailing_dir.name --init-path "{{ galaxy_dir }}"
176
177 - name: install collection with directory source and trailing slash - {{ test_id }}
178 command: ansible-galaxy collection download '{{ galaxy_dir }}/trailing_dir/name/' {{ galaxy_verbosity }}
179 args:
180 chdir: '{{ galaxy_dir }}/download'
181 register: download_dir_slash
182
183 - name: get result of install collections with with trailing slash - {{ test_id }}
184 stat:
185 path: '{{ galaxy_dir }}/download/collections/trailing_dir-name-1.0.0.tar.gz'
186 register: download_dir_slash_actual
187
188 - name: assert install collections with with trailing slash - {{ test_id }}
189 assert:
190 that:
191 - '"Downloading collection ''trailing_dir.name:1.0.0'' to" in download_dir_slash.stdout'
192 - download_dir_slash_actual.stat.exists
193
194 always:
195 - name: remove trailing dir skeleton
196 file:
197 path: '{{ galaxy_dir }}/trailing_dir'
198 state: absent
199
200 - name: remove test download dir
201 file:
202 path: '{{ galaxy_dir }}/download'
203 state: absent