Last active
March 15, 2019 17:07
-
-
Save tehmaspc/7592823 to your computer and use it in GitHub Desktop.
Create Multi-VM Vagrant Setup w/ Multi-Provisioners (shell, puppet). The following example shows 5 VMs being created via a single Vagrantfile. Each VM has as unique configuration and uses both a shell provisioner and a Puppet provisioner. The 'default' VM exists for serverspec 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
#!/bin/bash | |
# these hostname values should match the Vagrantfile box configurations | |
STAGE='/etc/first_stage' | |
if [ ! -e $STAGE ]; then | |
echo '10.0.1.100 gfs-s1' >> /etc/hosts | |
echo '10.0.1.101 gfs-s2' >> /etc/hosts | |
echo '10.0.1.102 gfs-s3' >> /etc/hosts | |
echo '10.0.1.105 gfs-c1' >> /etc/hosts | |
touch $STAGE | |
fi |
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
include 'glusterfs' |
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
include 'glusterfs' | |
# class { 'glusterfs::client': | |
# # server => 'gfs-s1', # the 'primary' glusterfs node we will attempt to mount the volume from | |
# server => '10.0.1.100', | |
# backup_server => '10.0.1.101', | |
# } |
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
include 'glusterfs' | |
# class { 'glusterfs::initiate': | |
# # use hostnames when the same hostnames have been added to the /etc/hosts files of all vagrant boxes; | |
# # use ip addresses when testing for functionality but we don't need to worry about using DNS lookups. | |
# # NOTE1: glusterfs perfers that peers are referenced by their DNS hostnames. | |
# # NOTE2: see the Vagrantfile for the multi-vm setup | |
# # | |
# # peers => [ '10.0.1.101', '10.0.1.102' ], # peers relative to "primary" gluster node gfs-s1 (10.0.1.100) | |
# peers => [ 'gfs-s2', 'gfs-s3' ], | |
# } |
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 : | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
DEFAULT_NETWORK_BRIDGE = "en0: Wi-Fi (AirPort)" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
# All Vagrant configuration is done here. The most common configuration | |
# options are documented and commented below. For a complete reference, | |
# please see the online documentation at vagrantup.com. | |
# Every Vagrant virtual environment requires a box to build off of. | |
config.vm.box = "magnum-vagrant" | |
# The url from where the 'config.vm.box' box will be fetched if it | |
# doesn't already exist on the user's system. | |
# For 'magnum-vagrant' we acquire vagrant boxes from: http://puppet-vagrant-boxes.puppetlabs.com/ | |
config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210.box" | |
# Create a forwarded port mapping which allows access to a specific port | |
# within the machine from a port on the host machine. In the example below, | |
# accessing "localhost:8080" will access port 80 on the guest machine. | |
# config.vm.network :forwarded_port, guest: 80, host: 8080 | |
# Create a private network, which allows host-only access to the machine | |
# using a specific IP. | |
# config.vm.network :private_network, ip: "192.168.33.10" | |
# config.vm.network :public_network, :bridge => DEFAULT_NETWORK_BRIDGE | |
# Create a public network, which generally matched to bridged network. | |
# Bridged networks make the machine appear as another physical device on | |
# your network. | |
# config.vm.network :public_network | |
# If true, then any SSH connections made will enable agent forwarding. | |
# Default value: false | |
# config.ssh.forward_agent = true | |
# Share an additional folder to the guest VM. The first argument is | |
# the path on the host to the actual folder. The second argument is | |
# the path on the guest to mount the folder. And the optional third | |
# argument is a set of non-required options. | |
# config.vm.synced_folder "../data", "/vagrant_data" | |
# Enable provisioning with Puppet stand alone. Puppet manifests | |
# are contained in a directory path relative to this Vagrantfile. | |
# config.vm.provision :puppet do |puppet| | |
# puppet.manifests_path = "./.vagrant_puppet" | |
# puppet.manifest_file = "init.pp" | |
# puppet.module_path = [ "../", "./spec/fixtures/modules/" ] | |
# puppet.options = "--verbose" | |
# end | |
# the default vm for serverspec testing | |
config.vm.define "default" do |default| | |
default.vm.box = 'magnum-vagrant' | |
default.vm.provision :puppet do |puppet| | |
puppet.manifests_path = "./.vagrant_puppet" | |
puppet.manifest_file = "init.pp" | |
puppet.module_path = [ "../", "./spec/fixtures/modules/" ] | |
puppet.options = "--verbose" | |
end | |
end | |
config.vm.define "gfs-s1" do |gfs| | |
gfs.vm.box = 'magnum-vagrant' | |
gfs.vm.network :private_network, ip: "10.0.1.100" | |
gfs.vm.host_name = "gfs-s1" | |
gfs.vm.provision :shell, :path => "./.vagrant_puppet/hosts_setup.sh" | |
gfs.vm.provision :puppet do |puppet| | |
puppet.manifests_path = "./.vagrant_puppet" | |
puppet.manifest_file = "init_primary.pp" | |
puppet.module_path = [ "../", "./spec/fixtures/modules/" ] | |
puppet.options = "--verbose" | |
end | |
end | |
config.vm.define "gfs-s2" do |gfs| | |
gfs.vm.box = 'magnum-vagrant' | |
gfs.vm.network :private_network, ip: "10.0.1.101" | |
gfs.vm.host_name = "gfs-s2" | |
gfs.vm.provision :shell, :path => "./.vagrant_puppet/hosts_setup.sh" | |
gfs.vm.provision :puppet do |puppet| | |
puppet.manifests_path = "./.vagrant_puppet" | |
puppet.manifest_file = "init.pp" | |
puppet.module_path = [ "../", "./spec/fixtures/modules/" ] | |
puppet.options = "--verbose" | |
end | |
end | |
config.vm.define "gfs-s3" do |gfs| | |
gfs.vm.box = 'magnum-vagrant' | |
gfs.vm.network :private_network, ip: "10.0.1.102" | |
gfs.vm.host_name = "gfs-s3" | |
gfs.vm.provision :shell, :path => "./.vagrant_puppet/hosts_setup.sh" | |
gfs.vm.provision :puppet do |puppet| | |
puppet.manifests_path = "./.vagrant_puppet" | |
puppet.manifest_file = "init.pp" | |
puppet.module_path = [ "../", "./spec/fixtures/modules/" ] | |
puppet.options = "--verbose" | |
end | |
end | |
config.vm.define "gfs-c1" do |gfs| | |
gfs.vm.box = 'magnum-vagrant' | |
gfs.vm.network :private_network, ip: "10.0.1.105" | |
gfs.vm.host_name = "gfs-c1" | |
gfs.vm.provision :shell, :path => "./.vagrant_puppet/hosts_setup.sh" | |
gfs.vm.provision :puppet do |puppet| | |
puppet.manifests_path = "./.vagrant_puppet" | |
puppet.manifest_file = "init_client.pp" | |
puppet.module_path = [ "../", "./spec/fixtures/modules/" ] | |
puppet.options = "--verbose" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment