parent
a7040aac63
commit
666b6a434c
@ -0,0 +1,16 @@
|
||||
# Molecule managed
|
||||
|
||||
[defaults]
|
||||
roles_path = .molecule/roles/:.molecule/../roles/:../:../../
|
||||
library = .molecule/library/:library/
|
||||
action_plugins = .molecule/plugins/actions/:plugins/actions/
|
||||
callback_plugins = .molecule/plugins/callbacks/:plugins/callbacks/
|
||||
connection_plugins = .molecule/plugins/connections/:plugins/connections/
|
||||
lookup_plugins = .molecule/plugins/lookups/:plugins/lookups/
|
||||
vars_plugins = .molecule/plugins/vars/:plugins/vars/
|
||||
filter_plugins = .molecule/plugins/filters/:plugins/filters/
|
||||
ansible_managed = Ansible managed: Do NOT edit this file manually!
|
||||
nocows = 1
|
||||
retry_files_enabled = False
|
||||
|
||||
[ssh_connection]
|
@ -0,0 +1,5 @@
|
||||
[all]
|
||||
xenial ansible_connection=docker
|
||||
stretch ansible_connection=docker
|
||||
jessie ansible_connection=docker
|
||||
centos7 ansible_connection=docker
|
@ -0,0 +1,30 @@
|
||||
# Molecule managed
|
||||
|
||||
require 'rake'
|
||||
require 'rspec/core/rake_task'
|
||||
require 'yaml'
|
||||
require 'fileutils'
|
||||
|
||||
task spec: 'serverspec:all'
|
||||
task default: :spec
|
||||
|
||||
hosts = YAML.load_file('.molecule/state.yml')['hosts']
|
||||
|
||||
namespace :serverspec do
|
||||
task all: hosts.keys
|
||||
hosts.each do |name, host|
|
||||
desc "Run serverspec on #{name}"
|
||||
pattern = ['spec/*_spec.rb', "spec/#{name}/*_spec.rb", "spec/hosts/#{name}/*_spec.rb"]
|
||||
|
||||
host['groups'].each do |group|
|
||||
pattern << "spec/#{group}/*_spec.rb"
|
||||
pattern << "spec/groups/#{group}/*_spec.rb"
|
||||
end
|
||||
|
||||
RSpec::Core::RakeTask.new(name.to_sym) do |target|
|
||||
puts "*** Run serverspec on #{name} ***"
|
||||
ENV['TARGET_HOST'] = name
|
||||
target.pattern = pattern.join(',')
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,18 @@
|
||||
---
|
||||
converged: null
|
||||
created: true
|
||||
default_platform: null
|
||||
default_provider: null
|
||||
driver: docker
|
||||
driver_config: {}
|
||||
hosts:
|
||||
centos7:
|
||||
groups: []
|
||||
jessie:
|
||||
groups: []
|
||||
stretch:
|
||||
groups: []
|
||||
xenial:
|
||||
groups: []
|
||||
installed_deps: true
|
||||
multiple_platforms: null
|
@ -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=2.2.3
|
||||
- ANSIBLE=2.3.2
|
||||
- ANSIBLE=2.4.2
|
||||
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} ansible-lint>=3.4.15 molecule==1.25.0 docker git-semver testinfra>=1.7.0
|
||||
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
|
@ -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
|
@ -1 +0,0 @@
|
||||
localhost
|
@ -0,0 +1,11 @@
|
||||
---
|
||||
- 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,55 @@
|
||||
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