mirror of
https://github.com/HanXHX/ansible-mysql.git
synced 2026-04-09 13:42:10 +07:00
Test playbook execution with travis
This commit is contained in:
@@ -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)
|
||||
13
tests/travis.yml
Normal file
13
tests/travis.yml
Normal file
@@ -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;"
|
||||
Reference in New Issue
Block a user