provisioning your environment with vagrant and ansible
TRANSCRIPT
![Page 1: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/1.jpg)
Provisioning your environment
Leveraging Vagrant, Ansible, and AWS
![Page 2: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/2.jpg)
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
![Page 3: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/3.jpg)
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
![Page 4: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/4.jpg)
Provisioning your environment
Rich Gwozdz, Spatial Development International
Ansible: simple & straightforward • simple and straightforward • YAML • SSH
![Page 5: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/5.jpg)
Provisioning your environment
Rich Gwozdz, Spatial Development International
Ansible playbook
![Page 6: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/6.jpg)
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
![Page 7: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/7.jpg)
Provisioning your environment
Rich Gwozdz, Spatial Development International
var_files: files containing variables/settings to be used
in all task
Ansible playbook
![Page 8: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/8.jpg)
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
![Page 9: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/9.jpg)
Provisioning your environment
Rich Gwozdz, Spatial Development International
handler: helper functions
Ansible playbook
![Page 10: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/10.jpg)
Provisioning your environment
Rich Gwozdz, Spatial Development International
tasks: individual plays not grouped into roles
Ansible playbook
![Page 11: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/11.jpg)
Provisioning your environment
Rich Gwozdz, Spatial Development International
{{ my_var }} : example of variable usage
Ansible playbook
![Page 12: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/12.jpg)
Provisioning your environment
Rich Gwozdz, Spatial Development International
# Run playbook$ ansible-playbook -u ubuntu playbook.yml
![Page 13: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/13.jpg)
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!
![Page 14: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/14.jpg)
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
![Page 15: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/15.jpg)
Provisioning your environment
Rich Gwozdz, Spatial Development International
Vagrant VM as Ansible Mangement Node
![Page 16: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/16.jpg)
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
![Page 17: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/17.jpg)
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
![Page 18: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/18.jpg)
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)
![Page 19: Provisioning your Environment with Vagrant and Ansible](https://reader033.vdocument.in/reader033/viewer/2022042706/5885f02c1a28ab864f8b5b13/html5/thumbnails/19.jpg)
Provisioning your environment
Rich Gwozdz, Spatial Development International
Questions?