Skip to content

Instantly share code, notes, and snippets.

@kyhau
Last active December 12, 2016 00:41
Show Gist options
  • Save kyhau/0498f8ed49bba1a664aa to your computer and use it in GitHub Desktop.
Save kyhau/0498f8ed49bba1a664aa to your computer and use it in GitHub Desktop.
SaltStack

Install salt-minion on a new ubuntu server

  1. Change the hostname on the minion
$ sudo su
  
$ vi /etc/hosts
# add 127.0.0.1 servername
 
$ vi /etc/hostname
# change the name to the servername

$ hostname -F /etc/hostname 
# (this forces the hostname changes which stick after a reboot)
  1. Setup latest version of salt-minion on a new server See
$ add-apt-repository ppa:saltstack/salt        # to get the latest version
$ apt-get update
$ apt-get install salt-minion

Or to get the latest installation from the SaltStack repository (Ubuntu 14)

$ wget -O - https://repo.saltstack.com/apt/ubuntu/ubuntu14/latest/SALTSTACK-GPG-KEY.pub | sudo apt-key add -

$ vi /etc/apt/sources.list
# Add the following line to /etc/apt/sources.list
# deb http://repo.saltstack.com/apt/ubuntu/ubuntu14/latest trusty main
 
$ apt-get update
 
$ apt-get install salt-minion

Or to get the latest installation from the SaltStack repository (Ubuntu 16)

sudo wget -O - https://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest/SALTSTACK-GPG-KEY.pub | sudo apt-key add -
sudo mkdir -p /etc/apt/sources.list.d/
cat "deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest xenial main" >> /etc/apt/sources.list.d/saltstack.list
sudo apt-get update
sudo apt-get install salt-minion
cat /etc/salt/minion_id             # to confirm minion id is the same as hostname
  1. Configuring salt-minion for connectivity to master (you can check an existing minion for the configuration)
$ sudo vi /etc/salt/minion

# Edit the line
# master: <salt-master-server>
  1. Start the minion in the foreground (to daemonize the process, pass the -d flag)
$ service salt-minion start
  1. Login to the salt-master server and accept the new minion key
$ salt-key -L                         # Check to see if key is available
$ salt-key -a <minion-key>            # Accept the new minion key
  
$ salt-run manage.status              # Check that the server is up

A) Override pillar value from command line Ref

$ salt '*' state.apply ftpsync pillar='{"ftpusername": "test", "ftppassword": "hello"}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment