Skip to content
Permalink
Browse files

Added firsts tests with molecule and testinfra.

  • Loading branch information...
Frzk committed Mar 18, 2019
1 parent 05907ef commit f5fa6623b421f83961cd92043115081a96c117bb
@@ -0,0 +1,16 @@
*******
Docker driver installation guide
*******

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

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

Install
=======

$ sudo pip install docker-py
@@ -0,0 +1,30 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
options:
config-file: molecule/default/yamllint.yml
platforms:
- name: instance
image: "frzk/${MOLECULE_DISTRO:-centos7}-ansible"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: yes
pre_build_image: yes
provisioner:
name: ansible
lint:
name: ansible-lint
playbooks:
converge: ${MOLECULE_PLAYBOOK:-playbook.yml}
scenario:
name: default
verifier:
name: testinfra
lint:
name: flake8
...
@@ -0,0 +1,5 @@
---
- name: Converge
hosts: all
roles:
- role: ansible-role-chrony
@@ -0,0 +1,31 @@
#!/usr/bin/env python
# coding: utf8

import os
from testinfra.utils.ansible_runner import AnsibleRunner


testinfra_hosts = AnsibleRunner(os.environ['MOLECULE_INVENTORY_FILE']) \
.get_hosts('all')


def test_chrony_is_installed(host):
"""
"""
package_name = "chrony"

chrony = host.package(package_name)
assert chrony.is_installed

def test_chrony_running_and_enabled(host):
"""
"""
os = host.system_info.distribution
service_name = "chronyd"

if os === "debian":
service_name = "chronyd"

chrony = host.service(service_name)
assert chrony.is_running
assert chrony.is_enabled
@@ -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'
@@ -0,0 +1,7 @@
---
extends: default
rules:
line-length:
max: 120
level: warning
...

0 comments on commit f5fa662

Please sign in to comment.
You can’t perform that action at this time.