Created
June 21, 2013 17:00
-
-
Save treydock/5832658 to your computer and use it in GitHub Desktop.
Basic Vagrantfile for developing Puppet modules.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
def home | |
File.expand_path('~') | |
end | |
# Define 10GB disks to attach to VM | |
def extra_disks | |
[ | |
{:path => File.join(home, 'vagrant/sdb.vdi'), :size => 10*1024}, | |
{:path => File.join(home, 'vagrant/sdc.vdi'), :size => 10*1024}, | |
] | |
end | |
$script = <<SCRIPT | |
rpm -ivh http://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-7.noarch.rpm &>/dev/null | |
yum -y install puppet puppet-server 2>/dev/null | |
mkdir -p /etc/puppet/modules | |
cat >> /etc/puppet/hiera.yaml << EOF | |
--- | |
:logger: noop | |
EOF | |
cat >> /tmp/puppet_apply_host.pp << EOF | |
host { 'puppet': | |
ip => '127.0.0.1', | |
} | |
EOF | |
puppet apply /tmp/puppet_apply_host.pp | |
/etc/init.d/puppetmaster start | |
cat >> /tmp/puppet_apply_packages.pp << EOF | |
package { 'git': ensure => present } | |
EOF | |
puppet apply /tmp/puppet_apply_packages.pp | |
puppet module install puppetlabs-stdlib --modulepath /etc/puppet/modules | |
SCRIPT | |
Vagrant.configure("2") do |config| | |
config.vm.box = 'centos-64-x64-vbox4210-nocm' | |
config.vm.box_url = 'http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box' | |
# Share Puppet module into VM | |
#config.vm.synced_folder "<local path to module>", "/etc/puppet/modules/mymodule" | |
config.vm.hostname = 'main.vm' | |
config.vm.provider :virtualbox do |vb| | |
# Boot with GUI mode | |
vb.gui = true | |
# Example of adding block devices to VM | |
#extra_disks.each_with_index do |disk, index| | |
# vb.customize ["createhd", "--filename", disk[:path], "--size", disk[:size]] | |
# vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", index+1, "--device", 0, "--type", "hdd", "--medium", disk[:path]] | |
#end | |
end | |
config.vm.provision :shell, :inline => $script | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment