2014-04-23 17:12:54 +02:00
|
|
|
---
|
|
|
|
language: python
|
|
|
|
python: "2.7"
|
2014-04-23 20:03:08 +02:00
|
|
|
|
2014-04-23 17:12:54 +02:00
|
|
|
env:
|
|
|
|
- SITE=test.yml
|
2014-04-23 20:03:08 +02:00
|
|
|
|
2014-04-23 17:12:54 +02:00
|
|
|
before_install:
|
|
|
|
- sudo apt-get update -qq
|
2014-05-23 20:54:23 +02:00
|
|
|
|
|
|
|
# Remove MySQL. Completely and totally.
|
2014-07-11 15:31:12 +02:00
|
|
|
- sudo apt-get remove --purge 'mysql*'
|
2014-05-23 20:37:40 +02:00
|
|
|
- sudo apt-get autoremove
|
|
|
|
- sudo apt-get autoclean
|
2014-05-23 20:29:33 +02:00
|
|
|
- sudo rm -rf /var/lib/mysql
|
2014-05-23 21:00:05 +02:00
|
|
|
- sudo truncate -s 0 /var/log/mysql/error.log
|
2014-04-23 20:03:08 +02:00
|
|
|
|
2014-04-23 17:12:54 +02:00
|
|
|
install:
|
2014-04-23 20:03:08 +02:00
|
|
|
# Install Ansible.
|
2014-08-04 04:47:53 +02:00
|
|
|
- pip install ansible
|
2014-04-23 20:03:08 +02:00
|
|
|
|
|
|
|
# Add ansible.cfg to pick up roles path.
|
2014-11-08 21:36:01 +01:00
|
|
|
- "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg"
|
2014-04-23 20:03:08 +02:00
|
|
|
|
2014-04-23 17:12:54 +02:00
|
|
|
script:
|
|
|
|
# Check the role/playbook's syntax.
|
|
|
|
- "ansible-playbook -i tests/inventory tests/$SITE --syntax-check"
|
|
|
|
|
|
|
|
# Run the role/playbook with ansible-playbook.
|
2014-05-23 18:44:52 +02:00
|
|
|
- "ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo"
|
2014-04-23 17:12:54 +02:00
|
|
|
|
|
|
|
# Run the role/playbook again, checking to make sure it's idempotent.
|
|
|
|
- >
|
|
|
|
ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo
|
|
|
|
| grep -q 'changed=0.*failed=0'
|
|
|
|
&& (echo 'Idempotence test: pass' && exit 0)
|
|
|
|
|| (echo 'Idempotence test: fail' && exit 1)
|
|
|
|
|
2014-05-23 20:54:23 +02:00
|
|
|
# Some MySQL debugging (show all the logs).
|
2014-05-23 20:29:33 +02:00
|
|
|
- "sudo ls -lah /var/log"
|
2014-05-23 20:22:31 +02:00
|
|
|
- "sudo cat /var/log/mysql/error.log"
|
2014-05-23 20:18:23 +02:00
|
|
|
|
2015-01-09 01:04:16 +01:00
|
|
|
# Check to make sure we can connect to MySQL via Unix socket.
|
|
|
|
- >
|
|
|
|
mysql -u root -proot -e 'show databases;'
|
|
|
|
| grep -q 'performance_schema'
|
|
|
|
&& (echo 'MySQL running normally' && exit 0)
|
|
|
|
|| (echo 'MySQL not running' && exit 1)
|
|
|
|
|
|
|
|
# Check to make sure we can connect to MySQL via TCP.
|
2014-04-23 17:19:46 +02:00
|
|
|
- >
|
2015-01-09 00:30:00 +01:00
|
|
|
mysql -u root -proot -h 127.0.0.1 -e 'show databases;'
|
2014-04-23 17:19:46 +02:00
|
|
|
| grep -q 'performance_schema'
|
|
|
|
&& (echo 'MySQL running normally' && exit 0)
|
|
|
|
|| (echo 'MySQL not running' && exit 1)
|