Skip to content

Commit b717257

Browse files
authored
Minor molecule cleanups (#401)
* test: refactor molecule preparations (DRY) * test: stub away vault enterprise service The Vault Enterprise binary doesn't start without a license, so we "fake" it. This should make those molecule tests more stable.
1 parent 1495632 commit b717257

File tree

8 files changed

+48
-135
lines changed

8 files changed

+48
-135
lines changed

molecule/almalinux-9/prepare.yml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
---
2-
- name: Prepare controlling host
3-
hosts: localhost
4-
connection: local
5-
6-
tasks:
7-
- name: Prepare CI environment
8-
when: lookup('env', 'CI') is truthy
9-
block:
10-
- name: Install OS packages on controlling host
11-
when: ansible_distribution != 'MacOSX'
12-
ansible.builtin.package:
13-
name: unzip
14-
become: true
15-
16-
- name: Install netaddr dependency on controlling host
17-
ansible.builtin.pip:
18-
name: netaddr
19-
become: false
2+
- name: Common prepare
3+
ansible.builtin.import_playbook: ../prepare.yml
204

215
- name: Prepare AlmaLinux
226
hosts: all
@@ -26,4 +10,4 @@
2610
path: /etc/shadow
2711
mode: '0640'
2812
owner: root
29-
group: root
13+
group: root

molecule/archlinux/prepare.yml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
---
2-
- name: Prepare controlling host
3-
hosts: localhost
4-
connection: local
5-
6-
tasks:
7-
- name: Prepare CI environment
8-
when: lookup('env', 'CI') is truthy
9-
block:
10-
- name: Install OS packages on controlling host
11-
when: ansible_distribution != 'MacOSX'
12-
ansible.builtin.package:
13-
name: unzip
14-
become: true
15-
16-
- name: Install netaddr dependency on controlling host
17-
ansible.builtin.pip:
18-
name: netaddr
19-
become: false
2+
- name: Common prepare
3+
ansible.builtin.import_playbook: ../prepare.yml
204

215
- name: Prepare ArchLinux
226
hosts: all
Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
---
2-
- name: Prepare controlling host
3-
hosts: localhost
4-
connection: local
5-
6-
tasks:
7-
- name: Prepare CI environment
8-
when: lookup('env', 'CI') is truthy
9-
block:
10-
- name: Install OS packages on controlling host
11-
when: ansible_distribution != 'MacOSX'
12-
ansible.builtin.package:
13-
name: unzip
14-
become: true
15-
16-
- name: Install netaddr dependency on controlling host
17-
ansible.builtin.pip:
18-
name: netaddr
19-
become: false
2+
- name: Common prepare
3+
ansible.builtin.import_playbook: ../prepare.yml
204

215
- name: Prepare CentOS
226
hosts: all
@@ -26,4 +10,4 @@
2610
path: /etc/shadow
2711
mode: '0640'
2812
owner: root
29-
group: root
13+
group: root
Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
---
2-
- name: Prepare controlling host
3-
hosts: localhost
4-
connection: local
5-
6-
tasks:
7-
- name: Prepare CI environment
8-
when: lookup('env', 'CI') is truthy
9-
block:
10-
- name: Install OS packages on controlling host
11-
when: ansible_distribution != 'MacOSX'
12-
ansible.builtin.package:
13-
name: unzip
14-
become: true
15-
16-
- name: Install netaddr dependency on controlling host
17-
ansible.builtin.pip:
18-
name: netaddr
19-
become: false
2+
- name: Common prepare
3+
ansible.builtin.import_playbook: ../prepare.yml
204

215
- name: Prepare CentOS
226
hosts: all
@@ -26,4 +10,4 @@
2610
path: /etc/shadow
2711
mode: '0640'
2812
owner: root
29-
group: root
13+
group: root
Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
11
---
2-
- name: Prepare controlling host
3-
hosts: localhost
4-
connection: local
5-
6-
tasks:
7-
- name: Prepare CI environment
8-
when: lookup('env', 'CI') is truthy
9-
block:
10-
- name: Install OS packages on controlling host
11-
when: ansible_distribution != 'MacOSX'
12-
ansible.builtin.package:
13-
name: unzip
14-
become: true
15-
16-
- name: Install netaddr dependency on controlling host
17-
ansible.builtin.pip:
18-
name: netaddr
19-
become: false
20-
212
- name: Prepare Debian
223
hosts: all
234
gather_facts: false
245
tasks:
256
- name: Bootstrap Python
267
ansible.builtin.raw: "test -e /usr/bin/python || apt-get install --update python3 -y"
8+
changed_when: true
9+
10+
- name: Common prepare
11+
ansible.builtin.import_playbook: ../prepare.yml

molecule/debian-13/prepare.yml

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
11
---
2-
- name: Prepare controlling host
3-
hosts: localhost
4-
connection: local
5-
6-
tasks:
7-
- name: Prepare CI environment
8-
when: lookup('env', 'CI') is truthy
9-
block:
10-
- name: Install OS packages on controlling host
11-
when: ansible_distribution != 'MacOSX'
12-
ansible.builtin.package:
13-
name: unzip
14-
become: true
15-
16-
- name: Install netaddr dependency on controlling host
17-
ansible.builtin.pip:
18-
name: netaddr
19-
become: false
20-
212
- name: Prepare Debian
223
hosts: all
234
gather_facts: false
245
tasks:
256
- name: Bootstrap Python
267
ansible.builtin.raw: "test -e /usr/bin/python || apt-get install --update python3 -y"
8+
changed_when: true
9+
10+
- name: Common prepare
11+
ansible.builtin.import_playbook: ../prepare.yml

molecule/prepare.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: Prepare
2+
- name: Prepare host
33
hosts: localhost
44
connection: local
55

@@ -9,11 +9,34 @@
99
block:
1010
- name: Install OS packages on controlling host
1111
when: ansible_distribution != 'MacOSX'
12-
package:
12+
ansible.builtin.package:
1313
name: unzip
1414
become: true
1515

1616
- name: Install netaddr dependency on controlling host
17-
pip:
17+
ansible.builtin.pip:
1818
name: netaddr
1919
become: false
20+
21+
- name: Stub out vault enterprise service
22+
hosts: all
23+
tasks:
24+
- name: Prepare CI environment
25+
when:
26+
- "'enterprise' in lookup('env', 'MOLECULE_SCENARIO_DIRECTORY')"
27+
- ansible_service_mgr == "systemd"
28+
block:
29+
- name: Make sure dropin directory exists
30+
ansible.builtin.file:
31+
path: /etc/systemd/system/vault.service.d/
32+
state: directory
33+
mode: '0755'
34+
35+
- name: Write dropin file
36+
ansible.builtin.copy:
37+
dest: /etc/systemd/system/vault.service.d/fake-service.conf
38+
mode: '0644'
39+
content: |
40+
[Service]
41+
ExecStart=
42+
ExecStart=/usr/bin/sleep 100000

molecule/rockylinux-9/prepare.yml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
---
2-
- name: Prepare controlling host
3-
hosts: localhost
4-
connection: local
5-
6-
tasks:
7-
- name: Prepare CI environment
8-
when: lookup('env', 'CI') is truthy
9-
block:
10-
- name: Install OS packages on controlling host
11-
when: ansible_distribution != 'MacOSX'
12-
ansible.builtin.package:
13-
name: unzip
14-
become: true
15-
16-
- name: Install netaddr dependency on controlling host
17-
ansible.builtin.pip:
18-
name: netaddr
19-
become: false
2+
- name: Common prepare
3+
ansible.builtin.import_playbook: ../prepare.yml
204

215
- name: Prepare Rocky
226
hosts: all
@@ -26,4 +10,4 @@
2610
path: /etc/shadow
2711
mode: '0640'
2812
owner: root
29-
group: root
13+
group: root

0 commit comments

Comments
 (0)