Download the presentation here: HATech Academy – Saltstack 101
Watch the training video here:
Watch HATech Academy: Intro to Satstack from hatechdevops on www.twitch.tv
Introduction
This Intro to Saltstack training session introduces the student to Saltstack, its architecture and why it is so different to other options like Puppet, Chef and Ansible. The training labs in will introduce basic setup and configuration, state modules and execution modules, and how to query the infrastructure and retrieve an inventory of all connected devices.
LAB 1 -Create Resource Group
- Login to your Azure Account
- Click on the Resource Groups menu
- Click ‘+’ add to create a new Resource Group
- Provide a name for the Resource Group
- For this lab choose West US for the Region
- Click OK
Create Salt Master node
- Select the Virtual Machines menu
- Click ‘+’ to create a new Virtual Machine Instance
- Choose Ubuntu 16.04 as the instance OS
- Click Create
- Give it a name of ‘saltmaster’
- Provide a Username
- Choose Password instead of SSH Key and enter a password
- Select the Resource Group that you created above
- Click OK
- Choose B1MS as the instance size
- Click OK
- Click Advanced Network Security Group
- Click Network Security Group (firewall)
- Create New to add a new Firewall
- Click default-allow-ssh
- Add the following Destination Ports – 80,4505,4505
- Click Save
- Click OK to exit the Security settings
- Click OK to exit the Optional settings
- Check the Summary and click Create
Create Salt Minion node
- Select the Virtual Machines menu
- Click ‘+’ to create a new Virtual Machine Instance
- Choose Ubuntu 16.04 as the instance OS
- Click Create
- Give it a name of ‘saltmaster’
- Provide a Username
- Choose Password instead of SSH Key and enter a password
- Select the Resource Group that you created above
- Click OK
- Choose B1MS as the instance size
- Click OK
- Ensure the virtual network is the same as the Salt Master
- Click Advanced for Network Security Group
- Click Network Security group (firewall)
- Click saltmaster-nsg or whatever name you gave the security group above
- Click Save
- Click OK to exit the Security settings
- Click OK to exit the Optional settings
- Check the Summary and click Create
Install SaltMaster
- From Virtual Machines menu, click on the Salt Master node
- Copy the public IP address
- SSH into the node ex. ssh tkelley@
- Run
sudo su
- Run
wget -O - https://repo.saltstack.com/apt/ubuntu/18.04/amd64/latest/SALTSTACK-GPG-KEY.pub | sudo apt-key add -
- Run
echo "deb http://repo.saltstack.com/apt/ubuntu/18.04/amd64/latest bionic main" >> /etc/apt/sources.list.d/saltstack.list
- Run
apt-get update && apt-get install -y salt-api salt-master salt-minion salt-ssh
- Run
mkdir /srv/salt
- Run
service salt-master status and ensure salt-master is running
- Exit Box
Install SaltMinion
- From Virtual Machines menu, click on the Salt Master node
- Copy the public IP address
- SSH into the node ex. ssh tkelley@
- Run
sudo su
- Run
wget -O - https://repo.saltstack.com/apt/ubuntu/18.04/amd64/latest/SALTSTACK-GPG-KEY.pub | sudo apt-key add -
- Run
echo "deb http://repo.saltstack.com/apt/ubuntu/18.04/amd64/latest bionic main" >> /etc/apt/sources.list.d/saltstack.list
- Run
apt-get update && apt-get install -y salt-api salt-minion salt-ssh
- Run
mkdir /srv/salt
- Run
service salt-minion status and ensure salt-minion is running
- Exit Box
Configure & Test
- Run
nano /etc/salt/minion
- On line 16, delete the # and change salt to the IP address of the master
- Run control + x to exit the file
- Press y to save changes
- Press Enter to exit the file
- Run
service salt-minion restart
- Accept minion key
- From Virtual Machines menu, click on the Salt Master node
- Copy the public IP address
- SSH into the node ex. ssh tkelley@
- Run
sudo su
- Run
salt-key -L
- It may take a moment but in the Unaccepted Keys: section a key name for the
- Salt Minion should be there
- When it appears, run
salt-key -a
- Press y to accept the key
- Run
salt '*' test.ping
LAB 2 – Saltstack Execution Modules
The following lab is an example of some of the commands that can be executed from the command line on the Salt master:
- The following command checks connectivity between the Master and the minions
salt '*' test.ping
- The following command is an example of reading a file on the minion and sending the output to the salt master
salt '*' cmd.run 'cat /etc/hosts'
- The following installs Apache on all the connected minions
salt '*' pkg.install 'apache2'
- The following removes Apache on all the connected minions
salt '*' pkg.remove 'apache2'
LAB 3 – Saltstack State Modules
The following lab is an example of how we can declare a state that we wish a minion to match:
- Create a new file called /srv/salt/webserver/init.sls
cd /srv/salt mkdir webserver nano webserver/init.sls
- Create a state to install apache
apache2: pkg.installed: [] service.running: - require: - pkg: apache2
- Apply the state to your minions
salt '*' state.apply webserver
Share this post
Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest
Share on print
Share on email