Travis major changes:
- Use Vagrant + Docker - Test multiple Ansible versionspull/35/head
parent
3ae791ec47
commit
eb0bdcad6f
31
.travis.yml
31
.travis.yml
|
@ -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/
|
||||||
|
|
|
@ -16,15 +16,22 @@ Vagrant.configure("2") do |config|
|
||||||
{ :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 }},
|
||||||
end
|
{ :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 }}
|
||||||
|
]
|
||||||
|
|
||||||
vms_debian.each do |opts|
|
config.vm.network "private_network", type: "dhcp"
|
||||||
|
|
||||||
|
conts.each do |opts|
|
||||||
config.vm.define opts[:name] do |m|
|
config.vm.define opts[:name] do |m|
|
||||||
m.vm.box = opts[:box]
|
m.vm.provider "docker" do |d|
|
||||||
m.vm.network "private_network", type: "dhcp"
|
d.image = opts[:docker]
|
||||||
|
d.remains_running = true
|
||||||
|
d.has_ssh = true
|
||||||
|
end
|
||||||
m.vm.provision "ansible" do |ansible|
|
m.vm.provision "ansible" do |ansible|
|
||||||
ansible.playbook = "tests/test.yml"
|
ansible.playbook = "tests/test.yml"
|
||||||
ansible.verbose = 'vv'
|
ansible.verbose = 'vv'
|
||||||
|
@ -33,24 +40,44 @@ Vagrant.configure("2") do |config|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# See: https://forums.freebsd.org/threads/52717/
|
|
||||||
vms_freebsd.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.guest = :freebsd
|
v.cpus = 1
|
||||||
m.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
|
v.memory = 256
|
||||||
m.ssh.shell = "sh"
|
end
|
||||||
m.vm.base_mac = "080027D14C66"
|
|
||||||
m.vm.provision "shell", inline: "pkg install -y python bash"
|
|
||||||
m.vm.provision "ansible" do |ansible|
|
m.vm.provision "ansible" do |ansible|
|
||||||
ansible.playbook = "tests/test.yml"
|
ansible.playbook = "tests/test.yml"
|
||||||
ansible.verbose = 'vv'
|
ansible.verbose = 'vv'
|
||||||
ansible.sudo = true
|
ansible.sudo = true
|
||||||
ansible.extra_vars = {
|
ansible.extra_vars = opts[:vars]
|
||||||
ansible_python_interpreter: '/usr/local/bin/python'
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
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.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
|
end
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
FROM williamyeh/ansible:debian8-onbuild
|
|
||||||
|
|
||||||
RUN apt-get update
|
|
||||||
CMD ["sh", "tests/travis.sh"]
|
|
|
@ -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:
|
||||||
|
|
|
@ -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)
|
|
Loading…
Reference in New Issue