Skip to main content

Setting Up a Salt Master and Minion

Hands-On Lab

 

Photo of Terrence Cox

Terrence Cox

Senior Vice President of Content

Length

00:30:00

Difficulty

Intermediate

The Salt system is amazingly simple and easy to configure. The two components of the Salt system each have a respective configuration file. The salt-master is configured via the master configuration file, and the salt-minion is configured via the minion configuration file. The set up and configuration of a Salt Master and minion(s) is a fundamental skill on your journey to using Salt for configuration management and orchestration. Within this activity, the student will practice installing a Salt Master and minion of different distribution types. At the end, the student will be familiar with the process of configuring a Salt environment, as well as managing Salt keys.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Setting Up a Salt Master and Minion

Introduction

As the new tech intern at the niche publication Apartment 42, you have been tasked with setting up the infrastructure for their new website via Salt. You boss has also made it clear that you are expected to maintain your own test environments wherein you can write your states and formulas, and ensure any changes to the infra works before even pushing it to staging. For this, you've decided on using a CentOS master (hostname: salt) and an Ubuntu minion (hostname: minion1).

Using whichever installation method you desire, install both a Salt master and Salt minion on the provided CentOS 7 server and a Salt minion on the provided Ubuntu 16.04 server. When finished, ensure the minion (including the Master's own minion set up) is using the correct fingerprint and accept the key exchange.

Solution

  1. Begin by logging in to the Salt Master lab server using the credentials provided on the hands-on lab page.

    ssh cloud_user@PUBLIC_IP_ADDRESS

Install Salt on the Salt Master and Minion1 Servers

  1. Retrieve the Salt installation file.

    curl -L https://bootstrap.saltstack.com -o install_salt.sh
  2. Install Salt.

    sudo sh install_salt.sh -P -M
  3. In a new terminal, log in to the Minion lab server using the credentials provided on the hands-on lab page.

    ssh cloud_user@PUBLIC_IP_ADDRESS
  4. Edit the hosts file.

    sudo vim /etc/hosts
  5. Add the private IP of the Salt Master lab server.

    PRIVATE_IP_ADDRESS salt
  6. Save the changes and exit the editor.

  7. Retrieve the Salt installation file.

    curl -L https://bootstrap.saltstack.com -o install_salt.sh
  8. Install Salt.

    sudo sh install_salt.sh -P

Add the Master Fingerprint to Both Servers

  1. On the Salt Master server, retrieve the public key.

    sudo salt-key -F master
  2. Copy the master.pub key.

  3. On the Minion server, edit the minion file.

    sudo vim /etc/salt/minion
  4. Search for the "master_finger" configuration.

  5. Uncomment the "master_finger" configuration.

  6. Paste the key copied from the Salt Master server between the two single quotes.

  7. Save the changes and exit the editor.

  8. Restart the salt-minion service.

    sudo systemctl restart salt-minion
  9. On the Salt Master server, edit the minion file.

    sudo vim /etc/salt/minion
  10. Search for the "master_finger" configuration.

  11. Uncomment the "master_finger" configuration.

  12. Paste the key copied from the Salt Master server between the two single quotes.

  13. Save the changes and exit the editor.

Verify the Local Keys and Accept Both Minions

  1. Check the local key of the Salt Master server.

    sudo salt-call --local key.finger
  2. On the Minion sever, check the local key.

    sudo salt-call --local key.finger
  3. On the Salt Master server, accept both minions.

    sudo salt-key -A
  4. Choose to proceed.

  5. Restart the salt-minion service.

    sudo systemctl restart salt-minion

Conclusion

Congratulations — you've completed this hands-on lab!