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.
|
|
|
|
- sudo apt-get remove --purge -s '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 20:54:23 +02:00
|
|
|
- sudo rm -rf /var/log/mysql
|
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-04-23 17:12:54 +02:00
|
|
|
- pip install ansible==1.5.0
|
2014-04-23 20:03:08 +02:00
|
|
|
|
|
|
|
# Add ansible.cfg to pick up roles path.
|
|
|
|
- "printf '[defaults]\nroles_path = ../' > ansible.cfg"
|
|
|
|
|
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"
|
|
|
|
- "sudo ls -lah /var/log/mysql"
|
2014-05-23 20:22:31 +02:00
|
|
|
- "sudo cat /var/log/mysql/error.log"
|
2014-05-23 20:54:23 +02:00
|
|
|
- "sudo cat /var/log/mysql/slow.log"
|
2014-05-23 20:18:23 +02:00
|
|
|
|
2014-04-23 17:19:46 +02:00
|
|
|
# Check to make sure we can connect to MySQL.
|
|
|
|
- >
|
|
|
|
mysql -u root -proot -e 'show databases;'
|
|
|
|
| grep -q 'performance_schema'
|
|
|
|
&& (echo 'MySQL running normally' && exit 0)
|
|
|
|
|| (echo 'MySQL not running' && exit 1)
|