Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

whoami ● Brazilian, living in Amsterdam since 2012 ● PHP developer with sysadmin background | devop ● Author of Vagrant Cookbook on LeanPub and phansible.com

Slide 3

Slide 3 text

What to expect from this talk 1)Quick Vagrant overview 2)Provisioning with Ansible 3)Quickly getting started with Phansible (demo)

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Why Vagrant? ● Reproducible and portable development environment ● Enables easier code collaboration ● Backend env tests / benchmark ● Automation Tools learning and testing

Slide 6

Slide 6 text

Important Terms ● Host and Guest ● Provider ● Provisioner ● Vagrantfile

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

1.1 Ansible Overview ● Simple and Powerful ● Tasks defined with YAML ● Sequential Execution ● Modules Directory: Ansible Galaxy ● Requires installation of Ansible in the Host

Slide 10

Slide 10 text

1.2 Vagrantfile Vagrant.configure("2") do |config| config.vm.box = "hashicorp/precise64" config.vm.provision "ansible" do |ansible| ansible.playbook = "playbook.yml" end end

Slide 11

Slide 11 text

1.3 The Playbook # playbook.yml --- - hosts: all sudo: true tasks: - name: Update apt-cache apt: update_cache=yes - name: Install Nginx apt: pkg=nginx state=latest

Slide 12

Slide 12 text

1.4 Playbook x Manifest #playbook.yml --- - hosts: all sudo: true tasks: - name: Update apt-cache apt: update_cache=yes - name: Install Nginx apt: pkg=nginx state=latest #default.pp exec { 'apt-get update': command => '/usr/bin/apt-get update' } package { 'nginx': ensure => "installed", require => Exec['apt-get update'], }

Slide 13

Slide 13 text

DEMO 1 basic playbook

Slide 14

Slide 14 text

Writing Playbooks

Slide 15

Slide 15 text

2.1 Variables --- - hosts: all sudo: yes vars: web_server: nginx tasks: - name: Install {{ web_server }} apt: pkg={{ web_server }} state=latest

Slide 16

Slide 16 text

2.1 Variables - arrays tasks: - name: Install Packages apt: pkg={{ item }} state=latest with_items: - nginx - php5-fpm - git

Slide 17

Slide 17 text

2.1 Variables - arrays --- - hosts: all sudo: yes vars: sys_packages: [ 'nginx', 'php5-fpm', 'git' ] tasks: - name: Install Packages apt: pkg={{ item }} state=latest with_items: sys_packages

Slide 18

Slide 18 text

2.1 Variables - facts ● Information discovered from systems ● Globally available ● Example: ansible_eth0.ipv4.address "ansible_eth0": { "active": true, "device": "eth0", "ipv4": { "address": "162.243.203.85", "netmask": "255.255.255.0", "network": "162.243.203.0" }, "ipv6": [ { "address": "fe80::601:23ff:fe9c:8a01", "prefix": "64", "scope": "link" } ], "macaddress": "04:01:23:9c:8a:01", "mtu": 1500, "promisc": false, "type": "ether" },

Slide 19

Slide 19 text

2.2 Templates ServerAdmin webmaster@localhost DocumentRoot {{ doc_root }} AllowOverride All Require all granted

Slide 20

Slide 20 text

2.2 Templates - Usage - name: Change default apache vhost template: src=templates/apache.tpl dest=/etc/apache2/sites-available/000-default.conf

Slide 21

Slide 21 text

2.3 Handlers (services) --- - hosts: all sudo: yes vars: - doc_root: /vagrant tasks: - name: Change default apache vhost template: src=templates/apache.tpl dest=/etc/apache2/sites- available/000-default.conf notify: restart apache handlers: - name: restart apache service: name=apache2 state=restarted

Slide 22

Slide 22 text

DEMO 2 Variables, templates, handlers

Slide 23

Slide 23 text

2.2 Templates ServerAdmin webmaster@localhost DocumentRoot {{ doc_root }} AllowOverride All Require all granted

Slide 24

Slide 24 text

Organization

Slide 25

Slide 25 text

3.1 Including Tasks --- - hosts: all sudo: true vars: doc_root: /vagrant/web tasks: - include: tasks/init.yml - include: tasks/nginxphp.yml handlers: - name: restart nginx service: name=nginx state=restarted

Slide 26

Slide 26 text

3.2 Roles . ├── playbook.yml └── roles ├── init │ └── tasks │ └── main.yml └── nginxphp ├── handlers │ └── main.yml ├── tasks │ └── main.yml └── templates └── vhost.tpl #playbook.yml --- - hosts: all sudo: true vars: doc_root: /vagrant/web roles: - init - nginxphp

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

DEMO 3 phansible

Slide 31

Slide 31 text

Vagrant Cookbook Get a special discount with this coupon http://bit.ly/vc-dc4devs

Slide 32

Slide 32 text

Questions?

Slide 33

Slide 33 text

erikaheidi.com/vagrant https://joind.in/1166 3