Vagrant - PugMI
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Vagrant - PugMI

  • 999 views
Uploaded on

Base usage of Vagrant and my experience. ...

Base usage of Vagrant and my experience.
Why Vagrant? What is Vagrant?

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
999
On Slideshare
931
From Embeds
68
Number of Embeds
7

Actions

Shares
Downloads
8
Comments
0
Likes
2

Embeds 68

http://gianarb.github.io 37
http://localhost 14
https://www.linkedin.com 5
http://www.linkedin.com 4
http://gianarb.it 4
http://en.gianarb.it 3
https://www.rebelmouse.com 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Development environments made easy
  • 2. Why?! Gianluca - @GianArb – GianArb – gianarb.github.io
  • 3. Vagrant Command Line Tool Gianluca - @GianArb – GianArb – gianarb.github.io
  • 4. Box vagrant box add <name> <url> <*provider> Vagrant box list Vagrant box remove <name> <*provider> Gianluca - @GianArb – GianArb – gianarb.github.io
  • 5. $. Vagrant box add precise32 <url> $. Vagrant init precise32 $. Vagrant up Goooo!!! Gianluca - @GianArb – GianArb – gianarb.github.io
  • 6. Providers Virtualbox, VmWare“ Gianluca - @GianArb – GianArb – gianarb.github.io
  • 7. Plugins $. Vagrant plugin install <name> $. Vagrant plugin uninstall <name> $. Vagrant plugin list Gianluca - @GianArb – GianArb – gianarb.github.io
  • 8. Provisioning How can i install my services? Chef Solo - Chef Client Shell – ansiable Puppet apply – puppet Agent Gianluca - @GianArb – GianArb – gianarb.github.io
  • 9. That’s all?! Where are my other commands?! up – halt –suspend – provisioning Reload – destroy - ssh -status Gianluca - @GianArb – GianArb – gianarb.github.io
  • 10. Sharing & Conf This stuff is beautiful Gianluca - @GianArb – GianArb – gianarb.github.io
  • 11. # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant::Config.run do |config| config.vm.box = "precise32" config.vm.box_url = http://“./precise32.box end mode: ruby Gianluca - @GianArb – GianArb – gianarb.github.io
  • 12. Network config.vm.forwardind_port(80, 8080)“ config.vm.network :private_network, IP: ‚192.168.33.111‛ ** Config.VM.Network :public_network * Gianluca - @GianArb – GianArb – gianarb.github.io
  • 13. Network ** Config.VM.Network :public_network, :bridge => ‘en1:Wi-Fi (AirPort)’’ Gianluca - @GianArb – GianArb – gianarb.github.io
  • 14. Provider config.vm.provider :virtualbox do |vb| vb.customize [ "modifyvm", :id, "--cpus", 2, "--memory", "1224"] ““.. end Gianluca - @GianArb – GianArb – gianarb.github.io
  • 15. Share Folders config.vm.synced_folder "~/Sites", "/var/www‛ :owner=> "www-data", :group=> "www-data" Nfs => true ** + + Gianluca - @GianArb – GianArb – gianarb.github.io
  • 16. Share Folders config.vm.synced_folder "~/Sites", "/var/www‛ :owner=> "www-data", :group=> "www-data" Nfs => true ** + + Gianluca - @GianArb – GianArb – gianarb.github.io
  • 17. My Skeleton ** Gianluca - @GianArb – GianArb – gianarb.github.io
  • 18. ** /cookbooks This is my vendor $. git submodule add https://github.com/GianArb/opsworks-cookbooks cookbooks But““ Gianluca - @GianArb – GianArb – gianarb.github.io
  • 19. Who is my Vendor? http://github.com/opscode-cookbooks Gianluca - @GianArb – GianArb – gianarb.github.io
  • 20. Where is my Conf?! config.vm.provision :chef_solo do |chef| Chef.cookbooks_path=[‘my_cookbooks’,‘cookbooks’ chef.add_recipe ‚apt‛ chef.add_recipe ‚apache2‛ chef.Add_recipe ‚apache2::mod_rewrite‛ chef.add_recipe ‚php‛ chef.add_recipe ‚MYSQL‛ .... end Gianluca - @GianArb – GianArb – gianarb.github.io
  • 21. How can I configure my conf? 0.o config.vm.provision :chef_solo do |chef| “. chef.add_recipe ‚MYSQL‛ chef.json = { :mysql=> { :server_root_password => ’root’, :server_debian_password => ’root’, :server_Repl_password => ‘replica’, :bind_address => ‘127.0.0.1’ } } end Gianluca - @GianArb – GianArb – gianarb.github.io
  • 22. config.vm.provision :chef_solo do |chef| “. chef.add_recipe ‚MYSQL‛ chef.json = { :mysql=> { :server_root_password => ’root’, :server_debian_password => ’root’, :server_Repl_password => ‘replica’, :bind_address => ‘127.0.0.1’ } } end Gianluca - @GianArb – GianArb – gianarb.github.io
  • 23. Shell Provisioning config.vm.provision :shell, :inline => ‚echo ‘hello ciao!’‛ OR config.vm.provision :shell, :path=> ‚/path/to/script.sh’‛ Gianluca - @GianArb – GianArb – gianarb.github.io
  • 24. What happen if You can run this Configuration of VM Now? Gianluca - @GianArb – GianArb – gianarb.github.io
  • 25. Where is my virtualhost? Is the moment, Now We are Beginning to Create a custom cookbook for this application Gianluca - @GianArb – GianArb – gianarb.github.io
  • 26. App cookbooks Gianluca - @GianArb – GianArb – gianarb.github.io My_cookbooks/app/attributes/default.rb My_cookbooks/app/recipes/virtualhost.rb My_cookbooks/app/template/default/app.conf.erb
  • 27. My_cookbooks/app/attributes/defau lt.rb Gianluca - @GianArb – GianArb – gianarb.github.io In this file are setting all nodes of recipe configuration default['app']['server_name'] = 'testapp.local' default['app_test']['docroot'] = ‚/vagrant/src‚
  • 28. My_cookbooks/app/recipes/virtualho st.rb Gianluca - @GianArb – GianArb – gianarb.github.io # # Cookbook Name:: app # Recipe:: default # app_name = 'app' app_config = node[app_name] include_recipe "apt" include_recipe "apache2" include_recipe "apache2::mod_php5" # Set up the Apache virtual host web_app app_name do server_name app_config['server_name'] docroot app_config['docroot'] template "#{app_name}.conf.erb" log_dir node['apache']['log_dir'] end
  • 29. …./template/default/app.conf.erb Gianluca - @GianArb – GianArb – gianarb.github.io <VirtualHost *:80> ServerName <%= @params[:server_name] %> ServerAlias <% @params[:server_aliases] && @params[:server_aliases].each do |a| %><%= "#{a}" %> <% end %> DocumentRoot <%= @params[:docroot] %> <Directory <%= @params[:docroot] %>> Options -Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
  • 30. Vagrant-omnibus $. Vagrant plugin install vagrant- omnibus Gianluca - @GianArb – GianArb – gianarb.github.io Vagrant.configure("2") do |config| config.omnibus.chef_version = :latest OR config.omnibus.chef_version = ‚11.4.0‛ “ end
  • 31. Bento Create your custom .box Gianluca - @GianArb – GianArb – gianarb.github.io $. git clone git://github.com/opscode/bento.git $. cd bento $. bundle install $. bundle exec veewee vbox list $. bundle exec veewee vbox build ubuntu-12.04
  • 32. Try now! Gianluca - @GianArb – GianArb – gianarb.github.io $. git clone http://github.com/GianArb/pugMi2013-vagrant $. cd pugMi2013-vagrant $. git submodule init $. git submodule update $. cd cookbooks $. git submodule init $. git submodule update
  • 33. Gianluca - @GianArb – GianArb – gianarb.github.io http://vagrantup.com http://github.com/opscode-cookbooks http://www.vagrantbox.es Irc.freenode.net/#vagrant Irc.freenode.net/#chef https://github.com/opscode/bento https://github.com/schisamo/vagrant-omnibus https://github.com/PUGTorino/application_zf Gianluca Arbezzano me@gianarb.it