Saltstack Configuration Management

Minion (or standalone) install:

\curl -L | sudo sh

Master install:

\curl -L | sudo sh -s -- -M -N
# -M    install master
# -N    do not install minion

Minion: Who is your master?

# IP address or host name
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 run on minion:

salt-call -l debug state.highstate

Workflow for remote execution modules:

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


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?