using salt - how to debug?

69 views
Skip to first unread message

lik...@gmx.de

unread,
May 14, 2020, 5:15:40 PM5/14/20
to qubes...@googlegroups.com
Hi!

I'm trying to get salt examples running but failing at the simplest one.

I've a enabled top-file:
----------------
base:
dom0:
- doSmth

AppVmTobeChanged:
- doSmthDifferent
-----------------
top file was enabled by: qubesctl top.enable ...

But "doSmthDifferent" will never be executed, when I call: qubesctl --show-output state.highstate

Any hints where to look at? How to debug it?

Current references:
https://www.qubes-os.org/doc/salt/
https://github.com/unman/notes/blob/master/salt/Index

Best, P

unman

unread,
May 15, 2020, 9:31:41 AM5/15/20
to qubes...@googlegroups.com
You haven't included AppVmTobeChanged as a target:
qubesctl --show-output --targets=AppVmTobeChanged state.highstate

You should check that you aren't getting a mistaken dom0 call.

lik...@gmx.de

unread,
May 17, 2020, 4:55:06 AM5/17/20
to qubes...@googlegroups.com

>
> You haven't included AppVmTobeChanged as a target:
> qubesctl --show-output --targets=AppVmTobeChanged state.highstate
>
> You should check that you aren't getting a mistaken dom0 call.
>

That made the trick. Thanks unman!

One step forward, but still a way to go:
Currently I'm struggling to use pillars in my scripts. I have my scripts in
/srv/salt/user_salt
/srv/salt/user_pillar

Trying to enable a script containing some constants doesn't work because they cannot be found.
The only way to use pillars for me is passing them at the command line:
qubesctl ... pillar='{"name": "value"}'

But in this case I get errors in some scripts like this:
TypeError encountered executing state.highstate: highstate() takes from 0 to 1 positional arguments but 2 were given

after executing this commandline:
sudo qubesctl --show-output --target AppVmTobeChanged state.highstate pillar='{"name": "value"}'


Best case I'd manage to include pillars in my scripts. Any ideas how?

unman

unread,
May 17, 2020, 12:08:14 PM5/17/20
to qubes...@googlegroups.com
Can you post examples of the pillars you have written?
What exactly are you trying to do?

lik...@gmx.de

unread,
May 18, 2020, 2:17:06 PM5/18/20
to qubes...@googlegroups.com
On 2020-05-17 17:08, unman wrote:
My current goal is to automate the update of a fedora template as soon as a new one is available.
I'm trying to achieve this by these steps:
1. creating a clone of the default template
2. update this template with packages for a special purpose template

Details:
I created a top file like this:

-------- /srv/salt/user_salt/create_my_special_purpose_template.top --------
base:
dom0:
- match: nodegroup
- user_salt.create-template-clone

't-fedora-*-template-clone':
- user_salt.install-pkgs-for-special-purpose-template

-------- /srv/salt/user_salt/create_my_special_purpose_template.top --------

1. creating a clone of the default template is done by this file
-------- /srv/salt/user_salt/create-template-clone.sls --------
create-template-clone:
qvm.clone:
- name: t-fedora-{{ pillar['version'] }}-special-purpose-template
- source: fedora-{{ pillar['version'] }}-minimal

-------- /srv/salt/user_salt/create-template-clone.sls --------

2. update this template with packages for a special purpose template
-------- /srv/salt/user_salt/install-pkgs-for-special-purpose-template.sls --------
install-packages:
pkg.installed:
- pkgs:
- nano
- refresh: True
-------- /srv/salt/user_salt/install-pkgs-for-special-purpose-template.sls --------

In step 2 I'm trying to use pillars to be less dependent from the fedora version.

When I'm running the command:
sudo qubesctl --show-output --target t-fedora-31-template-clone state.highstate pillar='{"version": "31"}'

I get the error:
TypeError encountered executing state.highstate: highstate() takes from 0 to 1 positional arguments but 2 were given

That's why I'm trying to include pillars at least as a file, but don't manage to include them, so that they could by used by step 1.


Thank you very much by reading this long story... :) And if you've suggestion to solve it I even more appreciate it. :))

pr...@tuta.io

unread,
May 18, 2020, 5:45:09 PM5/18/20
to lik...@gmx.de, qubes...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

I think the pillar files need to be in /srv/pillar/
The following example should work:

/srv/pillar/fedora-version.top
base:
  dom0:
    - fedora-version

/srv/pillar/fedora-version.sls
version: 31

Then the file needs to be linked to another directory:
ln -s /srv/pillar/fedora-version.top /srv/pillar/_tops/base/fedora-version.top

This can be tested with the following command:
sudo qubesctl pillar.get version
And can be used in salt files as you have used it
-----BEGIN PGP SIGNATURE-----

iIgEARMKADAWIQRFNnsoPo7HH0XEMXc88cBGMbAIWAUCXsMAEhIccHJhZ29AdHV0
YW5vdGEuZGUACgkQPPHARjGwCFjP2AD/bV5z2DEkRvGtHEbv32MbRAAPN1uZDvfR
MR9DzIPEKnUA/2Zfz12HtzdtA/pIEAZoDceKrNLp7iua2Lk8HyStuyUw
=eySN
-----END PGP SIGNATURE-----

Reply all
Reply to author
Forward
0 new messages