What is the pillar import path when using Salt user directories?

Hi everyone,

I am using Salt to record some of my personal configuration. I enabled the user directories.

I am currently turning my original split-SSH state into a formula. Part of that is taking advantage of Salt pillar.

So far, placing my pillar data in /srv/user_pillar/split-ssh/ makes it accessible as I expect. Using Jinja to template some of those files work fine too, until I try to:

{% from 'example.jinja' import example_macro %}

At that point I get:

jinja2.exceptions.TemplateNotFound: example.jinja

The file example.jinja is in the same directory as the file I’m trying to importing it from (/srv/user_pillar/split-ssh/).

My understanding is that the path needs to be relative to pillar_roots, which is defined in /etc/salt/master as /srv/pillar.

I’ve tried without success:

  • '../user_pillar/split-ssh/example.jinja'
  • 'split-ssh/example.jinja'
  • 'example.jinja'

Does anyone know what the pillar import path should look like when using the /srv/user_pillar?


For additional context: I experience the same problem when attempting to:

{% load_yaml 'config.yaml' as config %}

Any clues welcome! I can provide entire code snippets if that helps :slightly_smiling_face:

I can confirm that placing example.jinja in /srv/pillar makes it found. But that doesn’t really solve the problem when the goal is to use /srv/user_pillar.

Additionally, adding /srv/user_pillar doesn’t have any visible effect (?) - even after restarting.

# /etc/salt/master.d/user.conf

pillar_roots:
  base:
    - /srv/pillar
  user:
    - /srv/user_pillar

What I do:
Append my/your user directory to /srv/pillar/topd/config.top
and then run qubesctl saltutil.refresh_pillar
after that it will find the files.

I use a salt state to do this:
cat /srv/salt/dom/pilla.sls
add_topd:
file.append:
- name: /srv/pillar/topd/config.top
- ignore_whitespace: false
- text:
" - qub"
- order: 1

pillar_sync:
cmd.run:
- names:
- qubesctl saltutil.refresh_pillar
- order: 1

Read about the use of environments in salt - that’s what
“base” and “user” are.
You can target environments using saltenv and pillarenv

Example:

/srv/user_salt/get.top

base:
   target:
     - get

/srv/user_salt/get.sls

get_page:
   cmd.run:
     - name: wget {{pillar['host'] }}

/srv/user_pillar/get.sls

host: www.qubes-os.org

qubesctl --skip-dom0 --targets=target state.apply saltenv=user get