-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add molecule-based test-setup * fix: linting errors * run tests on circle ci
- Loading branch information
Showing
16 changed files
with
134 additions
and
16 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
version: 2 | ||
jobs: | ||
build: | ||
machine: | ||
docker_layer_caching: true | ||
steps: | ||
- checkout | ||
- run: | ||
name: Run tests | ||
command: make test |
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 @@ | ||
molecule/default/tests/__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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
extends: default | ||
|
||
rules: | ||
braces: | ||
max-spaces-inside: 1 | ||
level: error | ||
brackets: | ||
max-spaces-inside: 1 | ||
level: error | ||
line-length: disable | ||
# NOTE(retr0h): Templates no longer fail this lint rule. | ||
# Uncomment if running old Molecule templates. | ||
# truthy: disable |
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,2 @@ | ||
FROM quay.io/ansible/molecule:latest | ||
RUN sudo pip install docker-py |
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,14 @@ | ||
SHELL=/bin/bash | ||
TESTIMAGENAME=molecule-test | ||
|
||
test: build-testimage | ||
docker run --rm -it \ | ||
-v '${PWD}':/tmp/ansible-role-portainer \ | ||
-v /var/run/docker.sock:/var/run/docker.sock \ | ||
-w /tmp/ansible-role-portainer \ | ||
${TESTIMAGENAME} \ | ||
sudo molecule test | ||
# sudo molecule init scenario -r ${ROLENAME} -s default -d docker | ||
|
||
build-testimage: | ||
docker build -t ${TESTIMAGENAME} . |
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 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: docker | ||
lint: | ||
name: yamllint | ||
platforms: | ||
- name: instance | ||
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest" | ||
command: ${MOLECULE_DOCKER_COMMAND:-""} | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
privileged: true | ||
pre_build_image: true | ||
provisioner: | ||
name: ansible | ||
lint: | ||
name: ansible-lint | ||
scenario: | ||
name: default | ||
test_sequence: | ||
- lint | ||
- destroy | ||
- dependency | ||
- syntax | ||
- create | ||
- prepare | ||
- converge | ||
# - idempotence | ||
- side_effect | ||
- verify | ||
- destroy | ||
verifier: | ||
name: testinfra | ||
lint: | ||
name: flake8 |
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,18 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
roles: | ||
- role: geerlingguy.repo-epel | ||
- role: geerlingguy.pip | ||
- role: geerlingguy.docker | ||
- role: ansible-role-portainer | ||
vars: | ||
pip_install_packages: | ||
- name: docker-py | ||
persistent_data_path: /opt/portainer:/data | ||
company_logo_url: http://example.com/foo.png | ||
portainer_endpoint: "http://{{ inventory_hostname }}:{{ host_port }}/api" | ||
admin_user: admin | ||
admin_password: admin | ||
endpoints: | ||
- {name: portainer-mgmt, url: "unix:///var/run/docker.sock"} |
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 @@ | ||
--- | ||
- src: geerlingguy.repo-epel | ||
version: 1.2.3 | ||
- src: geerlingguy.pip | ||
version: 1.3.0 | ||
- src: geerlingguy.docker | ||
version: 2.5.2 |
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,14 @@ | ||
import os | ||
|
||
import testinfra.utils.ansible_runner | ||
|
||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( | ||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') | ||
|
||
|
||
def test_hosts_file(host): | ||
f = host.file('/etc/hosts') | ||
|
||
assert f.exists | ||
assert f.user == 'root' | ||
assert f.group == 'root' |
Binary file not shown.
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
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
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
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
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
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