Apt-cacher-ng cacher qube creating errors

I’m trying to use salt to create and install cacher proxy, following @unman’s notes at https://github.com/unman/shaker/tree/main/cacher, and I get the error at the beginning of the process running
qubesctl state.apply cacher.create (I think there is typo in the note, containing extra period at the end of the command?)

[user@dom0 ~]$ sudo qubesctl state.apply cacher.create
[ERROR ] Command ‘systemd-run’ failed with return code: 1
[ERROR ] stdout: Running scope as unit: run-r23b25769022a4d7a809aec112943d1fc.scope
Using sys-whonix as UpdateVM to download updates for Dom0; this may take some time…
Running ‘/usr/lib/qubes/qubes-download-dom0-updates.sh --doit --nogui ‘–exclude=qubes-template-*’ ‘-y’ ‘–best’ ‘–allowerasing’ ‘–clean’ ‘–action=install’ ‘debian-11-minimal’’ on sys-whonix
sys-whonix: command failed with code: 1
[ERROR ] retcode: 1
[ERROR ] Error occurred installing package(s). Additional info follows:

errors:
- Running scope as unit: run-r23b25769022a4d7a809aec112943d1fc.scope
Using sys-whonix as UpdateVM to download updates for Dom0; this may take some time…
Running `/usr/lib/qubes/qubes-download-dom0-updates.sh --doit --nogui ‘–exclude=qubes-template-*’ ‘-y’ ‘–best’ ‘–allowerasing’ ‘–clean’ ‘–action=install’ 'debian-11-minimal’’ on sys-whonix
sys-whonix: command failed with code: 1

Acoording to this @marmarek’s post here

how it is possible to use qubes-download-dom0-updates.sh to install debian-11-minimal if the scrip exist only in the updateVM, not in dom0?

What am I missing here?

I prepared and copied cacher folder to /srv/salt/ of course

Silly me. The command tried to be executed on sys-whonix. How to pass the error?

Does what I already stated at

have something with the cacher error?

enmus via Qubes OS Forum qubes_os@forum.qubes-os.org writes:

qubesctl state.apply cacher.create (I think there is typo in the note,
containing extra period at the end of the command?)

yes

[user@dom0 ~]$ sudo qubesctl state.apply cacher.create
[ERROR ] Command ‘systemd-run’ failed with return code: 1
[ERROR ] stdout: Running scope as unit:
run-r23b25769022a4d7a809aec112943d1fc.scope
Using sys-whonix as UpdateVM to download updates for Dom0; this may take some
time…
Running ‘/usr/lib/qubes/qubes-download-dom0-updates.sh --doit --nogui
‘–exclude=qubes-template-*’ ‘-y’ ‘–best’ ‘–allowerasing’ ‘–clean’
‘–action=install’ ‘debian-11-minimal’’ on sys-whonix
sys-whonix: command failed with code: 1
[ERROR ] retcode: 1
[ERROR ] Error occurred installing package(s). Additional info follows:

errors:
- Running scope as unit: run-r23b25769022a4d7a809aec112943d1fc.scope
Using sys-whonix as UpdateVM to download updates for Dom0; this may take
some time…
Running `/usr/lib/qubes/qubes-download-dom0-updates.sh --doit --nogui
‘–exclude=qubes-template-*’ ‘-y’ ‘–best’ ‘–allowerasing’ ‘–clean’
–action=install’ 'debian-11-minimal’’ on sys-whonix
sys-whonix: command failed with code: 1

Acoording to this @marmarek’s post here
Missing qubes-download-dom0-updates.sh - #5 by marmarek

how it is possible to use qubes-download-dom0-updates.sh to install debian-11-minimal if the scrip exist only in the updateVM, not in dom0?

What am I missing here?

I looks like a bug… But essentially, you should be able to install
that template manually with (and then salt will not try again to install
it) :

$ sudo qubes-dom0-update qubes-template-debian-11-minimal

I find ‘–exclude=qubes-template-*’ in your log suspicious.

Thanks for the response @dal.

I couldn’t trace this, it’s probably in the shell script. Even if i find it, I don’t know how would I “fix” it.

OK. Let’s try the next one. i have debian-11-minimal installed. Yet

local:
---------- ID: debian-11-minimal
Function: pkg.installed
Name: qubes-template-debian-11-minimal
Result: False (???)
Comment: Error occurred installing package(s). Additional info follows:

          errors:
Summary
              - Running scope as unit: run-rd2994f7ab33d429585ff20cdee6bfc94.scope
                Redirecting to 'qvm-template install -y --best --allowerasing --disablerepo=* --enablerepo=qubes-templates-itl debian-11-minimal'
                usage: qvm-template [--verbose] [--quiet] [--help] [--repo-files REPO_FILES]
                                    [--keyring KEYRING] [--updatevm UPDATEVM]
                                    [--enablerepo REPOID] [--disablerepo REPOID]
                                    [--repoid REPOS] [--releasever RELEASEVER] [--refresh]
                                    [--cachedir CACHEDIR] [--keep-cache] [--yes]
                                    {install,reinstall,downgrade,upgrade,download,list,info,search,remove,purge,clean,repolist}

qvm-template: error: unrecognized arguments: -y --best --allowerasing (???)
Started: 15:26:02.012097
Duration: 16833.202 ms
Changes:

Any idea?

enmus via Qubes OS Forum qubes_os@forum.qubes-os.org writes:

