Saltstack Configuration Management#

Minion (or standalone) install:

\curl -L http://bootstrap.saltstack.org | sudo sh

Master install:

\curl -L http://bootstrap.saltstack.org | sudo sh -s -- -M -N
# -M    install master
# -N    do not install minion

Minion: Who is your master?

# IP address or host name
master_host=10.1.1.2
sed -i.bak -e "s/#master: salt/master: $master_host/" /etc/salt/minion
service salt-minion restart

Master: Accept obedient minion:

salt-key -L
# accept single
salt-key -a ubuntu1204
# accept all
salt-key -A

Master: Order your minion:

salt \* test.ping

Test run on minion:

salt-call -l debug state.highstate

Workflow for remote execution modules:

vim /srv/salt/_modules/foo.py
salt \* saltutil.sync_all
salt --text-out \* foo.bar
# if this does not work. do it on the minion
salt-call saltutil.sync_all; salt-call foo.bar
# to reload, restart minion and master daemons

Troubleshooting#

Stupid Error Messages#

Whey I ran salt-call postgres.user_create trac password=trac login=true, I got:

got multiple values for keyword argument 'foo'

What it meant: You have forgotten to add the argument “login” to your user_create function.

Jinja dashes and underscores#

Error message:

TypeError: unsupported operand type(s) for -: 'dict' and 'StrictUndefined'

Problem: Template with {{ foo-bar }}.

Solution: Do not use underscores for variable names in templates. You would not do that in Python either, eh?