# SaltStack on CentOS 6.x

> A concise tutorial on setting up SaltStack for centralized server management on CentOS, including master-minion setup and basic commands.

- Canonical: https://www.russ.cloud/2013/10/06/saltstack-on-centos-6x/
- Published: 2013-10-06
- Author: Russ McKendrick
- Tags: Infrastructure as Code, Linux, Automation

---

Had a play with [SaltStack](http://saltstack.com/) today, it’s a good way to manage multiple machines from a central location. It runs as a Server (master) and client (minion).

First we need to install the Salt-Master, this assumes you are installing on CentOS and don’t mind having EPEL installed on both the master and minion ….

```bash frame="terminal" title="SaltStack on CentOS 6.x 1/3"
# Install EPEL and Update on both the master and minions
yum update -y
yum install http://ftp.linux.ncsu.edu/pub/epel/6/i386/epel-release-6-8.noarch.rpm

# Install the salt-master
yum install salt-master
chkconfig salt-master on
sed -i ‘s/#interface: 0.0.0.0/interface: 0.0.0.0/g’ /etc/salt/master
service salt-master start

# Install the salt-minion
# Replace $salt-master.yourdomain.com with the FQDN of your salt-master

yum install salt-minion
chkconfig salt-minion on
sed -i ‘s/#master: salt/master: manager.yourdomain.com/g’ /etc/salt/minion
service salt-minion start
```


Now we have a minion talking to the master we need to accept the certificate;

```bash frame="terminal" title="SaltStack on CentOS 6.x 2/3"
salt-key -L
salt-key -A [hostname]
```


Thats it, you can now run commands across all your machines e.g.

```bash frame="terminal" title="SaltStack on CentOS 6.x 3/3"
salt ‘*’ test.ping
salt ‘*’ grains.ls
salt ‘*’ grains.items
salt ‘*’ cmd.has_exec service
salt ‘*’ cmd.run “service nginx stop”
salt ‘*’ cmd.run “service nginx start”
salt ‘*’ cmd.run “yum update -y”
```


For further reading [RTFM](https://salt.readthedocs.org/en/latest/).
