Setup salt provisioning
This commit performs salt provisioning setup by adding salt master to the salt VM and salt minion to all VMs. An /etc/hosts entry for the salt master is added using a shell provisioner. No salt executions are performed yet.
This commit is contained in:
parent
f373d0c639
commit
d1cecfe7a8
3 changed files with 41 additions and 2 deletions
20
Vagrantfile
vendored
20
Vagrantfile
vendored
|
@ -6,18 +6,34 @@ Vagrant.configure("2") do |config|
|
|||
config.vm.post_up_message = nil
|
||||
config.vm.synced_folder ".", "/vagrant", disabled: true
|
||||
|
||||
config.vm.provision "shell",
|
||||
inline: "sed -i 's/^mesg n$/tty -s \\&\\& mesg n/g' /root/.profile"
|
||||
config.vm.provision "shell",
|
||||
path: "scripts/add_salt_to_etc_hosts.sh"
|
||||
config.vm.provision :salt do |salt|
|
||||
salt.masterless = false
|
||||
salt.minion_config = "salt/minion"
|
||||
salt.run_highstate = false
|
||||
salt.install_type = "stable"
|
||||
end
|
||||
|
||||
config.vm.define "salt" do |node|
|
||||
node.vm.hostname = "salt"
|
||||
node.vm.hostname = "salt.gva.dev"
|
||||
node.vm.synced_folder "repos/gvasalt/states", "/srv/salt"
|
||||
node.vm.synced_folder "repos/gvasalt/pillar", "/srv/pillar"
|
||||
node.vm.network "private_network", ip: "172.16.4.10"
|
||||
node.vm.provider "virtualbox" do |vb|
|
||||
vb.memory = "256"
|
||||
end
|
||||
|
||||
node.vm.provision :salt do |salt|
|
||||
salt.install_master = true
|
||||
salt.minion_id = "salt"
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "mq" do |node|
|
||||
node.vm.hostname = "mq"
|
||||
node.vm.hostname = "mq.gva.dev"
|
||||
node.vm.network "private_network", ip: "172.16.4.20"
|
||||
node.vm.provider "virtualbox" do |vb|
|
||||
vb.memory = "256"
|
||||
|
|
1
salt/minion
Normal file
1
salt/minion
Normal file
|
@ -0,0 +1 @@
|
|||
# empty minion config
|
22
scripts/add_salt_to_etc_hosts.sh
Normal file
22
scripts/add_salt_to_etc_hosts.sh
Normal file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
ip_address="172.16.4.10"
|
||||
host_name="salt.gva.dev"
|
||||
|
||||
matches_in_host="$(grep -n $host_name /etc/hosts | cut -f1 -d:)"
|
||||
host_entry="${ip_address} ${host_name} salt"
|
||||
|
||||
if [ ! -z "$matches_in_host" ]
|
||||
then
|
||||
echo "Updating existing hosts entry"
|
||||
|
||||
echo $matches_in_host | while read -r line_number; do
|
||||
sed -i "${line_number}s/.*/${host_entry}/" /etc/hosts
|
||||
done
|
||||
else
|
||||
echo "Adding new hosts entry"
|
||||
|
||||
echo "${host_entry}" >> /etc/hosts
|
||||
fi
|
Loading…
Reference in a new issue