Test playbook execution with travis
parent
17f3731450
commit
293ee332dd
35
.travis.yml
35
.travis.yml
|
@ -1,29 +1,20 @@
|
|||
---
|
||||
matrix:
|
||||
include:
|
||||
- env: OS=debian-jessie ORIGIN=default VENDOR=mysql
|
||||
- env: OS=debian-jessie ORIGIN=default VENDOR=mariadb
|
||||
- env: OS=debian-jessie ORIGIN=uptream VENDOR=mariadb
|
||||
- env: OS=debian-jessie ORIGIN=uptream VENDOR=mariadb_galera
|
||||
- env: OS=debian-jessie ORIGIN=uptream VENDOR=percona
|
||||
|
||||
sudo: required
|
||||
|
||||
language: python
|
||||
python: "2.7"
|
||||
|
||||
# Use the new container infrastructure
|
||||
sudo: false
|
||||
|
||||
# Install ansible
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- python-pip
|
||||
|
||||
install:
|
||||
# Install ansible
|
||||
- pip install ansible
|
||||
|
||||
# Check ansible version
|
||||
- ansible --version
|
||||
|
||||
# Create ansible.cfg with correct roles_path
|
||||
- printf '[defaults]\nroles_path=../' >ansible.cfg
|
||||
services:
|
||||
- docker
|
||||
|
||||
script:
|
||||
# Basic role syntax check
|
||||
- ansible-playbook tests/test.yml -i localhost, --syntax-check
|
||||
- docker build -f tests/$OS.Dockerfile -t test-$OS . && docker run -e "ORIGIN=$ORIGIN" -e "VENDOR=$VENDOR" --name $OS test-$OS
|
||||
|
||||
notifications:
|
||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
|
||||
- name: FAIL | If config asked is impossible
|
||||
fail: msg="config asked is impossible"
|
||||
fail: msg="config asked is impossible ({{ mysql_origin }} / {{ mysql_vendor }})"
|
||||
when: >
|
||||
not (
|
||||
(mysql_origin == 'default' and mysql_vendor == 'mysql') or
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM williamyeh/ansible:debian8-onbuild
|
||||
|
||||
RUN apt-get update
|
||||
CMD ["sh", "tests/test.sh"]
|
||||
CMD ["sh", "tests/travis.sh"]
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
# Thanks to https://servercheck.in/blog/testing-ansible-roles-travis-ci-github
|
||||
|
||||
DIR=$( dirname $0 )
|
||||
INVENTORY_FILE="$DIR/inventory"
|
||||
PLAYBOOK="$DIR/test.yml"
|
||||
INVENTORY_FILE="localhost,"
|
||||
PLAYBOOK="$DIR/travis.yml"
|
||||
|
||||
set -ev
|
||||
|
||||
|
@ -12,10 +12,10 @@ set -ev
|
|||
ansible-playbook -i $INVENTORY_FILE -c local --syntax-check -vv $PLAYBOOK
|
||||
|
||||
# Check role
|
||||
ansible-playbook -i $INVENTORY_FILE -c local --sudo -vv $PLAYBOOK
|
||||
ansible-playbook -i $INVENTORY_FILE -c local -e "{ mysql_vendor: $VENDOR, mysql_origin: $ORIGIN }" --sudo -vv $PLAYBOOK
|
||||
|
||||
# Check indempotence
|
||||
ansible-playbook -i $INVENTORY_FILE -c local --sudo -vv $PLAYBOOK \
|
||||
ansible-playbook -i $INVENTORY_FILE -c local -e "{ mysql_vendor: $VENDOR, mysql_origin: $ORIGIN }" --sudo -vv $PLAYBOOK \
|
||||
| grep -q 'changed=0.*failed=0' \
|
||||
&& (echo 'Idempotence test: pass' && exit 0) \
|
||||
|| (echo 'Idempotence test: fail' && exit 1)
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
|
||||
- hosts: all
|
||||
vars:
|
||||
mysql_replication_master: true
|
||||
mysql_bind_address: '{{ ansible_eth0.ipv4.address }}'
|
||||
mariadb_galera_members:
|
||||
- '{{ ansible_eth0.ipv4.address }}'
|
||||
roles:
|
||||
- ../../
|
||||
post_tasks:
|
||||
- name: TEST | SHELL | Test mysql
|
||||
shell: mysql -e "SHOW DATABASES;"
|
Loading…
Reference in New Issue