Skip to content

Commit 13fa5c2

Browse files
authored
Ensure Ansible Galaxy installs are up to date (#700)
* diff requirements in ansible * add galaxy tag
1 parent 87bfefc commit 13fa5c2

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ venv
55
*.pyc
66
packer/openhpc2
77
.vscode
8+
requirements.yml.last

ansible/validate.yml

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,50 @@
55
- name: Validate secrets created
66
hosts: localhost
77
gather_facts: false
8+
tags:
9+
- validate
10+
- passwords
811
tasks:
912
- import_role:
1013
name: passwords
1114
tasks_from: validate.yml
1215

16+
- name: Validate Ansible Galaxy installs are up to date
17+
hosts: localhost
18+
gather_facts: false
19+
become: false
20+
tags:
21+
- validate
22+
- galaxy
23+
tasks:
24+
# Can't use e.g. ansible-galaxy {role,collection} list to check installed
25+
# vs desired, as git-installed collections do not provide any metadata for
26+
# the actual installed version.
27+
# So this compares requirements.yml against a .last version produced by a
28+
# successful dev/setup-env.sh run.
29+
- assert:
30+
that: "{{ _requirements_current == _requirements_installed }}"
31+
fail_msg: |
32+
Ansible Galaxy installs are out of date:
33+
34+
{% for req in _requirements_installed | difference(_requirements_current) %}
35+
{{ req }}
36+
{% endfor %}
37+
38+
Run dev/setup-env.sh to fix this.
39+
vars:
40+
# note difference filter requires lists, so need to rearrange yaml from files.
41+
_requirements_path: "{{ appliances_repository_root }}/requirements.yml"
42+
_requirements_current: "{{ (lookup('file', _requirements_path) | from_yaml).values() | flatten }}"
43+
# below produced by dev/setup-env.sh - gives empty list if file is missing:
44+
_requirements_installed: "{{ ((lookup('file', _requirements_path + '.last', errors='ignore') or '{}') | from_yaml ).values() | flatten }}"
45+
1346
- name: Ensure control node is in inventory
1447
hosts: all
1548
gather_facts: false
49+
tags:
50+
- validate
51+
- openhpc
1652
tasks:
1753
- assert:
1854
that: groups['control'] | length
@@ -21,7 +57,9 @@
2157
- name: Validate openhpc configuration
2258
hosts: openhpc
2359
gather_facts: false
24-
tags: openhpc
60+
tags:
61+
- validate
62+
- openhpc
2563
tasks:
2664
- import_role:
2765
name: stackhpc.openhpc
@@ -38,7 +76,9 @@
3876
- name: Validate filebeat configuration
3977
hosts: filebeat
4078
gather_facts: false
41-
tags: filebeat
79+
tags:
80+
- validate
81+
- filebeat
4282
tasks:
4383
- import_role:
4484
name: filebeat
@@ -51,6 +91,7 @@
5191
- grafana
5292
gather_facts: false
5393
tags:
94+
- validate
5495
- openondemand
5596
- openondemand_server
5697
- grafana
@@ -75,15 +116,19 @@
75116

76117
- name: Validate freeipa configuration
77118
hosts: freeipa
78-
tags: freeipa
119+
tags:
120+
- validate
121+
- freeipa
79122
tasks:
80123
- import_role:
81124
name: freeipa
82125
tasks_from: validate.yml
83126

84127
- name: Validate lustre configuration
85128
hosts: lustre
86-
tags: lustre
129+
tags:
130+
- validate
131+
- lustre
87132
tasks:
88133
- import_role:
89134
name: lustre

dev/setup-env.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ ansible --version
3939
# Install or update ansible dependencies ...
4040
ansible-galaxy role install -fr requirements.yml -p ansible/roles
4141
ansible-galaxy collection install -fr requirements.yml -p ansible/collections
42+
cp requirements.yml requirements.yml.last

0 commit comments

Comments
 (0)