Андрей Поданенко - start using vagrant now!
Post on 12-Jul-2015
79 Views
Preview:
TRANSCRIPT
Local development with Vagrant
Andriy PodanenkoSoftware Architect, DevOpPropeople@podarok
Plan
● What is Vagrant?● Provisioning, puppet, ansible● Generating configs with puphpet.com● How puphpet.com works internally
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
Vagrant commands
● vagrant up● vagrant ssh● vagrant provision● vagrant halt● vagrant destroy● vagrant reload --provision
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
Vagrant configuration● Ruby syntax● Box, ram, cpuVagrant.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
Vagrant boxes
● https://vagrantcloud.com● http://www.vagrantbox.es
Vagrant configuration
● Network
● Sync folders
● Nfs is faster than native. Try latest vagrant with rsync
Vagrant.configure("2") do |config| config.vm.network "private_network", ip: "192.168.50.4"end
Vagrant.configure("2") do |config| config.vm.synced_folder "project/", "/var/www/project"end
Vagrant provisioning
● Shell● Puppet (model driven)● Chef (procedural)● Ansible● Salt● Docker● ...
Combining provisioners# Shell provisionconfig.vm.provision "shell" do |s| s.path = "puphpet/shell/initial-setup.sh" s.args = "/vagrant/puphpet"end
# Ansible provisionconfig.vm.provision "ansible" do |ansible| ansible.playbook = "playbook.yml"end
# Puppet provisionconfig.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
puppet -> manifest.pp
ansible -> playbook.yml- hosts: demovmbox connection: local gather_facts: no
vars: drupal_user: drupalcamplviv drupal_pass: ilovelviv installation_profile_name: presentation mysql_user: drupal mysql_pass: drupal mysql_db: drupal
tasks: - name: Droping drupal database mysql_db: name={{ mysql_db }} state=absent
- name: Creating drupal database mysql_db: name={{ mysql_db }} state=present
- name: Installing drupal sudo: yes shell: "drush -y si {{ installation_profile_name }} --db-url=mysql://{{ mysql_user }}:{{ mysql_pass }}@127.0.0.1:/{{ mysql_db }} --account-name={{ drupal_user }} --account-pass={{ drupal_pass }}"
PuPHPet.com
Demo
vagrant up demo
Demo
PuPHPet.com
PuPHPet.com
● All configs in puphpet/config.yaml● Uses puppet librarian (Puppetfile)
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
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)
PS. Drupal related tree/workflow
Usefull links● http://puphpet.drupal.ua/● http://puphpet.com●● http://www.puppetcookbook.com/● https://docs.vagrantup.com/v2/provisioning● http://docs.ansible.com/playbooks.html●● https://github.com/podarok/ansible-vagrant-examples●● https://www.drupal.org/project/vdd
Local development with Vagrant
Andriy PodanenkoSoftware ArchitectPropeople@podarok
Questions?
top related