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

Commit 0d80168

Browse files
authored
Merge pull request #67 from cloudalchemy/tox
[minor] use tox, ansible 2.6, and allow using remote docker host
2 parents 03fab02 + a8e6901 commit 0d80168

File tree

8 files changed

+66
-14
lines changed

8 files changed

+66
-14
lines changed

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
*.swp
22
*.swo
33
*.idea
4+
.vagrant/
5+
*.retry
6+
*.log
7+
*.swp
8+
*.swo
9+
*.idea
410
.molecule
511
.cache
6-
*.kate-swp
712
__pycache__/
13+
.pytest_cache
14+
.tox

.travis.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1+
---
12
sudo: required
23
language: python
34
cache: pip
45
services:
56
- docker
67
env:
7-
- ANSIBLE='ansible>=2.3.0,<2.4.0'
8-
- ANSIBLE='ansible>=2.4.0,<2.5.0'
9-
- ANSIBLE='ansible>=2.5.0,<2.6.0'
8+
- ANSIBLE=2.4
9+
- ANSIBLE=2.5
10+
- ANSIBLE=2.6
11+
matrix:
12+
fast_finish: true
1013
install:
11-
- pip install ${ANSIBLE} 'ansible-lint>=3.4.15' 'molecule>=2.13.0' docker git-semver 'testinfra>=1.7.0'
14+
- pip install tox-travis git-semver
1215
script:
13-
- molecule test --all
16+
- tox
1417
deploy:
1518
provider: script
1619
skip_cleanup: true

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Provision and manage [grafana](https://github.com/grafana/grafana) - platform fo
1212

1313
## Requirements
1414

15-
- Ansible >= 2.3
15+
- Ansible >= 2.4
1616
- libselinux-python on deployer host (only when deployer machine has SELinux)
1717

1818
## Role Variables
@@ -93,18 +93,23 @@ We provide demo site for full monitoring solution based on prometheus and grafan
9393
9494
## Local Testing
9595
96-
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.
97-
All packages you need to can be specified in one line:
96+
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.
97+
We are using tox to simplify process of testing on multiple ansible versions. To install tox execute:
9898
```sh
99-
pip install ansible 'ansible-lint>=3.4.15' 'molecule>2.13.0' docker 'testinfra>=1.7.0' jmespath
99+
pip install tox
100100
```
101-
This should be similar to one listed in `.travis.yml` file in `install` section.
102-
After installing test suit you can run test by running
101+
To run tests on all ansible versions (WARNING: this can take some time)
103102
```sh
104-
molecule test --all
103+
tox
104+
```
105+
To run a custom molecule command on custom environment with only default test scenario:
106+
```sh
107+
tox -e py27-ansible25 -- molecule test -s default
105108
```
106109
For more information about molecule go to their [docs](http://molecule.readthedocs.io/en/latest/).
107110

111+
If you would like to run tests on remote docker host just specify `DOCKER_HOST` variable before running tox tests.
112+
108113
## Travis CI
109114

110115
Combining molecule and travis CI allows us to test how new PRs will behave when used with multiple ansible versions and multiple operating systems. This also allows use to create test scenarios for different role configurations. As a result we have a quite large test matrix (42 parallel role executions in case of [ansible-prometheus](https://github.com/cloudalchemy/ansible-prometheus)) which will take more time than local testing, so please be patient.

meta/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ galaxy_info:
33
author: Pawel Krupa
44
description: Grafana - platform for analytics and monitoring
55
license: MIT
6-
min_ansible_version: 2.3
6+
min_ansible_version: 2.4
77
platforms:
88
- name: Ubuntu
99
versions:

molecule/alternative/molecule.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,37 @@ lint:
88
platforms:
99
- name: bionic
1010
image: paulfantom/ubuntu-molecule:18.04
11+
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
1112
privileged: true
1213
volumes:
1314
- /sys/fs/cgroup:/sys/fs/cgroup:ro
1415
- name: xenial
1516
image: paulfantom/ubuntu-molecule:16.04
17+
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
1618
privileged: true
1719
volumes:
1820
- /sys/fs/cgroup:/sys/fs/cgroup:ro
1921
- name: stretch
2022
image: paulfantom/debian-molecule:9
23+
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
2124
privileged: true
2225
volumes:
2326
- /sys/fs/cgroup:/sys/fs/cgroup:ro
2427
- name: jessie
2528
image: paulfantom/debian-molecule:8
29+
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
2630
privileged: true
2731
volumes:
2832
- /sys/fs/cgroup:/sys/fs/cgroup:ro
2933
- name: centos7
3034
image: paulfantom/centos-molecule:7
35+
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
3136
privileged: true
3237
volumes:
3338
- /sys/fs/cgroup:/sys/fs/cgroup:ro
3439
- name: fedora
3540
image: paulfantom/fedora-molecule:27
41+
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
3642
privileged: true
3743
volumes:
3844
- /sys/fs/cgroup:/sys/fs/cgroup:ro

molecule/default/molecule.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,37 @@ lint:
88
platforms:
99
- name: bionic
1010
image: paulfantom/ubuntu-molecule:18.04
11+
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
1112
privileged: true
1213
volumes:
1314
- /sys/fs/cgroup:/sys/fs/cgroup:ro
1415
- name: xenial
1516
image: paulfantom/ubuntu-molecule:16.04
17+
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
1618
privileged: true
1719
volumes:
1820
- /sys/fs/cgroup:/sys/fs/cgroup:ro
1921
- name: stretch
2022
image: paulfantom/debian-molecule:9
23+
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
2124
privileged: true
2225
volumes:
2326
- /sys/fs/cgroup:/sys/fs/cgroup:ro
2427
- name: jessie
2528
image: paulfantom/debian-molecule:8
29+
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
2630
privileged: true
2731
volumes:
2832
- /sys/fs/cgroup:/sys/fs/cgroup:ro
2933
- name: centos7
3034
image: paulfantom/centos-molecule:7
35+
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
3136
privileged: true
3237
volumes:
3338
- /sys/fs/cgroup:/sys/fs/cgroup:ro
3439
- name: fedora
3540
image: paulfantom/fedora-molecule:27
41+
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
3642
privileged: true
3743
volumes:
3844
- /sys/fs/cgroup:/sys/fs/cgroup:ro

test-requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
molecule>=2.15.0
2+
docker
3+
ansible-lint>=3.4.0
4+
testinfra>=1.7.0
5+
jmespath

tox.ini

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[tox]
2+
minversion = 1.8
3+
envlist = py{27}-ansible{24,25,26}
4+
skipsdist = true
5+
6+
[travis:env]
7+
ANSIBLE=
8+
2.4: ansible24
9+
2.5: ansible25
10+
2.6: ansible26
11+
12+
[testenv]
13+
passenv = *
14+
deps =
15+
-rtest-requirements.txt
16+
ansible24: ansible<2.5
17+
ansible25: ansible<2.6
18+
ansible26: ansible<2.7
19+
commands =
20+
{posargs:molecule test --all --destroy always}

0 commit comments

Comments
 (0)