-
Notifications
You must be signed in to change notification settings - Fork 1
/
linux_salt_bootstrap.sh
executable file
·50 lines (40 loc) · 1.49 KB
/
linux_salt_bootstrap.sh
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
#!/usr/bin/env bash
set -e
set -u
readonly MASTER_CONFIG='file_roots:, base:, - /srv/salt, - /srv/formulas, - /srv/salt/roles,pillar_roots:, base:, - /srv/pillar, dev:, - /srv/pillar/dev, production:, - /srv/pillar/production'
function install_salt_repo() {
rpm --import https://archive.repo.saltstack.com/yum/redhat/7/x86_64/archive/2016.3.1/SALTSTACK-GPG-KEY.pub
local repofile='/etc/yum.repos.d/saltstack.repo'
echo '[saltstack-repo]' > $repofile
echo 'name=SaltStack repo for RHEL/CentOS $releasever' >> $repofile
echo 'baseurl=https://archive.repo.saltstack.com/yum/redhat/$releasever/$basearch/archive/2016.3.1' >> $repofile
echo 'enabled=1' >> $repofile
echo 'gpgcheck=1' >> $repofile
echo 'gpgkey=https://archive.repo.saltstack.com/yum/redhat/$releasever/$basearch/archive/2016.3.1/$releaseverSALTSTACK-GPG-KEY.pub' >> $repofile
yum clean all
}
function install_salt_master() {
install_salt_repo
yum install salt-master salt-minion -y
echo -e "$MASTER_CONFIG" | tr ',' '\n' > /etc/salt/master
for service in salt-master salt-minion; do
systemctl enable $service.service
systemctl start $service.service
done
}
function install_salt_minion() {
local master=$1
install_salt_repo
yum install salt-minion -y
echo "master: $master" > /etc/salt/minion
systemctl enable salt-minion.service
systemctl start salt-minion.service
}
main() {
if [[ $1 == 'master' ]]; then
install_salt_master
else
install_salt_minion $2
fi
}
main $@