Skip to content

Commit 7150de1

Browse files
author
Gustavo Muniz do Carmo
committed
molecule
1 parent 6c19f8b commit 7150de1

11 files changed

+93
-14
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/*/__pycache__
2+
.vscode

Diff for: .travis.yml

+2-12
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,10 @@ addons:
1313
- python-pip
1414

1515
install:
16-
- pip install ansible
17-
18-
before_script:
19-
- docker run --name xenial -d codeyourinfra/python3:xenial
20-
- docker run --name bionic -d codeyourinfra/python3:bionic
21-
- docker run --name alpine -d codeyourinfra/python3:alpine
16+
- pip install -r requirements.txt
2217

2318
script:
24-
- ansible-galaxy install -r requirements.yml -p tests/roles
25-
- ansible-playbook tests/test.yml -i tests/inventory
26-
27-
after_script:
28-
- docker stop xenial bionic alpine
29-
- docker rm xenial bionic alpine
19+
- molecule test
3020

3121
notifications:
3222
webhooks: https://galaxy.ansible.com/api/v1/notifications/

Diff for: .yamllint

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
ignore: |
3+
**/lib/
4+
rules:
5+
line-length: disable

Diff for: README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@ The role requires the *ansible_distribution* variable, obtained through the [gat
1919
2020
## Build process
2121
22-
The build process is performed in [Travis CI](https://travis-ci.org/codeyourinfra/oracle_java8). During the build, the role is tested by using [Docker images with Python 3](https://hub.docker.com/r/codeyourinfra/python3).
22+
The build process is performed in [Travis CI](https://travis-ci.org/codeyourinfra/oracle_java8). During the build, the role is tested by using [Molecule](https://molecule.readthedocs.io).
23+
24+
## Test yourself
25+
26+
Inside your [Python virtual environment](https://docs.python.org/3/tutorial/venv.html), run:
27+
28+
`pip install -r requirements.txt`
29+
30+
And then:
31+
32+
`molecule test`
2333

2434
## Author Information
2535

Diff for: meta/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ galaxy_info:
1919
- oracle
2020
- java
2121
- jdk
22-
22+
2323
dependencies: []

Diff for: molecule/default/Dockerfile.j2

+14
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 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 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 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

Diff for: molecule/default/INSTALL.rst

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
$ sudo pip install docker-py

Diff for: molecule/default/molecule.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
dependency:
3+
name: galaxy
4+
driver:
5+
name: docker
6+
lint:
7+
name: yamllint
8+
platforms:
9+
- name: xenial
10+
image: ubuntu:xenial
11+
- name: bionic
12+
image: ubuntu:bionic
13+
provisioner:
14+
name: ansible
15+
lint:
16+
name: ansible-lint
17+
scenario:
18+
name: default
19+
verifier:
20+
name: testinfra
21+
lint:
22+
name: flake8

Diff for: molecule/default/playbook.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- name: Converge
3+
hosts: all
4+
roles:
5+
- role: oracle_java8

Diff for: molecule/default/tests/test_default.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import os
2+
3+
import testinfra.utils.ansible_runner
4+
5+
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
6+
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
7+
8+
9+
def test_oracle_java8_is_installed(host):
10+
oracle_java8 = host.package("oracle-java8-installer")
11+
assert oracle_java8.is_installed
12+
assert oracle_java8.version.startswith("8u")

Diff for: requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ansible
2+
molecule
3+
docker

0 commit comments

Comments
 (0)