Ansible playbooks that allow you to deploy a simple web app with apache2 web servers and haproxy load balancer.
- Edit hosts_template file to specify your web servers and load balancer hosts. Replace field with your own addresses and/or add more hosts if necessary. Then run
sudo mv hosts_template hosts
. - There must be an user with NOPASSWD option in sudoers file on the hosts.
- Build an lightweight Ansible docker image:
docker build -t ansible .
- Run provisioning tasks with command
docker run --rm --network=host -it -v $(pwd)/log:/log ansible install-site.yml -e '{"username":<username>,"userpass":<password>}'
- Run purge tasks with command
docker run --rm --network=host -it -v $(pwd)/log:/log ansible purge-site.yml -e '{"username":<username>,"userpass":<password>}'
- You can specify modified
hosts
file without rebuilding docker image by adding mount with-v $(pwd)/hosts:/ansible/hosts
todocker run
command. - You can also specify another web app by editing
roles/apache/tasks/install.yml
. The app repo defined with the string:git: repo=<some repo URL> dest=/var/www/awesome-app