forked from andaok/salt-kube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
81 lines (76 loc) · 2 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# -*- mode: ruby -*-
# vi: set ft=ruby :
hosts = {
"salt" => "172.16.10.10",
"minion01" => "172.16.10.21",
"minion02" => "172.16.10.22"
}
$script = <<SCRIPT
cat > /etc/hosts << EOF
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
172.16.10.21 minion01
172.16.10.22 minion02
172.16.10.10 salt
EOF
swapoff -a
sed -i '/swap/d' /etc/fstab
yum update -y
if [[ $(hostname -s) == 'salt' ]]; then
mkdir -p /etc/salt
echo -e 'roles:\n - salt\n - ca\n - kube-master\n - etcd\n' > /etc/salt/grains
curl -L https://bootstrap.saltstack.com -o /tmp/install_salt.sh
sh /tmp/install_salt.sh -M stable 2018.3.3
cat > /etc/salt/master << EOFM
auto_accept: True
peer:
.*:
- .*
peer_run:
.*:
- .*
file_roots:
local:
- /srv/salt/local
- /srv/salt/local/roles
- /srv/formulas
pillar_roots:
local:
- /srv/pillar/local
EOFM
systemctl restart salt-master
else
mkdir -p /etc/salt
echo -e 'roles:\n - kube-minion\n - etcd\n' > /etc/salt/grains
curl -L https://bootstrap.saltstack.com -o /tmp/install_salt.sh
sh /tmp/install_salt.sh stable 2018.3.3
fi
cat > /etc/salt/minion << EOFS
master: salt
startup_states: highstate
multiprocessing: false
saltenv: local
EOFS
systemctl restart salt-minion
yum install https://forensics.cert.org/centos/cert/7/x86_64/python-M2Crypto-0.26.0-0.x86_64.rpm -y
SCRIPT
Vagrant.configure("2") do |config|
hosts.each do |name, ip|
config.vm.define name do |machine|
machine.vm.box = "bento/centos-7.6"
machine.vm.box_check_update = false
machine.ssh.insert_key = false
machine.vm.hostname = name
machine.vm.network :private_network, ip: ip
machine.vm.provision "shell", inline: $script
machine.vm.synced_folder './dist', '/srv'
machine.vm.provider "virtualbox" do |v|
v.name = name
if v.name == 'salt'
v.customize ["modifyvm", :id, "--memory", 4048]
else
v.customize ["modifyvm", :id, "--memory", 4048]
end
end
end
end
end