Forked from ryan-lane/Calling salt-call with environment variables
Created
November 30, 2015 16:51
-
-
Save sergeycherepanov/b110608cb96c8753c62c to your computer and use it in GitHub Desktop.
Using an environment variable in a state file
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
MYENVVAR="world" salt-call state.template test.sls |
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
Create a file with contents from an environment variable: | |
file.managed: | |
- name: /tmp/hello | |
- contents: {{ salt['environ.get']('MYENVVAR') }} |
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
{% set myenvvar = salt['environ.get']('MYENVVAR') %} | |
{% if myenvvar %} | |
Create a file with contents from an environment variable: | |
file.managed: | |
- name: /tmp/hello | |
- contents: {{ salt['environ.get']('MYENVVAR') }} | |
{% else %} | |
Fail - no environment passed in: | |
test: | |
- fail_without_changes | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment