blob: f3b9777c81d6b45b3ca47062d97377d56a2553d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
- name: test tarfile dependency resolution without querying distribution servers
vars:
init_dir: "{{ galaxy_dir }}/offline/setup"
build_dir: "{{ galaxy_dir }}/offline/build"
install_dir: "{{ galaxy_dir }}/offline/collections"
block:
- name: create test directories
file:
path: "{{ item }}"
state: directory
loop:
- "{{ init_dir }}"
- "{{ build_dir }}"
- "{{ install_dir }}"
- name: initialize two collections
command: ansible-galaxy collection init ns.{{ item }} --init-path {{ init_dir }}
loop:
- coll1
- coll2
- name: add one collection as the dependency of the other
lineinfile:
path: "{{ galaxy_dir }}/offline/setup/ns/coll1/galaxy.yml"
regexp: "^dependencies:*"
line: "dependencies: {'ns.coll2': '>=1.0.0'}"
- name: create required runtime.yml
copy:
dest: "{{ galaxy_dir }}/offline/setup/ns/{{ item }}/meta/runtime.yml"
content: "requires_ansible: '>=1.0.0'"
loop:
- coll1
- coll2
- name: build both collections
command: ansible-galaxy collection build {{ init_dir }}/ns/{{ item }}
args:
chdir: "{{ build_dir }}"
loop:
- coll1
- coll2
- name: install the dependency from the tarfile
command: ansible-galaxy collection install {{ build_dir }}/ns-coll2-1.0.0.tar.gz -p {{ install_dir }} -s offline
- name: install the tarfile with the installed dependency
command: ansible-galaxy collection install {{ build_dir }}/ns-coll1-1.0.0.tar.gz -p {{ install_dir }} -s offline
- name: empty the installed collections directory
file:
path: "{{ install_dir }}"
state: "{{ item }}"
loop:
- absent
- directory
- name: edit skeleton with new versions to test upgrading
lineinfile:
path: "{{ galaxy_dir }}/offline/setup/ns/{{ item }}/galaxy.yml"
regexp: "^version:.*$"
line: "version: 2.0.0"
loop:
- coll1
- coll2
- name: build the tarfiles to test upgrading
command: ansible-galaxy collection build {{ init_dir }}/ns/{{ item }}
args:
chdir: "{{ build_dir }}"
loop:
- coll1
- coll2
- name: install the tarfile and its dep with an unreachable server (expected error)
command: ansible-galaxy collection install {{ build_dir }}/ns-coll1-1.0.0.tar.gz -p {{ install_dir }} -s offline
environment:
ANSIBLE_FORCE_COLOR: False
ANSIBLE_NOCOLOR: True
ignore_errors: yes
register: missing_dep
- name: install the tarfile with a missing dependency and --offline
command: ansible-galaxy collection install --offline {{ build_dir }}/ns-coll1-1.0.0.tar.gz -p {{ install_dir }} -s offline
environment:
ANSIBLE_FORCE_COLOR: False
ANSIBLE_NOCOLOR: True
ignore_errors: yes
register: missing_dep_offline
- assert:
that:
- missing_dep.failed
- missing_dep_offline.failed
- galaxy_err in missing_dep.stderr
- missing_err in missing_dep_offline.stderr
vars:
galaxy_err: "ERROR! Unknown error when attempting to call Galaxy at '{{ offline_server }}'"
missing_err: |-
ERROR! Failed to resolve the requested dependencies map. Could not satisfy the following requirements:
* ns.coll2:>=1.0.0 (dependency of ns.coll1:1.0.0)
- name: install the dependency from the tarfile
command: ansible-galaxy collection install {{ build_dir }}/ns-coll2-1.0.0.tar.gz -p {{ install_dir }}
- name: install the tarfile with --offline for dep resolution
command: ansible-galaxy collection install {{ build_dir }}/ns-coll1-1.0.0.tar.gz {{ cli_opts }}
vars:
cli_opts: "--offline -p {{ install_dir }} -s offline"
register: offline_install
- name: upgrade using tarfile with --offline for dep resolution
command: ansible-galaxy collection install {{ build_dir }}/ns-coll1-2.0.0.tar.gz {{ cli_opts }}
vars:
cli_opts: "--offline --upgrade -p {{ install_dir }} -s offline"
register: offline_upgrade
- name: reinstall ns-coll1-1.0.0 to test upgrading the dependency too
command: ansible-galaxy collection install {{ build_dir }}/ns-coll1-1.0.0.tar.gz {{ cli_opts }}
vars:
cli_opts: "--offline --force -p {{ install_dir }} -s offline"
- name: upgrade both collections using tarfiles and --offline
command: ansible-galaxy collection install {{ collections }} {{ cli_opts }}
vars:
collections: "{{ build_dir }}/ns-coll1-2.0.0.tar.gz {{ build_dir }}/ns-coll2-2.0.0.tar.gz"
cli_opts: "--offline --upgrade -s offline"
register: upgrade_all
- assert:
that:
- '"ns.coll1:1.0.0 was installed successfully" in offline_install.stdout'
- '"ns.coll1:2.0.0 was installed successfully" in offline_upgrade.stdout'
- '"ns.coll1:2.0.0 was installed successfully" in upgrade_all.stdout'
- '"ns.coll2:2.0.0 was installed successfully" in upgrade_all.stdout'
always:
- name: clean up test directories
file:
path: "{{ item }}"
state: absent
loop:
- "{{ init_dir }}"
- "{{ build_dir }}"
- "{{ install_dir }}"
|