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: matrix:
include: allow_failures:
- env: PLATFORM=debian-jessie ORIGIN=debian NGINX_PHP56=true NGINX_PHP70=false NGINX_BACKPORTS=false DOTDEB=false - env: PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- env: PLATFORM=debian-jessie ORIGIN=backports NGINX_PHP56=true NGINX_PHP70=false NGINX_BACKPORTS=true DOTDEB=false fast_finish: true
- env: PLATFORM=debian-jessie ORIGIN=dotdeb NGINX_PHP56=true NGINX_PHP70=true NGINX_BACKPORTS=false DOTDEB=true
sudo: required sudo: required
@ -13,8 +21,21 @@ language: python
services: services:
- docker - 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: 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: notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/ webhooks: https://galaxy.ansible.com/api/v1/notifications/

93
Vagrantfile vendored
View File

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

View File

@ -4,7 +4,7 @@ galaxy_info:
description: Nginx for Debian description: Nginx for Debian
company: company:
license: GPLv2 license: GPLv2
min_ansible_version: 2.0 min_ansible_version: 2.2
platforms: platforms:
- name: Debian - name: Debian
versions: 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] https_proxy_protocol_port: [20443]
template: '_base' template: '_base'
ssl_name: 'test-ssl.local' ssl_name: 'test-ssl.local'
nginx_dh_length: 2048 nginx_dh_length: 1024
roles: roles:
- ../../ - ../../
post_tasks: 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)