Skip to content

Commit a9ae993

Browse files
Better molecule tests
1 parent fbd8a0f commit a9ae993

21 files changed

+261
-363
lines changed

molecule/default/Dockerfile.j2

Lines changed: 0 additions & 31 deletions
This file was deleted.

molecule/default/INSTALL.rst

Lines changed: 0 additions & 22 deletions
This file was deleted.

molecule/default/converge.yml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,15 @@
11
---
2-
- name: Install
2+
- name: Install Repo runner
33
user: ansible
44
hosts: all
55
gather_facts: yes
66
become: yes
77
vars:
88
- runner_user: ansible
99
- github_repo: ansible-github_actions_runner-testrepo
10-
- github_account: monolithprojects
11-
- runner_version: "latest"
12-
- reinstall_runner: yes
13-
roles:
14-
- robertdebock.epel
15-
- ansible-github_actions_runner
16-
17-
- name: Idempotence test
18-
user: ansible
19-
hosts: all
20-
become: yes
21-
gather_facts: yes
22-
vars:
23-
- runner_user: ansible
24-
- github_repo: ansible-github_actions_runner-testrepo
25-
- github_account: monolithprojects
10+
- github_account: monolithprojects-testorg
2611
- runner_version: "latest"
12+
- runner_labels: "'test1','test2'"
2713
roles:
2814
- robertdebock.epel
2915
- ansible-github_actions_runner

molecule/default/molecule.yml

Lines changed: 16 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,19 @@
11
---
2-
driver:
3-
name: docker
2+
provisioner:
3+
name: ansible
4+
playbooks:
5+
converge: converge.yml
6+
cleanup: cleanup.yml
7+
verify: verify.yml
8+
dependency:
9+
name: galaxy
410
lint: |
5-
yamllint .
611
ansible-lint
12+
driver:
13+
name: docker
714
platforms:
8-
- name: CentOS7
9-
image: monolithprojects/systemd-centos7:latest
10-
command: /sbin/init
11-
tmpfs:
12-
- /run
13-
- /tmp
14-
volumes:
15-
- /sys/fs/cgroup:/sys/fs/cgroup:ro
16-
privileged: yes
17-
pre_build_image: yes
18-
- name: CentOS8
19-
image: monolithprojects/systemd-centos8:latest
20-
command: /sbin/init
21-
tmpfs:
22-
- /run
23-
- /tmp
24-
volumes:
25-
- /sys/fs/cgroup:/sys/fs/cgroup:ro
26-
privileged: yes
27-
pre_build_image: yes
28-
- name: Fedora32
29-
image: monolithprojects/systemd-fedora32:latest
30-
command: /sbin/init
31-
tmpfs:
32-
- /run
33-
- /tmp
34-
volumes:
35-
- /sys/fs/cgroup:/sys/fs/cgroup:ro
36-
privileged: yes
37-
pre_build_image: yes
38-
- name: Fedora33
39-
image: monolithprojects/systemd-fedora33:latest
15+
- name: "${os:-ubuntu16}-${tag:-latest}"
16+
image: "${namespace:-monolithprojects}/systemd-${os:-ubuntu16}:${tag:-latest}"
4017
command: /sbin/init
4118
tmpfs:
4219
- /run
@@ -45,80 +22,18 @@ platforms:
4522
- /sys/fs/cgroup:/sys/fs/cgroup:ro
4623
privileged: yes
4724
pre_build_image: yes
48-
- name: Ubuntu16
49-
image: monolithprojects/systemd-ubuntu16:latest
50-
command: /sbin/init
51-
tmpfs:
52-
- /run
53-
- /tmp
54-
volumes:
55-
- /sys/fs/cgroup:/sys/fs/cgroup:ro
56-
privileged: yes
57-
pre_build_image: yes
58-
- name: Ubuntu18
59-
image: monolithprojects/systemd-ubuntu18:latest
60-
command: /sbin/init
61-
tmpfs:
62-
- /run
63-
- /tmp
64-
volumes:
65-
- /sys/fs/cgroup:/sys/fs/cgroup:ro
66-
privileged: yes
67-
pre_build_image: yes
68-
- name: Ubuntu20
69-
image: monolithprojects/systemd-ubuntu20:latest
70-
command: /sbin/init
71-
tmpfs:
72-
- /run
73-
- /tmp
74-
volumes:
75-
- /sys/fs/cgroup:/sys/fs/cgroup:ro
76-
privileged: yes
77-
pre_build_image: yes
78-
- name: Debian9
79-
image: monolithprojects/systemd-debian9:latest
80-
command: /sbin/init
81-
tmpfs:
82-
- /run
83-
- /tmp
84-
volumes:
85-
- /sys/fs/cgroup:/sys/fs/cgroup:ro
86-
privileged: yes
87-
pre_build_image: yes
88-
- name: Debian10
89-
image: monolithprojects/systemd-debian10:latest
90-
command: /sbin/init
91-
tmpfs:
92-
- /run
93-
- /tmp
94-
volumes:
95-
- /sys/fs/cgroup:/sys/fs/cgroup:ro
96-
privileged: yes
97-
pre_build_image: yes
98-
provisioner:
99-
name: ansible
100-
playbooks:
101-
converge: converge.yml
102-
cleanup: cleanup.yml
103-
log: false
10425
verifier:
105-
name: testinfra
106-
directory: tests
107-
dependency:
108-
name: galaxy
109-
options:
110-
ignore-certs: True
111-
ignore-errors: True
26+
name: ansible
11227
scenario:
11328
name: default
11429
test_sequence:
11530
- dependency
116-
- lint
31+
# - lint
11732
- destroy
11833
- syntax
11934
- create
120-
# - prepare
12135
- converge
122-
# - idempotence
36+
- idempotence
37+
- verify
12338
- cleanup
12439
- destroy

