Travis major changes:

- Use Vagrant + Docker
- Test multiple Ansible versions
pull/35/head
Emilien Mantel 2017-06-05 16:21:47 +02:00
parent 3ae791ec47
commit eb0bdcad6f
6 changed files with 88 additions and 69 deletions

View File

@ -1,8 +1,16 @@
env:
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.2,<2.3'
- PLATFORM='docker-debian-jessie-backports' ANSIBLE_VERSION='ansible>=2.2,<2.3'
- PLATFORM='docker-debian-jessie-dotdeb' ANSIBLE_VERSION='ansible>=2.2,<2.3'
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-debian-jessie-backports' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-debian-jessie-dotdeb' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.3,<2.4'
matrix:
include:
- env: PLATFORM=debian-jessie ORIGIN=debian NGINX_PHP56=true NGINX_PHP70=false NGINX_BACKPORTS=false DOTDEB=false
- env: PLATFORM=debian-jessie ORIGIN=backports NGINX_PHP56=true NGINX_PHP70=false NGINX_BACKPORTS=true DOTDEB=false
- env: PLATFORM=debian-jessie ORIGIN=dotdeb NGINX_PHP56=true NGINX_PHP70=true NGINX_BACKPORTS=false DOTDEB=true
allow_failures:
- env: PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.3,<2.4'
fast_finish: true
sudo: required
@ -13,8 +21,21 @@ language: python
services:
- docker
before_install:
- wget https://releases.hashicorp.com/vagrant/1.9.5/vagrant_1.9.5_x86_64.deb
- sudo dpkg -i vagrant_1.9.5_x86_64.deb
install:
- pip install "$ANSIBLE_VERSION"
script:
- docker build -f tests/$PLATFORM.Dockerfile -t test-$PLATFORM . && docker run -e "DOTDEB=$DOTDEB" -e "NGINX_PHP56=$NGINX_PHP56" -e "NGINX_PHP70=$NGINX_PHP70" -e "NGINX_BACKPORTS=$NGINX_BACKPORTS" --name $PLATFORM test-$PLATFORM
- VAGRANT_DEFAULT_PROVIDER=docker vagrant up $PLATFORM
- >
VAGRANT_DEFAULT_PROVIDER=docker vagrant provision $PLATFORM
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
- VAGRANT_DEFAULT_PROVIDER=docker vagrant status
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

93
Vagrantfile vendored
View File

