Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7408416
commit 14e89e8
Showing
6 changed files
with
104 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
.vagrant | ||
*.retry | ||
.molecule | ||
**__pycache__** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,20 @@ | ||
--- | ||
sudo: required | ||
language: python | ||
python: "2.7" | ||
|
||
sudo: true | ||
|
||
# Install ansible | ||
addons: | ||
apt: | ||
packages: | ||
- python-pip | ||
|
||
cache: pip | ||
services: | ||
- docker | ||
env: | ||
- ANSIBLE=2.2.3 | ||
- ANSIBLE=2.3.2 | ||
- ANSIBLE=2.4.2 | ||
install: | ||
# Install ansible | ||
- pip install ansible | ||
|
||
# Check ansible version | ||
- ansible --version | ||
|
||
# Create ansible.cfg with correct roles_path | ||
- printf '[defaults]\nroles_path=../' >ansible.cfg | ||
|
||
- pip install ansible==${ANSIBLE} ansible-lint>=3.4.15 molecule==1.25.0 docker git-semver testinfra>=1.7.0 | ||
before_script: | ||
- ansible-lint tests/playbook.yml | ||
script: | ||
# Basic role syntax check | ||
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check | ||
- ansible-playbook tests/test.yml -i tests/inventory --connection=local | ||
- ansible-playbook tests/test.yml -i tests/inventory --connection=local | ||
- > | ||
ansible-playbook tests/test.yml -i tests/inventory --connection=local | ||
| grep -q 'changed=0.*failed=0' | ||
&& (echo 'Idempotence test: pass' && exit 0) | ||
|| (echo 'Idempotence test: fail' && exit 1) | ||
- molecule test | ||
branches: | ||
only: | ||
- master | ||
notifications: | ||
webhooks: https://galaxy.ansible.com/api/v1/notifications/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
for i in ubuntu-molecule:16.04 debian-molecule:9 debian-molecule:8 centos-molecule:7 fedora-molecule:27 | ||
do | ||
docker pull paulfantom/$i & | ||
done | ||
|
||
wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
ansible: | ||
playbook: tests/playbook.yml | ||
driver: | ||
name: docker | ||
verifier: | ||
name: testinfra | ||
dependency: | ||
name: shell | ||
command: ./.travis/images.sh | ||
docker: | ||
build_image: False | ||
containers: | ||
- name: xenial | ||
image: paulfantom/ubuntu-molecule | ||
image_version: 16.04 | ||
privileged: true | ||
volume_mounts: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
- name: stretch | ||
image: paulfantom/debian-molecule | ||
image_version: 9 | ||
privileged: true | ||
volume_mounts: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
- name: jessie | ||
image: paulfantom/debian-molecule | ||
image_version: 8 | ||
privileged: true | ||
volume_mounts: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
- name: centos7 | ||
image: paulfantom/centos-molecule | ||
image_version: 7 | ||
privileged: true | ||
volume_mounts: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
- name: fedora | ||
image: paulfantom/fedora-molecule | ||
image_version: 27 | ||
privileged: true | ||
volume_mounts: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from testinfra.utils.ansible_runner import AnsibleRunner | ||
|
||
testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all') | ||
|
||
|
||
def test_files(host): | ||
dirs = [ | ||
"/etc/caddy", | ||
"/opt/node_exporter" | ||
] | ||
for dir in dirs: | ||
d = host.file(dir) | ||
assert d.exists | ||
assert d.is_directory | ||
|
||
|
||
def test_packages(host) | ||
pkgs = [ | ||
"git" | ||
] | ||
for p in pkgs: | ||
assert host.package(p).is_installed | ||
|
||
|
||
def test_service(host): | ||
s = host.service("caddy") | ||
assert s.is_enabled | ||
assert s.is_running | ||
|
||
|
||
def test_socket(host): | ||
sockets = [ | ||
"tcp://localhost:2020" | ||
] | ||
for socket in sockets: | ||
s = host.socket(socket) | ||
assert s.is_listening |