This is a run-down on how to create a complete Salt State. The aim of this article is to discuss how to write a complete Salt state from end-to-end. It is highly recommended that you go through the links below, which serve as an entry point into Saltstack, Saltstack installation, Saltstack configuration, Basic Saltstack commands and a few examples.
In this article, we'll aim to build a complete
LEMP server AND install a Wordpress application. The process is broken down into 2 parts, which are listed below.
1. LEMP Installation
info.phpfile to Nginx's default Document Root (
2. Wordpress Installation
In while the installation and configuration of a Salt Master and Salt Minion has been covered in the links above, here's a quick outline on installing a Salt Minion:
1. DEBIAN (minion)
1a. Add the Saltstack repo:
root@debianbase71:~# wget -O - https://repo.saltstack.com/apt/debian/8/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add - root@debianbase71:~# vim /etc/apt/sources.list.d/saltstack.list #ADD THIS LINE: deb http://repo.saltstack.com/apt/debian/8/amd64/latest jessie main
2b. Install the Salt-Minion service:
root@debianbase71:~# apt-get update root@debianbase71:~# apt-get install salt-common salt-minion salt-ssh -y
2c. Enable and start the Minion service:
root@debianbase71:~# systemctl enable salt-minion Synchronizing state for salt-minion.service with sysvinit using update-rc.d... Executing /usr/sbin/update-rc.d salt-minion defaults Executing /usr/sbin/update-rc.d salt-minion enable root@debianbase71:~# systemctl start salt-minion
2. CENTOS (minion)
2a. Install the Salt-Minion service: First, create the repo file for Saltstack, under /etc/yum.repos.d/saltstack.repo
[root@localhost ~]# vim /etc/yum.repos.d/saltstack.repo Add the following: [saltstack-repo] name=SaltStack repo for Red Hat Enterprise Linux $releasever baseurl=https://repo.saltstack.com/yum/redhat/$releasever/$basearch/latest enabled=1 gpgcheck=1 gpgkey=https://repo.saltstack.com/yum/redhat/$releasever/$basearch/latest/SALTSTACK-GPG-KEY.pub https://repo.saltstack.com/yum/redhat/$releasever/$basearch/latest/base/RPM-GPG-KEY-CentOS-7
Now, install Salt-Minion, using yum:
[root@localhost ~]# yum install salt-minion salt-ssh -y
2b. Enable and start the Minion service:
[root@localhost ~]# systemctl enable salt-minion Created symlink from /etc/systemd/system/multi-user.target.wants/salt-minion.service to /usr/lib/systemd/system/salt-minion.service. [root@localhost ~]# systemctl start salt-minion
Once this is complete, enable port 4506 on the Salt Minion, add the Salt Master's IP or Hostname to the Minion's configuration file (
/etc/salt/minion), restart the
salt-minion service and accept the Minion's key on the Salt Master.
If you'd rather use a shell script to install Salt Minion, here's a link to an easy to use bash script:
Now that we have a functional Minion(and a Salt-Master), in the next post, we'll create and analyze a complete Salt state.
For any feedback or corrections, please write in to: rahul [at] muchbits [dot] com