Last active
December 20, 2015 14:09
-
-
Save treydock/6144275 to your computer and use it in GitHub Desktop.
Vagrantfile for ZFS on Linux testing
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 : | |
# References | |
# [1] - https://github.com/treydock/puppet-zfsonlinux/tree/development_zpool_type | |
module LocalHelper | |
def self.home | |
File.expand_path('~') | |
end | |
def self.module_dir | |
File.dirname(__FILE__) | |
end | |
def self.module_name | |
File.basename(LocalHelper.module_dir) | |
end | |
def self.extra_disks | |
[ | |
{:path => "#{home}/vagrant/sdb.vdi", :size => 10*1024}, | |
{:path => "#{home}/vagrant/sdc.vdi", :size => 10*1024}, | |
{:path => "#{home}/vagrant/sdd.vdi", :size => 10*1024}, | |
{:path => "#{home}/vagrant/sde.vdi", :size => 10*1024}, | |
{:path => "#{home}/vagrant/sdf.vdi", :size => 10*1024}, | |
{:path => "#{home}/vagrant/sdg.vdi", :size => 10*1024}, | |
{:path => "#{home}/vagrant/sdh.vdi", :size => 10*1024}, | |
{:path => "#{home}/vagrant/sdi.vdi", :size => 10*1024}, | |
{:path => "#{home}/vagrant/sdj.vdi", :size => 10*1024}, | |
{:path => "#{home}/vagrant/sdk.vdi", :size => 10*1024}, | |
] | |
end | |
end | |
$script = <<SCRIPT | |
rpm -ivh http://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-7.noarch.rpm &>/dev/null | |
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.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| | |
# CentOS base box | |
config.vm.box = 'centos-64-x64-vbox4210' | |
config.vm.box_url = 'http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210.box' | |
# Scientific Linux base box | |
#config.vm.box = 'scientific-64-x64-vb4210' | |
#config.vm.box_url = 'http://yum.tamu.edu/vagrant/scientific-64-x64-vb4210.box' | |
config.vm.hostname = 'main.vm' | |
# Mount local puppet module into VM | |
config.vm.synced_folder LocalHelper.module_dir, "/etc/puppet/modules/#{LocalHelper.module_name}" | |
# Mount testing module into VM | |
# Refer to [1] | |
#config.vm.synced_folder "spec/system/modules/zpool", "/etc/puppet/modules/zpool" | |
config.vm.provider :virtualbox do |vb| | |
# Boot with GUI mode | |
vb.gui = true | |
# Adds block devices to build test zpools | |
LocalHelper.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 | |
# Run provisioning shell script | |
config.vm.provision :shell, :inline => $script | |
# Provision using Puppet | |
# Refer to [1] for files referenced | |
#config.vm.provision :puppet do |puppet| | |
#puppet.manifests_path = "spec/system/manifests" | |
#puppet.manifest_file = "base.pp" | |
#puppet.pp_path = '/etc/puppet' | |
#puppet.options = '--modulepath /etc/puppet/modules' | |
#end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment