Hi,
I'm re-writing a yaml/jinja state using the python state renderer,
because the amount of logic involved is a little clumsy with jinja. Salt
2017.7.0.
I was using:
{%- from "xxx.sls" import aaa, bbb %}
But I've been unable to figure out how to replicate this with the py
renderer. I've tried:
1 #!py
2
3 import re
4 import pprint
5 import json
6 import ipaddress
7 import hashlib
8
9 from xxx.sls import aaa, bbb
With this it's only searching system directories rather than files
relative to the state. Do I need to play about with sys.path.append? If
anyone has a working example that would be great.
Furthermore, I'm not sure if I should be using 'from xxx' or 'from
xxx.sls' or something else - do I need to rename the file to get rid of
the sls extension? (Not sure what impact this will have on the rest of
salt)
From strace'ing the salt master:
[pid 61] open("/srv/pillar/yyy.slsc",
O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0100644) = -1 EROFS (Read-only file
system)
[pid 61] stat("/usr/bin/xxx", 0x7ffdf30585e0) = -1 ENOENT (No such
file or directory)
[pid 61] open("/usr/bin/
xxx.x86_64-linux-gnu.so", O_RDONLY) = -1
ENOENT (No such file or directory)
[pid 61] open("/usr/bin/xxx.so", O_RDONLY) = -1 ENOENT (No such file
or directory)
[pid 61] open("/usr/bin/xxxmodule.so", O_RDONLY) = -1 ENOENT (No such
file or directory)
[pid 61] open("/usr/bin/xxx.py", O_RDONLY) = -1 ENOENT (No such file
or directory)
[pid 61] open("/usr/bin/xxx.pyc", O_RDONLY) = -1 ENOENT (No such file
or directory)
[pid 61] stat("/usr/lib/python2.7/xxx", 0x7ffdf30585e0) = -1 ENOENT
(No such file or directory)
[pid 61] open("/usr/lib/python2.7/
xxx.x86_64-linux-gnu.so", O_RDONLY)
= -1 ENOENT (No such file or directory)
[pid 61] open("/usr/lib/python2.7/xxx.so", O_RDONLY) = -1 ENOENT (No
such file or directory)
[pid 61] open("/usr/lib/python2.7/xxxmodule.so", O_RDONLY) = -1
ENOENT (No such file or directory)
[pid 61] open("/usr/lib/python2.7/xxx.py", O_RDONLY) = -1 ENOENT (No
such file or directory)
[pid 61] open("/usr/lib/python2.7/xxx.pyc", O_RDONLY) = -1 ENOENT (No
such file or directory)
Many thanks.