mirror of
https://github.com/HanXHX/ansible-mysql.git
synced 2026-03-02 10:42:09 +07:00
Import tests and vagrant
This commit is contained in:
31
Vagrantfile
vendored
Normal file
31
Vagrantfile
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
# vi: set tabstop=2 :
|
||||
# vi: set shiftwidth=2 :
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
|
||||
vms = [
|
||||
[ "debian-wheezy", "deb/wheezy-amd64" , "192.168.33.29" ],
|
||||
[ "debian-jessie", "deb/jessie-amd64", "192.168.33.30" ]
|
||||
]
|
||||
|
||||
config.vm.provider "virtualbox" do |v|
|
||||
v.cpus = 1
|
||||
v.memory = 256
|
||||
end
|
||||
|
||||
vms.each do |vm|
|
||||
config.vm.define vm[0] do |m|
|
||||
m.vm.box = vm[1]
|
||||
m.vm.network "private_network", ip: vm[2]
|
||||
|
||||
m.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "tests/test.yml"
|
||||
ansible.groups = { "test" => [ vm[0] ] }
|
||||
ansible.verbose = 'vv'
|
||||
ansible.sudo = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
4
tests/debian-jessie.Dockerfile
Normal file
4
tests/debian-jessie.Dockerfile
Normal file
@@ -0,0 +1,4 @@
|
||||
FROM williamyeh/ansible:debian8-onbuild
|
||||
|
||||
RUN apt-get update
|
||||
CMD ["sh", "tests/test.sh"]
|
||||
4
tests/debian-wheezy.Dockerfile
Normal file
4
tests/debian-wheezy.Dockerfile
Normal file
@@ -0,0 +1,4 @@
|
||||
FROM williamyeh/ansible:debian7-onbuild
|
||||
|
||||
RUN apt-get update
|
||||
CMD ["sh", "tests/test.sh"]
|
||||
1
tests/inventory
Normal file
1
tests/inventory
Normal file
@@ -0,0 +1 @@
|
||||
localhost
|
||||
21
tests/test.sh
Normal file
21
tests/test.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Thanks to https://servercheck.in/blog/testing-ansible-roles-travis-ci-github
|
||||
|
||||
DIR=$( dirname $0 )
|
||||
INVENTORY_FILE="$DIR/inventory"
|
||||
PLAYBOOK="$DIR/test.yml"
|
||||
|
||||
set -ev
|
||||
|
||||
# Check syntax
|
||||
ansible-playbook -i $INVENTORY_FILE -c local --syntax-check -vv $PLAYBOOK
|
||||
|
||||
# Check role
|
||||
ansible-playbook -i $INVENTORY_FILE -c local --sudo -vv $PLAYBOOK
|
||||
|
||||
# Check indempotence
|
||||
ansible-playbook -i $INVENTORY_FILE -c local --sudo -vv $PLAYBOOK \
|
||||
| grep -q 'changed=0.*failed=0' \
|
||||
&& (echo 'Idempotence test: pass' && exit 0) \
|
||||
|| (echo 'Idempotence test: fail' && exit 1)
|
||||
5
tests/test.yml
Normal file
5
tests/test.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
|
||||
- hosts: all
|
||||
roles:
|
||||
- ../../
|
||||
Reference in New Issue
Block a user