QubesOS / qubes-issues

The Qubes OS Project issue tracker
https://www.qubes-os.org/doc/issue-tracking/
543 stars 48 forks source link

saltstack: user defined pillars unusable for other targets than dom0 #6033

Closed 100111001 closed 4 years ago

100111001 commented 4 years ago

Qubes OS version Qubes release 4.0 (R4.0)

Affected component(s) or functionality user defined pillars in saltstack

Brief summary Using user defined pillars leads to an exception if tageting any other vm than dom0

To Reproduce setup.zip

/srv/salt/user_pillar/top.sls: user: 'target':

/srv/salt/user_pillar/get.sls: host: www.qubes-os.org

/srv/salt/user_salt/get.top base: target:

/srv/salt/user_salt/get.sls: get file: cmd.run:

To enable them during a qubesctl execution, I'm running:

sudo qubesctl --show-output state.apply --pillar-root=/srv/salt/user_pillar/

This works quite well when running this for dom0, but when I'm running it towards a target:

sudo qubesctl --show-output --target myTarget state.apply --pillar-root=/srv/salt/user_pillar/

I receive this error after the disp-mgmt-vm starts: ERROR (exception list index out of range)

Calling qubesctl without --pillar-root results in not finding the pillar in /var/log/qubes/mgmt-target.log: output: - Rendering SLS 'base:user_salt.get' failed: Jinja variable 'salt.utils.context.NamespacedDictWrapper object' has no attribute 'host'

Expected behavior Pillars are applied same way like it's done for dom0 with:

sudo qubesctl --show-output state.highstate --pillar-root=/srv/salt/user_pillar/

Actual behavior I receive this error after the disp-mgmt-vm starts:

ERROR (exception list index out of range) 

Solutions you've tried

With the stack trace:

SaltRenderError: Could not find relpath for user_salt.myPersonalTopFile.top
Traceback (most recent call last):
  File "/bin/qubesctl", line 110, in <module>
    salt_call()
  File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 391, in salt_call
    client.run()
  File "/usr/lib/python2.7/site-packages/salt/cli/call.py", line 58, in run
    caller.run()
[setup.zip](https://github.com/QubesOS/qubes-issues/files/5213887/setup.zip)

  File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 134, in run
    ret = self.call()
  File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 204, in call
    ret['return'] = func(*args, **kwargs)
  File "/var/cache/salt/minion/extmods/modules/topd.py", line 74, in enable
    return TopUtils(__opts__, **kwargs).enable(paths, saltenv)
  File "/var/cache/salt/minion/extmods/utils/toputils.py", line 600, in enable
    toppaths, unseen = self.prepare_paths(paths)
  File "/var/cache/salt/minion/extmods/utils/toputils.py", line 453, in prepare_paths
    toppath = self.toppath(path)
  File "/var/cache/salt/minion/extmods/utils/toputils.py", line 332, in toppath
    saltenv = saltenv or self.saltenv(path, saltenv)
  File "/var/cache/salt/minion/extmods/utils/pathutils.py", line 128, in saltenv
    relpath = self.relpath(path)
  File "/var/cache/salt/minion/extmods/utils/pathutils.py", line 486, in relpath
    return self.path(path, saltenv)
  File "/var/cache/salt/minion/extmods/utils/toputils.py", line 269, in path
    return super(TopUtils, self).path(path, saltenv, path_type=path_type)
  File "/var/cache/salt/minion/extmods/utils/pathutils.py", line 445, in path
    raise SaltRenderError('Could not find relpath for {0}'.format(path))
salt.exceptions.SaltRenderError: Could not find relpath for user_salt.myPersonalTopFile.top
DOM0 configuration failed, not continuing 

Relevant documentation you've consulted https://www.qubes-os.org/doc/salt/ https://github.com/QubesOS/qubes-mgmt-salt https://docs.saltstack.com/en/getstarted/config/pillar.html

100111001 commented 4 years ago

This issue can be closed. unman pointed me into the right direction. In the upper solution I'm trying to use: /srv/salt/user_salt instead of the correct directory: /srv/user_salt