On Github lpopov / vagrant-puppet-presentation
Created by Lyubomir Popov / @lpopov
$ vagrant init user/box # Create Vagrantfile for specified base box $ vagrant up # Create a VM if needed and boot $ vagrant reload # After every change to Vagrantfile $ vagrant halt # Turns off the VM $ vagrant destroy # Deletes the VM $ vagrant suspend # Suspends the VM $ vagrant resume # Resumes the VM $ vagrant ssh # Log in using ssh $ vagrant status # Status of the VM
Install Vagrant and Virtualbox (www.vagrantup.com and www.virtualbox.org)
$ vagrant init hashicorp/precise32 $ vagrant up $ vagrant ssh
Created with 'vagrant init hashicorp/precise32'
VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "hashicorp/precise32" end
Adding networking
VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "hashicorp/precise32" config.vm.network "private_network", ip: "10.0.1.10" end
Port forwarding
VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "hashicorp/precise32" config.vm.network "private_network", ip: "10.0.1.10" config.vm.network "forwarded_port", guest: 80, host: 8080 end
Shared folders
VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "hashicorp/precise32" config.vm.network "private_network", ip: "10.0.1.10" config.vm.network "forwarded_port", guest: 80, host: 8080 config.vm.synced_folder "./", "/vagrant" end
VM configuration (RAM, CPU, Network)
VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "hashicorp/precise32" config.vm.network "private_network", ip: "10.0.1.10" config.vm.network "forwarded_port", guest: 80, host: 8080 config.vm.synced_folder "./", "/vagrant" config.vm.provider :virtualbox do |vb| # vb.customize ["startvm", :id, "--type", "gui"] vb.customize ["modifyvm", :id, "--memory", "512"] vb.customize ["modifyvm", :id, "--cpus", "1"] vb.customize ["modifyvm", :id, "--hwvirtex", "on"] vb.customize ["modifyvm", :id, "--audio", "none"] vb.customize ["modifyvm", :id, "--nictype1", "virtio"] vb.customize ["modifyvm", :id, "--nictype2", "virtio"] end end
Provisioner setup
VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "hashicorp/precise32" config.vm.network "private_network", ip: "10.0.1.10" config.vm.network "forwarded_port", guest: 80, host: 8080 config.vm.synced_folder "./", "/vagrant" config.vm.provider :virtualbox do |vb| # vb.customize ["startvm", :id, "--type", "gui"] vb.customize ["modifyvm", :id, "--memory", "512"] vb.customize ["modifyvm", :id, "--cpus", "1"] vb.customize ["modifyvm", :id, "--hwvirtex", "on"] vb.customize ["modifyvm", :id, "--audio", "none"] vb.customize ["modifyvm", :id, "--nictype1", "virtio"] vb.customize ["modifyvm", :id, "--nictype2", "virtio"] end config.vm.provision "puppet" do |puppet| puppet.manifests_path = "puppet/manifests" puppet.module_path = "puppet/modules" puppet.manifest_file = "site.pp" end end
class php { package { ['php5', 'php5-cli', 'libapache2-mod-php5', 'php5-mysql', 'php5-sqlite', 'php5-tidy', 'php5-xdebug']: ensure => present; } }
$ tree --prune puppet puppet ├── manifests │ └── site.pp └── modules ├── apache │ ├── files │ │ └── vagrant-vhost.conf │ └── manifests │ └── init.pp ├── mysql │ └── manifests │ └── init.pp └── php ├── files │ └── php.ini └── manifests └── init.pp 10 directories, 6 files