commit
754dc5d40b
@ -1,5 +1,9 @@
|
||||
# Ignore Vagrant cache files
|
||||
/.vagrant/
|
||||
|
||||
# Ignore molecule and pytest files
|
||||
**__pycache__**
|
||||
.molecule
|
||||
|
||||
# Ignore retry files
|
||||
*.retry
|
||||
|
@ -1,29 +1,20 @@
|
||||
---
|
||||
sudo: required
|
||||
language: python
|
||||
python: "2.7"
|
||||
|
||||
# Use the new container infrastructure
|
||||
sudo: false
|
||||
|
||||
# Install ansible
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- python-pip
|
||||
|
||||
cache: pip
|
||||
services:
|
||||
- docker
|
||||
env:
|
||||
- ANSIBLE='ansible>=2.2.0,<2.3.0'
|
||||
- ANSIBLE='ansible>=2.3.0,<2.4.0'
|
||||
- ANSIBLE='ansible>=2.4.0,<2.5.0'
|
||||
install:
|
||||
# Install ansible
|
||||
- pip install ansible
|
||||
|
||||
# Check ansible version
|
||||
- ansible --version
|
||||
|
||||
# Create ansible.cfg with correct roles_path
|
||||
- printf '[defaults]\nroles_path=../' >ansible.cfg
|
||||
|
||||
- pip install ${ANSIBLE} 'ansible-lint>=3.4.15' 'molecule==1.25.0' docker git-semver 'testinfra>=1.7.0,<=1.10.1'
|
||||
before_script:
|
||||
- ansible-lint tests/playbook.yml
|
||||
script:
|
||||
# Basic role syntax check
|
||||
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
|
||||
|
||||
- molecule test
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
notifications:
|
||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||
|
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
for i in ubuntu-molecule:16.04 debian-molecule:9 debian-molecule:8 centos-molecule:7 fedora-molecule:27
|
||||
do
|
||||
docker pull paulfantom/$i &
|
||||
done
|
||||
|
||||
wait
|
@ -1,32 +0,0 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
Vagrant.configure(2) do |config|
|
||||
config.vm.provider "virtualbox" do |vb|
|
||||
vb.memory = "512"
|
||||
end
|
||||
|
||||
config.vm.define "centos-7" do |machine|
|
||||
machine.vm.box = "minimal/centos7"
|
||||
machine.vm.provision "shell", inline: "yum update -y"
|
||||
machine.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "tests/vagrant.yml"
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "debian-jessie" do |machine|
|
||||
machine.vm.box = "minimal/jessie64"
|
||||
machine.vm.provision "shell", inline: "apt-get update && apt-get install -y python"
|
||||
machine.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "tests/vagrant.yml"
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "ubuntu-xenial" do |machine|
|
||||
machine.vm.box = "ubuntu/xenial64"
|
||||
machine.vm.provision "shell", inline: "apt-get update && apt-get install -y python"
|
||||
machine.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "tests/vagrant.yml"
|
||||
end
|
||||
end
|
||||
end
|
@ -1,11 +1,7 @@
|
||||
---
|
||||
- name: reload unit
|
||||
become: true
|
||||
command: systemctl daemon-reload
|
||||
when:
|
||||
- ansible_service_mgr == "systemd"
|
||||
|
||||
- name: restart docker
|
||||
service:
|
||||
become: yes
|
||||
systemd:
|
||||
name: docker
|
||||
state: restarted
|
||||
daemon_reload: yes
|
||||
|
@ -0,0 +1,43 @@
|
||||
---
|
||||
ansible:
|
||||
playbook: tests/playbook.yml
|
||||
driver:
|
||||
name: docker
|
||||
verifier:
|
||||
name: testinfra
|
||||
dependency:
|
||||
name: shell
|
||||
command: ./.travis/images.sh
|
||||
docker:
|
||||
build_image: False
|
||||
containers:
|
||||
- name: xenial
|
||||
image: paulfantom/ubuntu-molecule
|
||||
image_version: 16.04
|
||||
privileged: true
|
||||
volume_mounts:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
# - name: stretch
|
||||
# image: paulfantom/debian-molecule
|
||||
# image_version: 9
|
||||
# privileged: true
|
||||
# volume_mounts:
|
||||
# - /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: jessie
|
||||
image: paulfantom/debian-molecule
|
||||
image_version: 8
|
||||
privileged: true
|
||||
volume_mounts:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
# - name: centos7
|
||||
# image: paulfantom/centos-molecule
|
||||
# image_version: 7
|
||||
# privileged: true
|
||||
# volume_mounts:
|
||||
# - /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
# - name: fedora
|
||||
# image: paulfantom/fedora-molecule
|
||||
# image_version: 27
|
||||
# privileged: true
|
||||
# volume_mounts:
|
||||
# - /sys/fs/cgroup:/sys/fs/cgroup:ro
|
@ -0,0 +1,2 @@
|
||||
[Service]
|
||||
Environment="HTTP_PROXY={{ docker_http_proxy }}" "HTTPS_PROXY={{ docker_https_proxy }}" "NO_PROXY={{ docker_no_proxy }}"
|
@ -1 +0,0 @@
|
||||
localhost
|
@ -0,0 +1,9 @@
|
||||
---
|
||||
- hosts: all
|
||||
become: yes
|
||||
roles:
|
||||
- ansible-role-docker
|
||||
vars:
|
||||
default_docker_config:
|
||||
storage-driver: vfs
|
||||
log-level: info
|
@ -1,6 +0,0 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
become: yes
|
||||
become_user: root
|
||||
roles:
|
||||
- .
|
@ -0,0 +1,54 @@
|
||||
from testinfra.utils.ansible_runner import AnsibleRunner
|
||||
|
||||
testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all')
|
||||
|
||||
|
||||
def test_directories(host):
|
||||
present = [
|
||||
"/etc/docker",
|
||||
]
|
||||
absent = []
|
||||
if present:
|
||||
for directory in present:
|
||||
d = host.file(directory)
|
||||
assert d.is_directory
|
||||
assert d.exists
|
||||
if absent:
|
||||
for directory in absent:
|
||||
d = host.file(directory)
|
||||
assert not d.exists
|
||||
|
||||
|
||||
def test_files(host):
|
||||
present = [
|
||||
"/etc/docker/daemon.json",
|
||||
]
|
||||
if present:
|
||||
for file in present:
|
||||
f = host.file(file)
|
||||
assert f.exists
|
||||
assert f.is_file
|
||||
|
||||
|
||||
# def test_socket(host):
|
||||
# assert host.socket("unix:///var/run/docker.sock").is_listening
|
||||
|
||||
|
||||
def test_service(host):
|
||||
present = [
|
||||
"docker"
|
||||
]
|
||||
if present:
|
||||
for service in present:
|
||||
s = host.service(service)
|
||||
assert s.is_running
|
||||
assert s.is_enabled
|
||||
|
||||
|
||||
def test_packages(host):
|
||||
if host.system_info.distribution == 'ol':
|
||||
DOCKER = 'docker-engine'
|
||||
else:
|
||||
DOCKER = 'docker-ce'
|
||||
|
||||
assert host.package(DOCKER).is_installed
|
@ -1,24 +0,0 @@
|
||||
---
|
||||
- hosts: all
|
||||
become: yes
|
||||
become_user: root
|
||||
vars:
|
||||
docker_clusterstore: yes
|
||||
vagrant: yes
|
||||
roles:
|
||||
- ../docker
|
||||
tasks:
|
||||
- name: check consul state
|
||||
command: docker ps -q -f name=consul
|
||||
register: consulcheck
|
||||
changed_when: no
|
||||
|
||||
- name: ensure consul is running
|
||||
command: >
|
||||
docker run \
|
||||
-d \
|
||||
--name consul \
|
||||
-p "8500:8500" \
|
||||
--restart always \
|
||||
progrium/consul -server -bootstrap
|
||||
when: consulcheck.stdout_lines | length == 0
|
Loading…
Reference in new issue