Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Start using vagrant now!

794 views

Published on

How to improve development using vagrant, puppet, ansible

Published in: Internet
  • Be the first to comment

Start using vagrant now!

  1. 1. Local development with Vagrant Andriy Podanenko Software Architect, DevOp Propeople @podarok
  2. 2. Plan ● What is Vagrant? ● Provisioning, puppet, ansible ● Generating configs with puphpet.com ● How puphpet.com works internally
  3. 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
  4. 4. Vagrant commands ● vagrant up ● vagrant ssh ● vagrant provision ● vagrant halt ● vagrant destroy ● vagrant reload --provision
  5. 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. 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
  7. 7. Vagrant boxes ● https://vagrantcloud.com ● http://www.vagrantbox.es
  8. 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. 9. Vagrant provisioning ● Shell ● Puppet (model driven) ● Chef (procedural) ● Ansible ● Salt ● Docker ● ...
  10. 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
  11. 11. puppet -> manifest.pp
  12. 12. - hosts: demovmbox ansible -> playbook.yml 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 }}"
  13. 13. PuPHPet.com Demo
  14. 14. vagrant up demo Demo
  15. 15. PuPHPet.com
  16. 16. PuPHPet.com ● All configs in puphpet/config.yaml ● Uses puppet librarian (Puppetfile)
  17. 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. 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)
  19. 19. PS. Drupal related tree/workflow
  20. 20. 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
  21. 21. Local development with Vagrant Questions? Andriy Podanenko Software Architect Propeople @podarok

×