Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit cb2fca6

Browse files
committed
Use cookiecutter via tox to clone verify playbook
The verify playbook for the functional tests was manually copied to each dir. This change attempts to DRY out the setup of the tests by using cookiecutter to clone the default playbook.
1 parent ed175da commit cb2fca6

File tree

8 files changed

+34
-24
lines changed

8 files changed

+34
-24
lines changed

molecule_goss/cookiecutter/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/verify.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
---
2-
# This is an example playbook to execute goss tests.
3-
# Tests need distributed to the appropriate ansible host/groups
4-
# prior to execution by `goss validate`.
5-
62
{% raw -%}
73
- name: Verify
84
hosts: all

molecule_goss/test/scenarios/docker/centos7/molecule/default/tests/default.yml renamed to molecule_goss/test/scenarios/docker/centos7/molecule/default/tests/test_default.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Molecule managed
2+
13
---
24
file:
35
/etc/hosts:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
file:
3+
/usr/local/bin/goss:
4+
exists: true
5+
owner: root
6+
group: root
7+
mode: "0755"

molecule_goss/test/scenarios/docker/centos7/molecule/default/verify.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
---
2-
# This is an example playbook to execute goss tests.
3-
# Tests need distributed to the appropriate ansible host/groups
4-
# prior to execution by `goss validate`.
5-
62
- name: Verify
73
hosts: all
84
become: true
95
vars:
10-
goss_version: v0.3.7
6+
goss_version: v0.3.13
117
goss_arch: amd64
128
goss_bin: /usr/local/bin/goss
13-
goss_sha256sum: 357f5c7f2e7949b412bce44349cd32ab19eb3947255a8ac805f884cc2c326059.
9+
goss_sha256sum: eb3522ff9682736ff61e2ad114de227de98debcf8a03ca66fcda3917577313e0.
1410
goss_test_directory: /tmp/molecule/goss
1511
goss_format: documentation
1612
tasks:
@@ -21,7 +17,7 @@
2117
sha256sum: "{{ goss_sha256sum }}"
2218
mode: 0755
2319

24-
- name: Create Molecule directory for test files
20+
- name: Create Molecule directory for test files # noqa 208
2521
file:
2622
path: "{{ goss_test_directory }}"
2723
state: directory
@@ -45,19 +41,19 @@
4541
msg: "{{ test_files.files }}"
4642
verbosity: 3
4743

48-
- name: Copy Goss tests to remote
44+
- name: Copy Goss tests to remote # noqa 208
4945
copy:
5046
src: "{{ item.path }}"
5147
dest: "{{ goss_test_directory }}/{{ item.path | basename }}"
5248
with_items:
5349
- "{{ test_files.files }}"
5450

5551
- name: Register test files
56-
shell: "ls {{ goss_test_directory }}/test_*.yml"
52+
shell: "ls {{ goss_test_directory }}/test_*.yml" # noqa 301
5753
register: test_files
5854

5955
- name: Execute Goss tests
60-
command: "{{ goss_bin }} -g {{ item }} validate --format {{ goss_format }}"
56+
command: "{{ goss_bin }} -g {{ item }} validate --format {{ goss_format }}" # noqa 301
6157
register: test_results
6258
with_items: "{{ test_files.stdout_lines }}"
6359
failed_when: false

molecule_goss/test/scenarios/docker/ubuntu18.04/molecule/default/tests/default.yml renamed to molecule_goss/test/scenarios/docker/ubuntu18.04/molecule/default/tests/test_default.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Molecule managed
2+
13
---
24
file:
35
/etc/hosts:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
file:
3+
/usr/local/bin/goss:
4+
exists: true
5+
owner: root
6+
group: root
7+
mode: "0755"

molecule_goss/test/scenarios/docker/ubuntu18.04/molecule/default/verify.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
---
2-
# This is an example playbook to execute goss tests.
3-
# Tests need distributed to the appropriate ansible host/groups
4-
# prior to execution by `goss validate`.
5-
62
- name: Verify
73
hosts: all
84
become: true
95
vars:
10-
goss_version: v0.3.7
6+
goss_version: v0.3.13
117
goss_arch: amd64
128
goss_bin: /usr/local/bin/goss
13-
goss_sha256sum: 357f5c7f2e7949b412bce44349cd32ab19eb3947255a8ac805f884cc2c326059.
9+
goss_sha256sum: eb3522ff9682736ff61e2ad114de227de98debcf8a03ca66fcda3917577313e0.
1410
goss_test_directory: /tmp/molecule/goss
1511
goss_format: documentation
1612
tasks:
@@ -21,7 +17,7 @@
2117
sha256sum: "{{ goss_sha256sum }}"
2218
mode: 0755
2319

24-
- name: Create Molecule directory for test files
20+
- name: Create Molecule directory for test files # noqa 208
2521
file:
2622
path: "{{ goss_test_directory }}"
2723
state: directory
@@ -45,19 +41,19 @@
4541
msg: "{{ test_files.files }}"
4642
verbosity: 3
4743

48-
- name: Copy Goss tests to remote
44+
- name: Copy Goss tests to remote # noqa 208
4945
copy:
5046
src: "{{ item.path }}"
5147
dest: "{{ goss_test_directory }}/{{ item.path | basename }}"
5248
with_items:
5349
- "{{ test_files.files }}"
5450

5551
- name: Register test files
56-
shell: "ls {{ goss_test_directory }}/test_*.yml"
52+
shell: "ls {{ goss_test_directory }}/test_*.yml" # noqa 301
5753
register: test_files
5854

5955
- name: Execute Goss tests
60-
command: "{{ goss_bin }} -g {{ item }} validate --format {{ goss_format }}"
56+
command: "{{ goss_bin }} -g {{ item }} validate --format {{ goss_format }}" # noqa 301
6157
register: test_results
6258
with_items: "{{ test_files.stdout_lines }}"
6359
failed_when: false

tox.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ commands =
2525
ansibledevel: ansible-galaxy install git+https://github.com/ansible-collections/community.general.git
2626
# failsafe as pip may install incompatible dependencies
2727
pip check
28+
# use cookiecutter to deploy the functional test verify playbooks
29+
cookiecutter -f molecule_goss/cookiecutter/ --output-dir molecule_goss/test/scenarios/docker/centos7/ --no-input
30+
cookiecutter -f molecule_goss/cookiecutter/ --output-dir molecule_goss/test/scenarios/docker/ubuntu18.04/ --no-input
2831
# failsafe for preventing changes that may break pytest collection
2932
python -m pytest -p no:cov --collect-only
3033
python -m pytest {posargs:-l}
@@ -49,6 +52,7 @@ deps =
4952
py{36,37,38,39}: molecule[test]
5053
py{36,37,38,39}-{devel}: git+https://github.com/ansible-community/molecule.git@master#egg=molecule[test]
5154
dockerfile: ansible>=2.9.12
55+
cookiecutter
5256
molecule-docker
5357
docker>=4.3.1
5458
passenv =

0 commit comments

Comments
 (0)