Skip to content

Instantly share code, notes, and snippets.

@kevinquinnyo
Created February 12, 2016 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinquinnyo/25c3e964e72e63a55fba to your computer and use it in GitHub Desktop.
Save kevinquinnyo/25c3e964e72e63a55fba to your computer and use it in GitHub Desktop.
# passing pillar manually works
salt 'dns2*' state.sls dns.new_minion "pillar={'new_minion': 'foobar'}"
# passing via 'kwarg' key in the reactor file start.sls does not work
# on minion:
root@lb1:~# salt-call event.send 'salt/minion/lb1.phx.9999.devops.some-domain.com/start'
local:
True
# from salt master log with DEBUG log level I see:
# new_minion = __pillar__[\'new_minion\']\nKeyError: \'new_minion\'\n'], 'retcode': 1
# If I try just echoing the entire __pillar__ to a file, it only contains my mine
#!py
def run():
states = {}
new_minion = __pillar__['new_minion']
states['test-reactor-triggered-sls'] = {
'cmd.run': [
{'name': 'echo "{0}" > /tmp/foo'.format(new_minion)}
]
}
return states
~
# /srv/pillar-dev/top.sls
base:
'*':
- saltmine
'salt-master.my-tss.com':
- localhost
- localhost.secrets
'lb*':
- websites
- websites.secrets
'web*':
- websites
- websites.secrets
'cache*':
- websites
'elk*':
- elk
'db*':
- websites
- websites.secrets
'git*':
- gitlab
- websites
'staging*':
- websites
- websites.secrets
'dns*':
- dns
# /srv/pillar-dev/saltmine/init.sls
mine_functions:
network.interfaces: []
network.ip_addrs: []
fqdn:
- mine_function: grains.get
- fqdn
domain:
- mine_function: grains.get
- domain
#!py
def run():
ret = {}
__salt__['mine.update'](data['id'])
ret['add-new-minion-a-record-{0}'.format(data['id'])] = {
'local.state.sls': [
{'tgt': 'dns*'},
{'arg': ['dns.new_minion']},
{'kwarg': [
{'pillar': {
'new_minion': data['id']
}}
]}
]
}
return ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment