Last active
August 29, 2015 14:19
-
-
Save miroswan/be8572a693079207d6c5 to your computer and use it in GitHub Desktop.
Install salt master and two minions w/ Vagrant
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 : | |
# Install landrush if it's not installed. This bash script is saved | |
# into a Ruby var. Landrush allows the nodes to reference each other | |
# by hostname. | |
check_landrush = <<CHECK_LANDRUSH | |
#!/bin/bash | |
plugins="$(vagrant plugin list)" | |
if [ -z "$(echo \"$plugins\" | grep landrush)" ]; then | |
echo "Installing the landrush vagrant plugin" | |
vagrant plugin install landrush | |
fi | |
CHECK_LANDRUSH | |
# Install the salt-master. Checks for binary before installing so it's | |
# idempotent | |
check_salt_master = <<CHECK_SALT_MASTER | |
#!/bin/bash | |
if [ -z "$(which salt)" ]; then | |
echo "##### Disabling the firewawll #####" | |
systemctl stop firewalld | |
systemctl disable firewalld | |
echo "##### Installing salt-master #####" | |
curl -L https://bootstrap.saltstack.com | sudo sh -s -- -MN | |
echo "##### Enabling Salt #####" | |
systemctl start salt-master | |
systemctl enable salt-master | |
fi | |
CHECK_SALT_MASTER | |
# Install the salt-minion. Checks for binary before installing so it's | |
# idempotent | |
check_salt_minion = <<CHECK_SALT_MINION | |
#!/bin/bash | |
if [ -z "$(which salt-call)" ]; then | |
echo "##### Disabling the firewawll #####" | |
systemctl stop firewalld | |
systemctl disable firewalld | |
echo "##### Installing salt-minion #####" | |
curl -L https://bootstrap.saltstack.com | sudo sh | |
echo "##### Enabling Salt #####" | |
systemctl start salt-minion | |
systemctl enable salt-minion | |
fi | |
CHECK_SALT_MINION | |
# Only install landrush if the vagrant command is vagrant up | |
if ARGV.include? "up" | |
# Use system method so we can see the output | |
system "#{check_landrush}" | |
end | |
Vagrant.configure(2) do |config| | |
config.vm.define "master" do |master| | |
master.vm.box = "jayunit100/centos7" | |
master.landrush.enabled = true | |
master.vm.hostname = "salt.vagrant.dev" | |
master.vm.network "private_network", type: "dhcp" | |
master.vm.provider "virtualbox" do |v| | |
v.memory = 1024 | |
end | |
master.vm.provision "shell", inline: "#{check_salt_master}" | |
end | |
config.vm.define "minion1" do |minion1| | |
minion1.vm.box = "jayunit100/centos7" | |
minion1.landrush.enabled = true | |
minion1.vm.hostname = "minion1.vagrant.dev" | |
minion1.vm.network "private_network", type: "dhcp" | |
minion1.vm.provider "virtualbox" do |v| | |
v.memory = 512 | |
end | |
minion1.vm.provision "shell", inline: "#{check_salt_minion}" | |
end | |
config.vm.define "minion2" do |minion2| | |
minion2.vm.box = "jayunit100/centos7" | |
minion2.landrush.enabled = true | |
minion2.vm.hostname = "minion2.vagrant.dev" | |
minion2.vm.network "private_network", type: "dhcp" | |
minion2.vm.provider "virtualbox" do |v| | |
v.memory = 512 | |
end | |
minion2.vm.provision "shell", inline: "#{check_salt_minion}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment