Provisioning your environment
Leveraging Vagrant, Ansible, and AWS
Provisioning your environment
Rich Gwozdz, Spatial Development International
Provisioning includes: • Installing software (Apache, PGRestAPI, Postgres) • Adding data (restore databases) • Configuration (configure Apache) • Anything needed to run your server application
Often executed via SSH session and bash scripting:
# Install Postgres$ apt-get postgresql-9.4-postgis-2.1……# Trust Connections$ sudo nano /etc/postgres/9.4/main/pg_hba.conf
Provisioning your environment
Rich Gwozdz, Spatial Development International
You can provision with bash alone; requires careful scripting • variables • conditionals • http requests • file transfers
Enter Provisioning Frameworks: • ease provisioning script development • provided tested, maintained modules • provide a sharing infrastructure
Provisioning your environment
Rich Gwozdz, Spatial Development International
Ansible: simple & straightforward • simple and straightforward • YAML • SSH
Provisioning your environment
Rich Gwozdz, Spatial Development International
Ansible playbook
Provisioning your environment
Rich Gwozdz, Spatial Development International
hosts: A group of target servers listed in:
/etc/ansible/hosts
[ec2s] 123.4.5.6
Ansible playbook
Provisioning your environment
Rich Gwozdz, Spatial Development International
var_files: files containing variables/settings to be used
in all task
Ansible playbook
Provisioning your environment
Rich Gwozdz, Spatial Development International
role: a role is a set of tasks that address a discrete
unit of work. Easily shared across playbooks
Ansible playbook
Provisioning your environment
Rich Gwozdz, Spatial Development International
handler: helper functions
Ansible playbook
Provisioning your environment
Rich Gwozdz, Spatial Development International
tasks: individual plays not grouped into roles
Ansible playbook
Provisioning your environment
Rich Gwozdz, Spatial Development International
{{ my_var }} : example of variable usage
Ansible playbook
Provisioning your environment
Rich Gwozdz, Spatial Development International
# Run playbook$ ansible-playbook -u ubuntu playbook.yml
Provisioning your environment
Rich Gwozdz, Spatial Development International
Ansible Mangement Node • Separate server: configured for SSH with target hosts • Local machine: but requires config changes - could get out of sync • Vagrant VM: distribute it via Git!
Provisioning your environment
Rich Gwozdz, Spatial Development International
Vagrant VM as Ansible Mangement Node
Vagrant provides “lightweight, reproducible, and portable development
environments” (i.e., server VMs) with VirtualBox and some other goodies
Provisioning your environment
Rich Gwozdz, Spatial Development International
Vagrant VM as Ansible Mangement Node
Provisioning your environment
Rich Gwozdz, Spatial Development International
Vagrant VM as Ansible Mangement Node
Why? • Vagrant VMs are distributable by Git repos • Everyone’s Management node would be identical • Can double as a local deployment of your environment
Cloned Git repo
Provisioning your environment
Rich Gwozdz, Spatial Development International
Vagrant VM as Ansible Mangement Node AND Target host
Local dev environment = deployment environment
Cloned Git repo
Provisioning your environment
Rich Gwozdz, Spatial Development International
Additional Ansible goodies Great AWS support• Create, delete EC2 • Create, delete Security Groups • Set Elastic IPs • Set EC2s as provisioning target hosts via tags rather than hard-coded
IPs
Ansible Galaxy• Hub for find, reusing, sharing Ansible roles (kind of like npm)
Provisioning your environment
Rich Gwozdz, Spatial Development International
Questions?
Top Related