|
| 1 | +# -*- mode: ruby -*- |
| 2 | +# vi: set ft=ruby : |
| 3 | + |
| 4 | +VAGRANTFILE_API_VERSION = "2" |
| 5 | + |
| 6 | +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
| 7 | + ### Define options for all VMs ### |
| 8 | + # Using vagrant-cachier improves performance if you run repeated yum/apt updates |
| 9 | + if defined? VagrantPlugins::Cachier |
| 10 | + config.cache.auto_detect = true |
| 11 | + end |
| 12 | + config.ssh.forward_agent = true |
| 13 | + |
| 14 | + config.vm.provider :virtualbox do |vb| |
| 15 | + vb.customize ["modifyvm", :id, "--memory", "512", "--cpus", "4", "--ioapic", "on"] |
| 16 | + end |
| 17 | + # hack to avoid ubuntu/debian-specific 'stdin: is not a tty' error on startup |
| 18 | + config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" |
| 19 | + |
| 20 | + # distro-agnostic puppet install script from https://github.com/danieldreier/puppet-installer |
| 21 | + config.vm.provision "shell", inline: "curl getpuppet.whilefork.com | bash" |
| 22 | + |
| 23 | + PUPPETMASTER_IP = '192.168.37.23' |
| 24 | + |
| 25 | + config.vm.define :package_install do |node| |
| 26 | + node.vm.box = 'puppetlabs/debian-7.4-64-nocm' |
| 27 | + node.vm.hostname = 'debian7.boxnet' |
| 28 | + node.vm.network :private_network, ip: PUPPETMASTER_IP |
| 29 | + |
| 30 | + # hack to avoid ubuntu/debian-specific 'stdin: is not a tty' error on startup |
| 31 | + node.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" |
| 32 | + |
| 33 | + # distro-agnostic puppet install script from https://github.com/danieldreier/puppet-installer |
| 34 | + node.vm.provision "shell", inline: "curl getpuppet.whilefork.com | bash" |
| 35 | + |
| 36 | + # use a packaged version of puppet-puppet to install dependencies via the forge |
| 37 | + # rm removes symlink from next step for vagrant provision idempotency |
| 38 | + node.vm.provision "shell", |
| 39 | + inline: "rm -rf /etc/puppet/modules/puppet" |
| 40 | + node.vm.provision "shell", |
| 41 | + inline: "if ls /vagrant/pkg/ploperations-puppet-*.tar.gz ; then puppet module install /vagrant/pkg/ploperations-puppet-*.tar.gz; fi" |
| 42 | + end |
| 43 | + |
| 44 | + config.vm.define :shared_folder do |node| |
| 45 | + node.vm.box = 'puppetlabs/debian-7.4-64-nocm' |
| 46 | + node.vm.hostname = 'debian7.boxnet' |
| 47 | + node.vm.network :private_network, ip: PUPPETMASTER_IP |
| 48 | + |
| 49 | + # use a packaged version of puppet-puppet to install dependencies via the forge |
| 50 | + # rm removes symlink from next step for vagrant provision idempotency |
| 51 | + node.vm.provision "shell", |
| 52 | + inline: "rm -rf /etc/puppet/modules/puppet" |
| 53 | + node.vm.provision "shell", |
| 54 | + inline: "if ls /vagrant/pkg/ploperations-puppet-*.tar.gz ; then puppet module install /vagrant/pkg/ploperations-puppet-*.tar.gz; rm -rf /etc/puppet/modules/puppet; fi" |
| 55 | + |
| 56 | + # if this was done as a vagrant shared folder, the previous step either |
| 57 | + # wouldn't run or would overwrite files this approach allows using |
| 58 | + # puppet's facilities for installing dependencies while also keeping a |
| 59 | + # shared folder to simplify development |
| 60 | + node.vm.provision "shell", |
| 61 | + inline: "ln -s /vagrant /etc/puppet/modules/puppet" |
| 62 | + end |
| 63 | + |
| 64 | + config.vm.define :agent do |node| |
| 65 | + node.vm.box = 'puppetlabs/debian-7.4-64-nocm' |
| 66 | + node.vm.hostname = 'debian7agent.boxnet' |
| 67 | + node.vm.network :private_network, ip: "192.168.37.25" |
| 68 | + node.vm.provision "shell", |
| 69 | + inline: "if ! grep #{PUPPETMASTER_IP} /etc/hosts; then echo '#{PUPPETMASTER_IP} puppet' >> /etc/hosts; fi" |
| 70 | + end |
| 71 | +end |
0 commit comments