molecule/default/requirements.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
---
22
- role: robertdebock.epel
3-
version: 2.5.4
3+
version: 3.0.1

molecule/default/tests/test_default.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

molecule/default/verify.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
- name: validate Repo runners
3+
user: ansible
4+
hosts: all
5+
gather_facts: yes
6+
become: yes
7+
vars:
8+
- runner_user: ansible
9+
- github_repo: ansible-github_actions_runner-testrepo
10+
- github_account: monolithprojects
11+
- github_api_url: "https://api.github.com"
12+
- access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}"
13+
- runner_name: "{{ ansible_hostname }}"
14+
15+
tasks:
16+
- name: Check currently registered runners
17+
uri:
18+
url: "{{ github_api_url }}/repos/{{ github_owner | default(github_account) }}/{{ github_repo }}/actions/runners"
19+
headers:
20+
Authorization: "token {{ access_token }}"
21+
Accept: "application/vnd.github.v3+json"
22+
method: GET
23+
status_code: 200
24+
force_basic_auth: yes
25+
register: registered_runners
26+
27+
- name: Check Runner
28+
assert:
29+
that:
30+
- runner_name in registered_runners.json.runners|map(attribute='name')|list
31+
- registered_runners.json.runners|map(attribute='status') == ["online"]
32+
quiet: true
33+
34+
- debug:
35+
var: registered_runners.json.runners|map(attribute='name')
36+
37+
- debug:
38+
var: registered_runners.json.runners|map(attribute='status')

molecule/organization/cleanup.yml renamed to molecule/org/cleanup.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
become: yes
66
vars:
77
- runner_user: ansible
8-
- github_account: monolithprojects-testorg
8+
- github_repo: ansible-github_actions_runner-testrepo
9+
- github_account: monolithprojects
910
- runner_state: absent
10-
- runner_org: yes
1111
roles:
1212
- ansible-github_actions_runner

molecule/org/converge.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
- name: Install Org Runner
3+
user: ansible
4+
hosts: all
5+
become: yes
6+
vars:
7+
- runner_user: ansible
8+
- github_account: monolithprojects-testorg
9+
- runner_org: yes
10+
- runner_state: "stopped"
11+
- runner_version: "2.274.2"
12+
roles:
13+
- robertdebock.epel
14+
- ansible-github_actions_runner

molecule/org/molecule.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
provisioner:
3+
name: ansible
4+
playbooks:
5+
converge: converge.yml
6+
cleanup: cleanup.yml
7+
verify: verify.yml
8+
dependency:
9+
name: galaxy
10+
lint: |
11+
yamllint .
12+
ansible-lint
13+
driver:
14+
name: docker
15+
platforms:
16+
- name: "${os:-ubuntu16}-${tag:-latest}"
17+
image: "${namespace:-monolithprojects}/systemd-${os:-ubuntu16}:${tag:-latest}"
18+
command: /sbin/init
19+
tmpfs:
20+
- /run
21+
- /tmp
22+
volumes:
23+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
24+
privileged: yes
25+
pre_build_image: yes
26+
verifier:
27+
name: ansible
28+
scenario:
29+
name: org
30+
test_sequence:
31+
- dependency
32+
- lint
33+
- destroy
34+
- syntax
35+
- create
36+
- converge
37+
- idempotence
38+
- verify
39+
- cleanup
40+
- destroy

0 commit comments

Comments
 (0)