Skip to content

Commit

Permalink
molecule2 & tox
Browse files Browse the repository at this point in the history
  • Loading branch information
bbaassssiiee committed Jul 15, 2018
1 parent d95cccf commit 11c3655
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 26 deletions.
21 changes: 0 additions & 21 deletions molecule.yml

This file was deleted.

14 changes: 14 additions & 0 deletions molecule/default/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Molecule managed

{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}

RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi
26 changes: 26 additions & 0 deletions molecule/default/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
*******
Docker driver installation guide
*******

Requirements
============

* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html)
* Docker Engine
* docker-py
* docker

Install
=======

Ansible < 2.6

.. code-block:: bash
$ sudo pip install docker-py
Ansible >= 2.6

.. code-block:: bash
$ sudo pip install docker
27 changes: 27 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
# Standards: 0.2
dependency:
name: galaxy
requirements_file: requirements.yml
driver:
name: docker
lint:
name: yamllint
platforms:
- name: base-maven-centos
image: milcom/centos7-systemd
privileged: True
- name: base-maven-ubuntu
image: ubuntu
privileged: True
provisioner:
name: ansible
config_options:
defaults:
remote_tmp: /tmp
playbooks:
converge: playbook.yml
lint:
name: ansible-lint
scenario:
name: default
File renamed without changes.
6 changes: 6 additions & 0 deletions molecule/default/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- src: https://github.com/dockpack/base_common.git
name: dockpack.base_common

- src: https://github.com/dockpack/base_java8.git
name: dockpack.base_java8
8 changes: 8 additions & 0 deletions molecule/default/tests/test_default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Molecule managed

---
file:
/etc/hosts:
exists: true
owner: root
group: root
53 changes: 53 additions & 0 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
# This is an example playbook to execute goss tests.
# Tests need distributed to the appropriate ansible host/groups
# prior to execution by `goss validate`.

- name: Verify
hosts: all
become: true
vars:
goss_version: v0.3.2
goss_arch: amd64
goss_dst: /usr/local/bin/goss
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
goss_test_directory: /tmp
goss_format: documentation
tasks:
- name: Download and install Goss
get_url:
url: "{{ goss_url }}"
dest: "{{ goss_dst }}"
sha256sum: "{{ goss_sha256sum }}"
mode: 0755
register: download_goss
until: download_goss is succeeded
retries: 3

- name: Copy Goss tests to remote
copy:
src: "{{ item }}"
dest: "{{ goss_test_directory }}/{{ item | basename }}"
with_fileglob:
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_*.yml"

- name: Register test files
shell: "ls {{ goss_test_directory }}/test_*.yml"
register: test_files

- name: Execute Goss tests
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
register: test_results
with_items: "{{ test_files.stdout_lines }}"

- name: Display details about the Goss results
debug:
msg: "{{ item.stdout_lines }}"
with_items: "{{ test_results.results }}"

- name: Fail when tests fail
fail:
msg: "Goss failed to validate"
when: item.rc != 0
with_items: "{{ test_results.results }}"
7 changes: 2 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# these python extensions are required for testing
ansible==2.3.2
yamllint==1.8.1
ansible-lint==3.4.15
molecule==1.25.1
tox
molecule
docker
16 changes: 16 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tox]
minversion = 1.8
envlist = py{27}-ansible{24,25},molecule,yamllint
skipsdist = true

[testenv]
# ansible only supports python3 in versions >= 2.5
basepython = python2.7
passenv = *
deps =
-rrequirements.txt
ansible24: ansible>=2.4,<2.5
ansible25: ansible>=2.5,<2.6
commands =
pip list
molecule test

0 comments on commit 11c3655

Please sign in to comment.