forked from BojanI27/saltstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
masterless.sh
executable file
·60 lines (49 loc) · 1.86 KB
/
masterless.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
51
52
53
54
55
56
57
58
59
#!/bin/bash
set -e
if [ -z "$1" ]
then
echo "The first argument should be the role"
exit
fi
if [ -n "$1" ]
then
ROLE=$1
fi
if ! ( command lsb_release );then
apt-get update
apt-get -y install lsb-release wget gnupg
fi
version=$(lsb_release -cs)
if [ $version != "jessie" ] && [ $version != "xenial" ] && [ $version != "stretch" ] && [ $version != "buster" ]; then
echo "OS not supported"
false
fi
if [ $version == "buster" ]; then
wget -O - https://repo.saltstack.com/py3/debian/10/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add -
echo 'deb http://repo.saltstack.com/py3/debian/10/amd64/latest buster main' > /etc/apt/sources.list.d/salt.list
fi
if [ $version == "jessie" ]; then
wget -O - https://repo.saltstack.com/apt/debian/8/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add -
echo 'deb http://repo.saltstack.com/apt/debian/8/amd64/latest jessie main' > /etc/apt/sources.list.d/salt.list
fi
if [ $version == "stretch" ]; then
wget -O - https://repo.saltstack.com/apt/debian/9/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add -
echo 'deb http://repo.saltstack.com/apt/debian/9/amd64/latest stretch main' > /etc/apt/sources.list.d/salt.list
fi
if [ $version == "xenial" ]; then
wget -O - https://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add -
echo 'deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest xenial main' > /etc/apt/sources.list.d/salt.list
fi
apt-get update -y
apt-get install python-pip --no-install-recommends -y
apt-get install salt-minion python-pip -y
cd "$(dirname "$0")"
mkdir /srv/{pillar,reactor}
cp -R salt /srv/
cp -R pillar/* /srv/pillar
cp -R reactor/* /srv/reactor
echo "file_client: local" >> /etc/salt/minion
echo "role: $ROLE" > /etc/salt/grains
service salt-minion restart
#setup pillars
echo "Setup pillars and run salt-call --local state.highstate or salt-call --local state.apply"