How to Install Saltstack on Ubuntu

0
600
How to Install Saltstack on Ubuntu

 

Salt, or SaltStack, is a remote execution tool and configuration management system, based on the community-sourced Salt platform. The remote execution capabilities allow administrators to run commands on various machines in parallel with a flexible targeting system. The configuration management functionality establishes a client-server model to quickly, easily, and securely bring infrastructure components in line with a given policy.

Now will see how to install salt on Ubuntu and how to connect both master and minion.saltstackbefore you start you can read Salt introduction

Install and configure the salt-master

Use the SaltStack PPA to install the latest salt-master program:

#add-apt-repository ppa:saltstack/salt
# apt update
#apt-get install salt-master salt-minion salt-ssh salt-cloud salt-doc

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

Install and configure the salt-minion

Use the SaltStack PPA to install the latest salt-minion program:

# add-apt-repository ppa:saltstack/salt
# apt update
# apt-get 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.

NO COMMENTS