Table of Cotnent

SALT master

Get Infos about minions

ComandsDescription
salt-run manage.uplist all minions which are up
salt-run manage.downlist all minions which are down
salt-run manage.up tgt="roles:postgres" tgt_type="grain"list all minions with role postgress set as grain and ar up
salt-run manage.up show_ip=trueshow the ip they are connecting from
salt-run manage.presentlist all up minions according to last known state (not asking them = faster but not reliable)
salt-run manage.not_presentlist all up minions according to last known state (not asking them = faster but not reliable)
salt '[minion]' grains.itemslist all grains of that [minion]
salt '[minion]' grains.item [grain]return values/lists/Arrays for [grain]
salt '[minion]' pillar.itemslist all pillar data of that [minion]
salt '[minion]' pillar.item [pillar]return values/lists/Arrays for [pillar]

Apply states

ComandsDescription
salt '[minion]' state.applyapply current configuration
salt '[minion]' state.apply test=truedryrun to see what whould change
salt -G 'os:Arch' state.applyapply config on all Arch machines -G (grain) 'key:value'
... --state-output=fulldefault; output multiple lines per state
... --state-output=terseoutput one line per state
... --state-output=mixedoutput one line per state unless failed, then use full
... --state-output=changesoutput multiple lines per state unless successful
... --state-verbose=falseomit successful states completely

Get infos about jobs

ComandsDescription
salt-run jobs.list_jobssearch for specitic job (=] jid)
salt-run jobs.lookup_jid [jid]get report of [jid]

Force data refresh

ComandsDescription
salt '[minion]' saltutil.refresh_pillarrefresh pillar data
salt '[minion]' saltutil.refresh_grainsrefresh grains
salt-run fileserver.updaterefresh states fileserver
salt-run git_pillar.updategit pull on pillar git repos

Upgrade packages on minions

ComandsDescription
salt -G 'virtual:LXC' -b 1 pkg.upgrade refresh=trueupgrade all LXD/LXC with batch size 1
salt -G 'virtual:kvm' -b 1 pkg.upgrade refresh=truesame for virtual machines

Salt Key management

ComandsDescription
salt-key -Llist all keys
salt-key -a [minion]accept key of minion if key is in unaccepted state (minions_pre)
salt-key -y -a [minion]same but with auto answering confirm question with y
salt-key -Aaccept all unaccepted keys
salt-key -d [minion]deletes all key matching [minion]. Accepted, denied and not yet accepted
/etc/salt/pki/masterpath containing keys
salt-key --gen-keys=[minion]generate a key file pair named minion

Salt minion

Get Infos about minions

ComandsDescription
salt-call grains.itemslist all grains
salt-call grains.item [grain]return values/lists/Arrays for [grain]
salt-call pillar.itemslist all pillar data
salt-call pillar.item [pillar]return values/lists/Arrays for [pillar]

misc

ComandsDescription
openssl passwd -6generate a password hash for distribution
read -s smbpw; printf '%s' "$smbpw" | iconv -t utf16le | openssl md4generate a password hash for samba (pdbedit)
salt $minion saltutil.clear_cache; salt $minion cmd.run "salt-call service.restart salt-minion" bg=true; sleep 15; salt $minion test.ping; salt $minion state.applyusefull in case salt minions got a broken cache