OK. Let’s try the next one. i have debian-11-minimal installed. Yet
[…]
Any idea?

What is the command you used ? What are exactly the .sls file targeted ?

As stated above. I’m using

$ sudo qubesctl state.apply cacher.create

and .sls from

shaker/cacher at main · unman/shaker · GitHub,

as well as template-debian-10(or)11-minimal.sls in /srv/salt from

I tried all possible combinations as well, having/not having debian-10(or)11-minimal installed but the command just don’t want to download debian-10(or)11-minimal.

Not only that template will not be skipped or downloaded, also nothing can be cloned by clone.sls

So, the error #3 is

Summary
      ID: qvm-clone-id
Function: qvm.clone
    Name: template-cacher
  Result: False
 `Comment: One or more requisite failed: template-debian-11-minimal.template-debian-11-minima`l
 Started: 13:14:46.871614
Duration: 0.009 ms
 Changes:   

I tried all possible combinations as well, having/not having
debian-10(or)11-minimal installed but the command just don’t want to
download debian-10(or)11-minimal.

If the template is installed with the correct name, Salt must recognize
it with qvm.present and not try to install it since it is already.

`Comment: One or more requisite failed:

template-debian-11-minimal.template-debian-11-minima`l

What happen if you try :

$ sudo qubesctl state.apply template-debian-11-minimal.template-debian-11-minimal

By the way the original include from the cacher repository is :

include:

  • template-debian-10-minimal

So in this use case the salt recipe is a top level of the directory, if
you ask template-debian-11-minimal.template-debian-11-minimal, that is
template-debian-11-minimal.sls in the directory template-debian-11-minimal.

It should, but it doesn’t for some reason and I’m trying to figure it out. Thanks for the ideas, though.

I tried, but it complains there’s no such thing in env base, of course?

Yes, as I stated above I tried with both debian-10 and debian-11 minimals. but nothing helps.

Can @unman help maybe?

enmus via Qubes OS Forum qubes_os@forum.qubes-os.org writes:

I tried, but it complains there’s no such thing in env base, of course?

Not good. Your previous log asked for
template-debian-11-minimal.template-debian-11-minimal; so why you
cannot launch it ?

Yes, as I stated above I tried with both debian-10 and debian-11 minimals. but nothing helps.

I am not sure if its relevant but I am trying to make you reduce the
issue to its essentials.

Your salt files must include a ‘template-debian-11-minimal’ recipe. It’s
a state file like others, so you must be able to launch it directly.

I understand and appreciate it. Thanks.

Because there isn’t such file? Shouldn’t that be template-debian-11-minimal.sls instead?

They do?

As I said, even when using provided files without any modification, template-debian-10-minimal.template-debian-10-minimal error is produced,

Are there any typos in those original .sls’?

enmus via Qubes OS Forum qubes_os@forum.qubes-os.org writes:

They do?

And do you have that template-debian-11-minimal on disk ?

So find out :

  1. how to call it directly.
  2. how to include it in your other files.

As I said, even when using provided files without any modification,
template-debian-10-minimal.template-debian-10-minimal error is produced,

Are there any typos in those original .sls’?

No. But as stated previously, the original files call include on
template-debian-10-minimal, it is not shipped with the repository.

So it is error prone and your following error seems to be about that :

 `Comment: One or more requisite failed:

template-debian-11-minimal.template-debian-11-minimal`

Thanks for your efforts dal, but I can’t follow you. It is trivial to manually download any debian template and to clone it to whatever name, and to put that name in other formulas to proper place, which I actually did, and then all other formulas work. My cacher qube was already set 10 days ago and is working flawlessly both with debian and fedora qubes.

I just wanted to discover what is wrong with first two formulas so other users having the same issue could benefit from it. Obviously they won’t, from me at least.

There are also some inconsistencies in unman’s two guides, with bind dirs, for example (they do not match here and here), and I thought something more must’ve been missing with template-debian-10-minimal.sls and clone.sls, but couldn’t seem to figure out what it was.

50_user.conf

shaker/cacher/ 50_user.conf

Latest commit b2f1e71 on Feb 2, 2021

2 lines (2 sloc) 74 Bytes

binds+=( ‘/var/cache/apt-cacher-ng’ )

binds+=( ‘/var/log/apt-cacher-ng’ )

notes/blob/master/apt-cacher-ng

notes/ apt-cacher-ng

Latest commit f1cb90a on Dec 16, 2018

In caching qube, use bind-dirs:

binds+=( ‘/var/cache/apt-cacher-ng’ )

binds+=( ‘/var/log/apt-cacher-ng’ )

binds+=( ‘/etc/apt-cacher-ng’)

This is all I found in journalctl -f

dom0 qubesd[3121]: permission denied for call b’admin.vm.Create.AppVM’+b’template-cacher’ (b’dom0’ → b’dom0’) with payload of 24 bytes

Couldn’t find anything useful on admin.vm.Create.AppVM other than

Hello @enmus.
Did you manage to get the cacher to work?

I’m having similar issues with qubesctl state.apply cacher.create but my error is:

local:
Data failed to compile:
------------
Specified SLS template-debian-11-minimal in saltenv base is not available on the salt master or through a configured fileserver

Unsure on how to proceed

I did, but as I said, I had to manually download/install debian-xx-template and to create clone of it. After that, the rest of the salt formula works.
You have to be more detailed in order to get help.

Because, for example, I don’t know if you read the topic carefully and if you created that sls file according to a link I posted above