Task steps:
- Create New EC2 instance (ubuntu 16.04 based)
- Update the OS with latest security patches
- Install nginx and enable on boot
- Verify service is up
- Static ami for Ubuntu 16.04 used
- Added static pythin interpeter
- Add pem key to ssh-add agent for SSH
- Used only eu-west-1 region staticly for ease of work
- Used roles for includes
- Used Nginx code for guidance for installation Nginx blog
- boto for dynamic inventory
- health check uses nginx which should return an OK status as well as the string "Everything works (<name of the current environment>)" when reaching the path /health
- Ansible playbook Should supports multiple environments (dev, prod)
Flow of usage
$ ENV=<environment>
$ ansible-playbook -v -i localhost, -e "env=$ENV" provision.yml
$ ansible-playbook -v -e "env=$ENV" -e 'ansible_python_interpreter=/usr/bin/python3' update-os.yml
$ ansible-playbook -v -e "env=$ENV" -e 'ansible_python_interpreter=/usr/bin/python3' webserver.yml
$ ansible-playbook -v -e "env=$ENV" -e 'ansible_python_interpreter=/usr/bin/python3' verify_nginx.yml
- Add private subnets
- Add Backends
- Add destroy tasks
- Add resources only if not exist (SG/VPC etc..)
- .......
FREE