Skip to content

Commit 2a562d0

Browse files
committed
Update 2017-9-2-Saltstack.md
1 parent e8f578c commit 2a562d0

File tree

1 file changed

+104
-3
lines changed

1 file changed

+104
-3
lines changed

_posts/2017-9-2-Saltstack.md

Lines changed: 104 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,111 @@
11
---
22
layout: post
33
title: Setting up my first saltstack
4+
published: true
45
---
5-
6-
Saltstack is a power systems orchestration tool used by sysadmins, developers,and large corporations alike.
6+
# What is Salt?
7+
Saltstack is a power systems orchestration tool used by sysadmins, developers,and large corporations based on the idea of "Infrastructure through code."
78
![_config.yml]({{ site.baseurl }}/images/saltstack.jpg)
89

10+
The official [Saltstack](http://saltstack.com) repo can be found [here](http://github.com/saltstack/salt)
11+
12+
Salt is powered by python and works on any Unix-like operating system, OS X, and windows alike. It's modules are written in Python. There are many features available ranging from simple tasks to more advanced ones.
13+
14+
Let's get started
15+
16+
### Installing your Salt master-
17+
18+
```
19+
curl -L https://bootstrap.saltstack.com -o install_salt.sh
20+
sudo sh install_salt.sh -P -M
21+
```
22+
23+
### Installing your Salt minion-
24+
25+
```
26+
curl -L https://bootstrap.saltstack.com -o install_salt.sh
27+
sudo sh install_salt.sh -P
28+
```
29+
For this example setup, I'll be setting up 1 salt master and 6 minions on CentOS instances from [DigitalOcean](http://digitalocean.com) for multiple reasons. Mostly because they support Salt-cloud. I'll re-touch on this later.
30+
31+
After running the appropriate commands, let's add our master to each minion. Here, my master is riley.science. On each minion, run the following-
32+
33+
```
34+
echo "master: riley.science" >> /etc/salt/minion
35+
```
36+
37+
This adds your master to each minion. Now, let's start the salt minions with the following-
38+
39+
```
40+
systemctl enable salt-minion
41+
systemctl start salt-minion
42+
43+
```
44+
45+
Start your salt master-
46+
47+
```
48+
systemctl enable salt-minion
49+
systemctl start salt-minion
50+
```
51+
52+
Assuming your minions can ping the master,now we should be able to run the following to view and accept the keys from the master. From here,you will not need to ssh directly into the minions(SSH'ing into servers is soo 2016) again. Let's view the keys asking for a connection,and accept them-
53+
54+
```
55+
[root@srv3 ~]# salt-key -L
56+
Accepted Keys:
57+
git.riley.science
58+
srv.fasterdevops.com
59+
srv4.riley.science
60+
srv5.riley.science
61+
srv6.riley.science
62+
srv7.riley.science
63+
srv8.riley.science
64+
Denied Keys:
65+
Unaccepted Keys:
66+
Rejected Keys:
67+
```
68+
69+
Here, I have already accepted my minions. Run salt-key -A to accept the keys that will show under Unaccepted Keys.
70+
71+
That's it! You now have a salt master and minions connected to it. Test the connection as follows-
72+
73+
```
74+
[root@srv3 ~]# salt '*' test.ping
75+
srv4.riley.science:
76+
True
77+
srv5.riley.science:
78+
True
79+
git.riley.science:
80+
True
81+
srv6.riley.science:
82+
True
83+
srv8.riley.science:
84+
True
85+
srv7.riley.science:
86+
True
87+
```
88+
Salt supports using wildcards when specifying the host, so with the above ping command if I wanted to ping every minion that started with the hostname srv, I would replace the * with just srv*.
89+
90+
You can find some of my own salt formulas to help you get started on my [github](http://github.com/sadminriley).
91+
92+
Other commands-
93+
94+
```
95+
salt '*' disk.usage
96+
97+
salt '*' network.interfaces
98+
99+
salt '*' cmd.run 'yum -y install whois'
100+
```
101+
102+
If you were to clone my formulas, and put them into /srv/salt , you could run the following to apply the state 'require' to install the specified packages-
103+
104+
```
105+
salt '*' state.apply require
106+
```
107+
108+
109+
You can learn more about advanced usage over at [https://docs.saltstack.com/](https://docs.saltstack.com/).
9110

10-
The official [saltstack](http://saltstack.com) repo can be found [here](http://github.com/saltstack/salt)
111+
I hope this was helpful!

0 commit comments

Comments
 (0)