Last active
August 29, 2015 14:16
-
-
Save ksalman/b9bf5a4dbfb30fc04b3b to your computer and use it in GitHub Desktop.
Using pillar data in python state renderer
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
vlabdb: | |
foo64: myvlabdb |
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(): | |
return context['foo'] + '\n' |
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
/tmp/tmpfile: | |
file: | |
- managed | |
- template: py | |
- source: salt://bar.py | |
- context: | |
foo: {{ salt['pillar.get']('vlabdb:' + grains['host']) }} |
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
[root@foo64 ~]# salt-call state.sls foo | |
[INFO ] Loading fresh modules for state activity | |
[INFO ] Fetching file from saltenv 'base', ** skipped ** latest already in cache 'salt://foo.sls' | |
[INFO ] Running state [/tmp/tmpfile] at time 13:24:15.481460 | |
[INFO ] Executing state file.managed for /tmp/tmpfile | |
[INFO ] Fetching file from saltenv 'base', ** skipped ** latest already in cache 'salt://bar.py' | |
[INFO ] File changed: | |
New file | |
[INFO ] Completed state [/tmp/tmpfile] at time 13:24:15.608985 | |
local: | |
---------- | |
ID: /tmp/tmpfile | |
Function: file.managed | |
Result: True | |
Comment: File /tmp/tmpfile updated | |
Started: 13:24:15.481460 | |
Duration: 127.525 ms | |
Changes: | |
---------- | |
diff: | |
New file | |
mode: | |
0644 | |
Summary | |
------------ | |
Succeeded: 1 (changed=1) | |
Failed: 0 | |
------------ | |
Total states run: 1 | |
[root@foo64 ~]# cat /tmp/tmpfile | |
myvlabdb | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment