{% set foo = salt['cmd.run']('echo $bar') %}
and then access using {{ foo }}
I'm still interested if there is a more proper way.
Den tisdag 3 december 2013 kl. 07:57:06 UTC+1 skrev Seth House:
I'm not 100% if you're referencing the master or the minion, so here
an answer to both. :-)
If the env var is set on your master and you want to pass it to the
sls you can do so with the pillar kwarg and some tricky quoting:
salt 'target' state.sls yoursls pillar='{server_type: "'$TYPE'"}'
It will then be available in the sls file via {{
salt['pillar.get']('server_type') }}.
However, if the env var is set on the minion target, you'll need
something like a custom grain to make it available to the sls.
Put the following in /srv/salt/_grains/type_env.py:
import os
def type_env():
return {'TYPE': os.environ.get('TYPE', '')}
Copy it to the minion:
salt 'target' saltutil.sync_grains
And now it should be available to your sls as a grain:
serverdensity_registration:
serverdensity.registered:
- api_key: sdsa
- sdd_group_name: {{pillar.server.name}}.{{
salt['grains.get']('TYPE') }}
- require:
- pkg: serverdensity_pkg
On Mon, Dec 2, 2013 at 10:41 PM, apz <[email protected] <javascript:>>
wrote:
--an answer to both. :-)
If the env var is set on your master and you want to pass it to the
sls you can do so with the pillar kwarg and some tricky quoting:
salt 'target' state.sls yoursls pillar='{server_type: "'$TYPE'"}'
It will then be available in the sls file via {{
salt['pillar.get']('server_type') }}.
However, if the env var is set on the minion target, you'll need
something like a custom grain to make it available to the sls.
Put the following in /srv/salt/_grains/type_env.py:
import os
def type_env():
return {'TYPE': os.environ.get('TYPE', '')}
Copy it to the minion:
salt 'target' saltutil.sync_grains
And now it should be available to your sls as a grain:
serverdensity_registration:
serverdensity.registered:
- api_key: sdsa
- sdd_group_name: {{pillar.server.name}}.{{
salt['grains.get']('TYPE') }}
- require:
- pkg: serverdensity_pkg
On Mon, Dec 2, 2013 at 10:41 PM, apz <[email protected] <javascript:>>
wrote:
I have a environment variable 'type' set on my system and I want to use its
value in a sls file which calls a custom salt state I have written, I am
including relevant portions of code here:
value in a sls file which calls a custom salt state I have written, I am
including relevant portions of code here:
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.