1. Local development with Vagrant
Andriy Podanenko
Software Architect, DevOp
Propeople
@podarok
2. Plan
● What is Vagrant?
● Provisioning, puppet, ansible
● Generating configs with puphpet.com
● How puphpet.com works internally
3. What is Vagrant
● Layer on top ov virtual machine providers
− Virtualbox
− Vmware
● Command line tool
● Text file to control the settings
● Plenty of boxes available on internet
5. Vagrant up workflow
-> vagrant up
● Obtaining vagrant box (vm image) - once
● Starting virtualbox (vm provider)
● Starting provisioners stack - first time and with
--provision or when -> vagrant provision
-> vm box up and running
-> vagrant ssh
6. Vagrant configuration
● Ruby syntax
● Box, ram, cpu
Vagrant.configure("2") do |config|
config.vm.box = 'ubuntu-1404'
config.vm.box_url = 'http://.../ubuntu-1404-x64.box'
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
end
end
8. Vagrant configuration
● Network
Vagrant.configure("2") do |config|
config.vm.network "private_network", ip: "192.168.50.4"
end
● Sync folders
Vagrant.configure("2") do |config|
config.vm.synced_folder "project/", "/var/www/project"
end
● Nfs is faster than native. Try latest vagrant with rsync
9. Vagrant provisioning
● Shell
● Puppet (model driven)
● Chef (procedural)
● Ansible
● Salt
● Docker
● ...
10. Combining provisioners
# Shell provision
config.vm.provision "shell" do |s|
s.path = "puphpet/shell/initial-setup.sh"
s.args = "/vagrant/puphpet"
end
# Ansible provision
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
end
# Puppet provision
config.vm.provision :puppet do |puppet|
ssh_username = !data['ssh']['username'].nil? ? data['ssh']['username'] : "vagrant"
puppet.facter = {
"ssh_username" => "#{ssh_username}",
"provisioner_type" => ENV['VAGRANT_DEFAULT_PROVIDER'],
}
puppet.manifests_path = "#{data['vm']['provision']['puppet']['manifests_path']}"
puppet.manifest_file = "#{data['vm']['provision']['puppet']['manifest_file']}"
end
16. PuPHPet.com
● All configs in puphpet/config.yaml
● Uses puppet librarian (Puppetfile)
17. Extending configs
● Use another puppet module
− Add it to the Puppetfile
− Modify manifest.pp
● Add another provisioner
− Add it to Vagrantfile
− insert provisioner’s needed files to vagrant tree
18. Contributing to puphpet.com
● Symfony app
● Each config element is a separate bundle that
provides UI and manifest.pp part
● Remember about all OS (debian + centos)