Skip to content

Instantly share code, notes, and snippets.

@ksalman
Last active August 29, 2015 14:16
Show Gist options
  • Save ksalman/b9bf5a4dbfb30fc04b3b to your computer and use it in GitHub Desktop.
Save ksalman/b9bf5a4dbfb30fc04b3b to your computer and use it in GitHub Desktop.
Using pillar data in python state renderer
vlabdb:
foo64: myvlabdb
#!py
def run():
return context['foo'] + '\n'
/tmp/tmpfile:
file:
- managed
- template: py
- source: salt://bar.py
- context:
foo: {{ salt['pillar.get']('vlabdb:' + grains['host']) }}
[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