On 2014-01-15 16:14, schlag wrote:
> Hi,
>
> Is there a way to use pillar.get with subkeys? I've tried all of the
> following which aren't working. For example:
>
> pillar.get('postgres_settings:pg_version', '9.2')
>
> pillar.get(['postgres_settings']['pg_version'], '9.2')
>
> This works on the cli, but does not in my state (see below).
>
> salt-call pillar.get postgres_settings:pg_version
> local:
> 9.3
>
> The reason I want this is to avoid extra logic in my states. For
> example, I manage postgresql and it's requirements with a state file
> and multiple pillar values.
I generally simplify and reduce jinja clutter using 'set'.
eg, at the top of .sls:
{% set src_path = salt['pillar.get']('src_path', '/var/src/') %}
...
{# git repositories #}
{% for repo in salt['pillar.get']('repos', {}) %}
{% set r = pillar['repos'][repo] %}
{{ repo }}-git:
git.latest:
- name: {{ r.url }}
- rev: {{ r.rev }}
- target: {{ src_path }}/{{ repo }}/
- user: root
- require:
- file: root_ssh_private_key
- file: src_workdir
{% endfor %}