16 February 2016

Salt: Install Configuration Manager

Install 

NB: Use sudo -i to run as super user

Installation

Ubuntu Install

  1. Add the key:
    wget -O - https://repo.saltstack.com/apt/ubuntu/14.04/amd64/latest/SALTSTACK-GPG-KEY.pub | sudo apt-key add -
  2. Add the source to /etc/apt/sources.list
    printf '%s\n%s\n' 'deb http://repo.saltstack.com/apt/ubuntu/14.04/amd64/latest trusty main' | sudo tee -a /etc/apt/sources.list
  3. Update sources:
    sudo apt-get update
  4. Install the salt-minion, salt-master, or other Salt components:
    apt-get install salt-master
    apt-get install salt-minion
    apt-get install salt-ssh
    apt-get install salt-syndic
    apt-get install salt-cloud

Alternative Install

Server:

curl -L https://bootstrap.saltstack.com -o install_salt.sh
sudo sh install_salt.sh -P -M

Install Client:

curl -L https://bootstrap.saltstack.com -o install_salt.sh
sh install_salt.sh -P

NB: If you get the error:
ERROR: Failed to run install_ubuntu_stable_deps()!!!
Then try this process instead:
wget -O - https://repo.saltstack.com/apt/ubuntu/14.04/amd64/latest/SALTSTACK-GPG-KEY.pub | sudo apt-key add -
printf '%s\n%s\n' 'deb http://repo.saltstack.com/apt/ubuntu/14.04/amd64/latest trusty main' | sudo tee -a /etc/apt/sources.list
apt-get update

Then install the relevant components:
apt-get install salt-master
apt-get install salt-minion
apt-get install salt-ssh
apt-get install salt-syndic
apt-get install salt-cloud

Configuration

Configure Server

Network interface/port

Salt master listens on ports 4505 and 4506 on all interfaces (0.0.0.0). 
To change the ip
service salt-master restart
Check service is running:
service salt-server status

Keys
  1. Print the master key fingerprint:
    salt-key -F master
  2. Copy the master.pub fingerprint from the Local Keys section, and set this in the minions

Configure Minion

Salt uses ports 4505 and 4506 which need to be open on the master only. These need to be open on your router/firewall (they will be opened by the install of the master on the master itself). If not enable the firewall e.g. ufw enable && ufw enable 4505 on Ubuntu
  1. Either configure DNS to resolve 'salt' to the master or edit the config:
    vi /etc/salt/minion
    master: [host/ip of master machine]
  2. Configure the master's key (or accept it on the master see below):
    Set the master's key as the master_finger in the minion configuration file.
  3. Restart the salt minion service:
    service salt-minion restart
  4. Check its running:
    service --status-all
    service salt-minion status
NB: If setting multiple masters:
master:
  - address1
  - address2
master_type: failover or str
random_master: True
master_alive_interval: 30
Good article on multiple masters here.

Accept Minion Key on Master

  1. List the keys:
    salt-key -L
  2. Accept all or one:
    salt-key -A
    salt-key -A [hostname]

Delete Minions

Remove all Minions that aren't currently connected:
salt-run manage.down removekeys=True

Test Connection

  • On the Master:
    Return the status of the Minions:
    salt '*' test.ping
    Return the ip addresses of the Minions:
    salt '*' network.ip_addrs
  • On the Minion:
    salt-minion -l debug

No comments:

Post a Comment