Deploying system services and docker containers using Ansible on Ubuntu 16.04
Deployment procedure consists of following procedures:
- Update Ubuntu server
- Install and configure firewall on server
- Install and configure DNS with specific zone
- Install Docker and deploy simple PHP application
Ubuntu server 16.04 for running services, Python2.7, PIP and git installed. The rest is installed by Ansible.
Configuring services to fit in your environment you have to configure following variables
- iptables_ssh_networks: networks from which you allow SSH access to hosts
- iptables_trusted_networks: networks from which you allow any traffic
- iptables_public_ports: publicly available ports
- bind_zone: zone for DNS
- bind_records: DNS records in the zone file of format {name: x, type: [CNAME, A, AAAA,...] record: y}
Make sure the repository is located on host and change directory to it. Next step is to use ansible playbooks to do all the heavy lifting. We have to setup the environment.
cd ansible
virtualenv .venv
source .venv/bin/activate
pip install -r requirements.txt
Run the Ansible playbook to configure our host
ansible-playbook -i production site.yaml
For running playbook on the local host use localhost inventory
ansible-playbook -i localhost site.yaml
To deploy simple PHP application use project Simple PHP Application using docker-compose
command
git clone https://github.com/cimermanGregor/simple_php_application.git
cd simple_php_application
mv docker-compose-dockerhub.yaml docker-compose.yaml
docker-compose up -d