diff --git a/.travis.yml b/.travis.yml index 11a8813..1bfd2f5 100644 --- a/.travis.yml +++ b/.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/ diff --git a/tasks/install/main.yml b/tasks/install/main.yml index 3cb6da9..61e9939 100644 --- a/tasks/install/main.yml +++ b/tasks/install/main.yml @@ -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 diff --git a/tests/debian-jessie.Dockerfile b/tests/debian-jessie.Dockerfile index cd78566..03252b3 100644 --- a/tests/debian-jessie.Dockerfile +++ b/tests/debian-jessie.Dockerfile @@ -1,4 +1,4 @@ FROM williamyeh/ansible:debian8-onbuild RUN apt-get update -CMD ["sh", "tests/test.sh"] +CMD ["sh", "tests/travis.sh"] diff --git a/tests/test.sh b/tests/travis.sh similarity index 55% rename from tests/test.sh rename to tests/travis.sh index e14025a..c0940e7 100644 --- a/tests/test.sh +++ b/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) diff --git a/tests/travis.yml b/tests/travis.yml new file mode 100644 index 0000000..0fec91f --- /dev/null +++ b/tests/travis.yml @@ -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;"