Hi Vitaly,
you can just have a little command
returning/outputting JSON [1] or YAML
as a source for an external pillar. That's
probably the easiest way to get started
with dynamic pillars.
Regards, Florian
[1]:
https://docs.saltstack.com/en/latest/topics/development/external_pillars.html#example-configuration
Am 23. Juni 2016 11:58:09 MESZ, schrieb Vitaly Isaev <
vitaly...@gmail.com>:
> Hello! I'm pretty new to Salt, and possibly I misunderstand some
> concepts... Recently I faced with a need of "dynamic" Pillar: some
> keys
> should be initialized with values at the Pillar's compile time (i.e.
> should
> not be stored statically). Jinja macro are not sufficient here, I
> would
> like to recruit Python for this purpose. Please consider two simple
> cases
> below. Is it possible to implement them in SaltStack?
>
>
> 1. # Say I have a Python function 'token_get' that encapsulates some
> heavy logic
> 2. # and obtains token string required for the particular Pillar file.
> 3. # Is it possible to call this function from Jinja template (Variant
>
> 1),
> 4. # or should I wrap this function into a distinct binary
> ('token_get_binary')
> 5. # and call it like in Variant 2?
> 6.
> 7. # Variant 1 (More preferred)
> 8. config:
> 9. host:
abc.def.com
> 10. port: 8081
> 11. token: {{ token_get(arg1, arg2) }}
> 12.
> 13.
> 14. # Variant 2 (Less preffered)
> 15. config:
> 16. host:
abc.def.com
> 17. port: 8081
> 18. {% set token_get_cmd = ["token_get_binary", arg1, arg2] | join
> "
> " %}
> 19. token: {{ salt['cmd.run'](token_get_cmd) }}
>