Skip to content

Instantly share code, notes, and snippets.

Created August 29, 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 anonymous/c51c9c9a1078b234fb61f8201e42cf29 to your computer and use it in GitHub Desktop.
Save anonymous/c51c9c9a1078b234fb61f8201e42cf29 to your computer and use it in GitHub Desktop.
retrieve executing state name?
# I want multiple instances of the same executable, each with its own unique
# settings, to run on a single minion. Is it possible to get the name of the
# executing state as listed in top.sls (test_instance1 or test_instance2 in
# the example below) from within map.jinja so that I can pass that name to
# pillar.get?
#
# Here is an overly simplified example; in reality, the pillar data contains
# many values to be passed to the formula. The formula knows how to write
# those values to templated config files and other such things.
### formulas/test/test/map.jinja
{% set default_settings = {
'cmd': 'ls',
'args': '-l',
}%}
{% set my_settings = salt['pillar.get'](
TODO_name_of_executing_state, # This value is the topic of my questions.
default=default_settings,
merge=True)
%}
### salt/top.sls and pillar/top.sls are identical
base:
'*db*':
- test_instance1
- test_instance2
### pillar/test_instance1.sls
test_instance1:
args: -lh
### pillar/test_instance2.sls
test_instance2:
args: -lhtr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment