Skip to content

Commit b74a7e5

Browse files
committed
tox & molecule2
1 parent 65a0d6a commit b74a7e5

File tree

11 files changed

+152
-33
lines changed

11 files changed

+152
-33
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ install:
1111

1212
script:
1313
- find . -name "*.yml" | xargs yamllint
14-
- molecule test
14+
- tox
1515

1616
notifications:
1717
webhooks: https://galaxy.ansible.com/api/v1/notifications/

.yamllint

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extends: default
55
rules:
66
braces:
77
min-spaces-inside: 0
8-
max-spaces-inside: 0
8+
max-spaces-inside: 1
99
min-spaces-inside-empty: -1
1010
max-spaces-inside-empty: -1
1111
brackets:
@@ -39,7 +39,7 @@ rules:
3939
check-multi-line-strings: false
4040
key-duplicates: enable
4141
line-length:
42-
max: 250
42+
max: 500
4343
allow-non-breakable-words: true
4444
allow-non-breakable-inline-mappings: false
4545
new-line-at-end-of-file: enable

molecule.yml

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

molecule/default/Dockerfile.j2

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Molecule managed
2+
3+
{% if item.registry is defined %}
4+
FROM {{ item.registry.url }}/{{ item.image }}
5+
{% else %}
6+
FROM {{ item.image }}
7+
{% endif %}
8+
9+
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
10+
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
11+
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
12+
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
13+
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
14+
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi

molecule/default/INSTALL.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
*******
2+
Docker driver installation guide
3+
*******
4+
5+
Requirements
6+
============
7+
8+
* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html)
9+
* Docker Engine
10+
* docker-py
11+
* docker
12+
13+
Install
14+
=======
15+
16+
Ansible < 2.6
17+
18+
.. code-block:: bash
19+
20+
$ sudo pip install docker-py
21+
22+
Ansible >= 2.6
23+
24+
.. code-block:: bash
25+
26+
$ sudo pip install docker

molecule/default/molecule.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
# Standards: 0.2
3+
dependency:
4+
name: galaxy
5+
driver:
6+
name: docker
7+
lint:
8+
name: yamllint
9+
platforms:
10+
- name: base-git-centos
11+
image: milcom/centos7-systemd
12+
privileged: True
13+
- name: base-git-ubuntu
14+
image: ubuntu
15+
privileged: True
16+
- name: base-git-debian
17+
image: maint/debian-systemd
18+
privileged: True
19+
provisioner:
20+
name: ansible
21+
config_options:
22+
defaults:
23+
remote_tmp: /tmp
24+
playbooks:
25+
converge: playbook.yml
26+
lint:
27+
name: ansible-lint
28+
scenario:
29+
name: default
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Molecule managed
2+
3+
---
4+
file:
5+
/etc/hosts:
6+
exists: true
7+
owner: root
8+
group: root

molecule/default/verify.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
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+
6+
- name: Verify
7+
hosts: all
8+
become: true
9+
vars:
10+
goss_version: v0.3.2
11+
goss_arch: amd64
12+
goss_dst: /usr/local/bin/goss
13+
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
14+
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
15+
goss_test_directory: /tmp
16+
goss_format: documentation
17+
tasks:
18+
- name: Download and install Goss
19+
get_url:
20+
url: "{{ goss_url }}"
21+
dest: "{{ goss_dst }}"
22+
sha256sum: "{{ goss_sha256sum }}"
23+
mode: 0755
24+
register: download_goss
25+
until: download_goss is succeeded
26+
retries: 3
27+
28+
- name: Copy Goss tests to remote
29+
copy:
30+
src: "{{ item }}"
31+
dest: "{{ goss_test_directory }}/{{ item | basename }}"
32+
with_fileglob:
33+
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_*.yml"
34+
35+
- name: Register test files
36+
shell: "ls {{ goss_test_directory }}/test_*.yml"
37+
register: test_files
38+
39+
- name: Execute Goss tests
40+
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
41+
register: test_results
42+
with_items: "{{ test_files.stdout_lines }}"
43+
44+
- name: Display details about the Goss results
45+
debug:
46+
msg: "{{ item.stdout_lines }}"
47+
with_items: "{{ test_results.results }}"
48+
49+
- name: Fail when tests fail
50+
fail:
51+
msg: "Goss failed to validate"
52+
when: item.rc != 0
53+
with_items: "{{ test_results.results }}"

requirements.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# these python extensions are required for testing
2-
ansible==2.3.2
3-
yamllint==1.8.1
4-
ansible-lint==3.4.15
5-
molecule==1.25.1
1+
tox
2+
molecule
63
docker

0 commit comments

Comments
 (0)