Created
February 12, 2016 17:06
-
-
Save kevinquinnyo/25c3e964e72e63a55fba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!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 | |
~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!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