Now will see how to install salt on centos 7 and how to connect both master and minion.
Install and configure the salt-master
Use the SaltStack official YUM repo to install the latest salt-master program:
# yum update # yum install https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el7.noarch.rpm # yum clean expire-cache # yum install salt-master -y
Or
# curl -L https://bootstrap.saltstack.com -o install_salt.sh # sh install_salt.sh -P -M
After the installation finishes, modify the configuration file as below:
# vim /etc/salt/master Find and replace master IP (uncomment it) interface: 192.168.0.161
and if need you can modify the timeouts (timeout & gather_job_timeout)
Start and enable the salt-master service:
# systemctl start salt-master.service # systemctl enable salt-master.service
Modify firewall rules (optional)
By default, the salt-master service will use ports 4505 and 4506 to communicate with minions. You need to allow traffic through the two ports on the master server.
Find out to which zone the eth0 interface belongs:
# firewall-cmd --get-active-zones
You will find out that the eth0 interface belongs to the “public” zone. Therefore, you need to allow traffic through the two ports in the “public” zone:
# firewall-cmd --permanent --zone=public --add-port=4505-4506/tcp # firewall-cmd --reload
That’s all that needs to be done on the master server for now.
Install and configure the salt-minion
Use the SaltStack official YUM repo to install the latest salt-minion program:
# yum update # yum install https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el7.noarch.rpm # yum clean expire-cache # yum install salt-minion -y
Or
# curl -L https://bootstrap.saltstack.com -o install_salt.sh # sh install_salt.sh -P
After the installation, modify the configuration file as below:
# vim /etc/salt/minion Find and replace master IP (uncomment it) master: 192.168.0.161
and mention your minion name on minion_id for easy idendification
# vim /etc/salt/minion_id Id: fox1
Start and Enable the salt-minion service:
# systemctl start salt-minion.service # systemctl enable salt-minion.service
Once salt-minion service started successfully, it sends off a signal to find the SaltStack server. Follow the steps to add more agents/minions
Accept the Minions
Once minion service started successfully, back to master and check all available minions on following command.
# salt-key -L
If everything was successful, you will see the minion server “fox1” listed in the “Unaccepted Keys” segment.
Accepted Keys: Denied Keys: Unaccepted Keys: fox1 Rejected Keys:
Accept “fox1” using this command:
# salt-key --accept=fox1
Or accept all of the agent servers:
# salt-key -A
Now out minion is ready, we can run some commands on master to check all setted up good. here fox1 is my minion name, please replace with Yours.
Try 1:
# salt fox1 test.ping fox1: True
Try 2:
# salt fox1 cmd.run 'free -m' Fox1: total used free shared buff/cache available Mem: 487M 396M 5.9M 920K 85M 51M Swap: 1.5G 45M 1.5G
Keep follow us for more post about salt. Happy reading.