Skip to content

Commit

Permalink
Merge pull request #55 from paulfantom/tox
Browse files Browse the repository at this point in the history
[minor] use tox, ansible 2.6, and allow using remote docker host
  • Loading branch information
paulfantom committed Jul 9, 2018
2 parents 075ceb9 + 87ff7bf commit 46b59f7
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
__pycache__/
.molecule
.pytest_cache
.tox

# Ignore retry files
*.retry
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ cache: pip
services:
- docker
env:
- ANSIBLE='ansible>=2.3.0,<2.4.0'
- ANSIBLE='ansible>=2.4.0,<2.5.0'
- ANSIBLE='ansible>=2.5.0,<2.6.0'
- ANSIBLE=2.4
- ANSIBLE=2.5
- ANSIBLE=2.6
install:
- pip install ${ANSIBLE} 'ansible-lint>=3.4.15' 'molecule>=2.12.0' docker git-semver 'testinfra>=1.7.0'
- pip install tox-travis git-semver
script:
- molecule test --all
- tox
deploy:
provider: script
skip_cleanup: true
Expand Down
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Install and configure [docker](https://www.docker.com) containerization platform

## Requirements

- Ansible >= 2.3
- Ansible >= 2.4

## Role Variables

Expand Down Expand Up @@ -52,17 +52,22 @@ Install and configure docker daemon

## Local Testing

The preferred way of locally testing the role is to use Docker and [molecule](https://github.com/metacloud/molecule) (v2.x). You will have to install Docker on your system. See Get started for a Docker package suitable to for your system.
All packages you need to can be specified in one line:
The preferred way of locally testing the role is to use Docker and [molecule](https://github.com/metacloud/molecule) (v2.x). You will have to install Docker on your system. See "Get started" for a Docker package suitable to for your system.
We are using tox to simplify process of testing on multiple ansible versions. To install tox execute:
```sh
pip install ansible 'ansible-lint>=3.4.15' 'molecule>2.12.0' docker 'testinfra>=1.7.0'
pip install tox
```
This should be similar to one listed in `.travis.yml` file in `install` section.
After installing test suit you can run test by running
To run tests on all ansible versions (WARNING: this can take some time)
```sh
molecule test
tox
```
For more information about molecule go to their [docs](https://molecule.readthedocs.io/en/latest/).
To run a custom molecule command on custom environment with only default test scenario:
```sh
tox -e py27-ansible25 -- molecule test -s default
```
For more information about molecule go to their [docs](http://molecule.readthedocs.io/en/latest/).

If you would like to run tests on remote docker host just specify `DOCKER_HOST` variable before running tox tests.

## License

Expand Down
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ galaxy_info:
description: Docker
company: Container Solutions
license: MIT
min_ansible_version: 2.3
min_ansible_version: 2.4
platforms:
- name: EL
versions:
Expand Down
3 changes: 3 additions & 0 deletions molecule/alternative/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ lint:
platforms:
- name: xenial
image: paulfantom/ubuntu-molecule:16.04
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: jessie
image: paulfantom/debian-molecule:8
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: centos7
image: paulfantom/centos-molecule:7
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
Expand Down
3 changes: 3 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ lint:
platforms:
- name: xenial
image: paulfantom/ubuntu-molecule:16.04
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: jessie
image: paulfantom/debian-molecule:8
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: centos7
image: paulfantom/centos-molecule:7
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
Expand Down
5 changes: 5 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
molecule>=2.15.0
docker
ansible-lint>=3.4.0
testinfra>=1.7.0
jmespath
20 changes: 20 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[tox]
minversion = 1.8
envlist = py{27}-ansible{24,25,26}
skipsdist = true

[travis:env]
ANSIBLE=
2.4: ansible24
2.5: ansible25
2.6: ansible26

[testenv]
passenv = *
deps =
-rtest-requirements.txt
ansible24: ansible<2.5
ansible25: ansible<2.6
ansible26: ansible<2.7
commands =
{posargs:molecule test --all --destroy always}

0 comments on commit 46b59f7

Please sign in to comment.