@ -6,51 +6,78 @@
Vagrant.configure("2") do |config|
vms_debian = [
{ :name => "debian-jessie", :box => "debian/jessie64", :vars => { "nginx_php56": true, "nginx_php70": false, "dotdeb": false, "nginx_backports": false }},
{ :name => "debian-jessie-backports", :box => "debian/jessie64", :vars => { "nginx_php56": true, "nginx_php70": false, "dotdeb": false, "nginx_backports": true }},
{ :name => "debian-jessie-dotdeb", :box => "debian/jessie64", :vars => { "nginx_php56": true, "nginx_php70": true, "dotdeb": true, "nginx_backports": false }},
{ :name => "debian-stretch", :box => "sharlak/debian_stretch_64", :vars => { "nginx_php56": false, "nginx_php70": true, "dotdeb": false, "nginx_backports": false }}
{ :name => "debian-jessie", :box => "debian/jessie64", :vars => { "nginx_php56": true, "nginx_php70": false, "dotdeb": false, "nginx_backports": false }},
{ :name => "debian-jessie-backports", :box => "debian/jessie64", :vars => { "nginx_php56": true, "nginx_php70": false, "dotdeb": false, "nginx_backports": true }},
{ :name => "debian-jessie-dotdeb", :box => "debian/jessie64", :vars => { "nginx_php56": true, "nginx_php70": true, "dotdeb": true, "nginx_backports": false }},
{ :name => "debian-stretch", :box => "sharlak/debian_stretch_64", :vars => { "nginx_php56": false, "nginx_php70": true, "dotdeb": false, "nginx_backports": false }}
]
vms_freebsd = [
{ :name => "freebsd-10.2", :box => "freebsd/FreeBSD-10.2-STABLE" }
{ :name => "freebsd-10.2", :box => "freebsd/FreeBSD-10.2-STABLE" }
]
config.vm.provider "virtualbox" do |v|
v.cpus = 1
v.memory = 256
conts = [
{ :name => "docker-debian-jessie", :docker => "hanxhx/vagrant-ansible:debian8", :vars => { "nginx_php56": true, "nginx_php70": false, "dotdeb": false, "nginx_backports": false }},
{ :name => "docker-debian-jessie-backports", :docker => "hanxhx/vagrant-ansible:debian8", :vars => { "nginx_php56": true, "nginx_php70": false, "dotdeb": false, "nginx_backports": true }},
{ :name => "docker-debian-jessie-dotdeb", :docker => "hanxhx/vagrant-ansible:debian8", :vars => { "nginx_php56": true, "nginx_php70": true, "dotdeb": true, "nginx_backports": false }},
{ :name => "docker-debian-stretch", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "nginx_php56": false, "nginx_php70": true, "dotdeb": false, "nginx_backports": false }}
]
config.vm.network "private_network", type: "dhcp"
conts.each do |opts|
config.vm.define opts[:name] do |m|
m.vm.provider "docker" do |d|
d.image = opts[:docker]
d.remains_running = true
d.has_ssh = true
end
m.vm.provision "ansible" do |ansible|
ansible.playbook = "tests/test.yml"
ansible.verbose = 'vv'
ansible.sudo = true
ansible.extra_vars = opts[:vars]
end
end
end
vms_debian.each do |opts|
config.vm.define opts[:name] do |m|
m.vm.box = opts[:box]
m.vm.network "private_network", type: "dhcp"
m.vm.provision "ansible" do |ansible|
ansible.playbook = "tests/test.yml"
ansible.verbose = 'vv'
ansible.sudo = true
ansible.extra_vars = opts[:vars]
m.vm.provider "virtualbox" do |v|
v.cpus = 1
v.memory = 256
end
m.vm.provision "ansible" do |ansible|
ansible.playbook = "tests/test.yml"
ansible.verbose = 'vv'
ansible.sudo = true
ansible.extra_vars = opts[:vars]
end
end
end
# See: https://forums.freebsd.org/threads/52717/
vms_freebsd.each do |opts|
config.vm.define opts[:name] do |m|
m.vm.box = opts[:box]
m.vm.network "private_network", type: "dhcp"
m.vm.guest = :freebsd
m.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
m.ssh.shell = "sh"
m.vm.base_mac = "080027D14C66"
m.vm.provision "shell", inline: "pkg install -y python bash"
m.vm.provision "ansible" do |ansible|
ansible.playbook = "tests/test.yml"
ansible.verbose = 'vv'
ansible.sudo = true
ansible.extra_vars = {
ansible_python_interpreter: '/usr/local/bin/python'
}
end
end
end
# vms_freebsd.each do |opts|
# config.vm.define opts[:name] do |m|
# m.vm.box = opts[:box]
# m.vm.provider "virtualbox" do |v|
# v.vm.cpus = 1
# v.vm.memory = 256
# v.vm.guest = :freebsd
# v.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
# v.vm.base_mac = "080027D14C66"
# end
# config.ssh.shell = "sh"
# m.vm.provision "shell", inline: "pkg install -y python bash"
# m.vm.provision "ansible" do |ansible|
# ansible.playbook = "tests/test.yml"
# ansible.verbose = 'vv'
# ansible.sudo = true
# ansible.extra_vars = {
# ansible_python_interpreter: '/usr/local/bin/python'
# }
# end
# end
# end
end

View File

@ -4,7 +4,7 @@ galaxy_info:
description: Nginx for Debian
company:
license: GPLv2
min_ansible_version: 2.0
min_ansible_version: 2.2
platforms:
- name: Debian
versions:

View File

@ -1,4 +0,0 @@
FROM williamyeh/ansible:debian8-onbuild
RUN apt-get update
CMD ["sh", "tests/travis.sh"]

View File

@ -229,7 +229,7 @@
https_proxy_protocol_port: [20443]
template: '_base'
ssl_name: 'test-ssl.local'
nginx_dh_length: 2048
nginx_dh_length: 1024
roles:
- ../../
post_tasks:

View File

@ -1,25 +0,0 @@
#!/bin/sh
# Thanks to https://servercheck.in/blog/testing-ansible-roles-travis-ci-github
DIR=$( dirname $0 )
PLAYBOOK="$DIR/test.yml"
set -ev
ANSIBLE_VARS="{ nginx_php56: $NGINX_PHP56, nginx_php70: $NGINX_PHP70, nginx_backports: $NGINX_BACKPORTS, dotdeb: $DOTDEB }"
echo $ANSIBLE_VARS
# Check syntax
ansible-playbook -i localhost, -c local --syntax-check -vv $PLAYBOOK
# Check role
ansible-playbook -i localhost, -c local -e "$ANSIBLE_VARS" --sudo -vv $PLAYBOOK
# Check indempotence
ansible-playbook -i localhost, -c local -e "$ANSIBLE_VARS" --sudo -vv $PLAYBOOK \
| grep -q 'changed=0.*failed=0' \
&& (echo 'Idempotence test: pass' && exit 0) \
|| (echo 'Idempotence test: fail' && exit 1)