What does "qvm-run --no-gui ..."?

I am working on my automated minimal templates and I have faced one error with my helper function.

In my helper-functions.sh, one add-function ( ) does: First, installing a program and secondly creating and coping files to the template.

test-function ()

{

	qvm-run --pass-io -u root $CUSTOM_TEMPLATE "apt install -y --no-install-recommends gedit" || { echo "ERROR: apt install gedit WITHOUT --no-gui FAILED" && exit 1; }
	qvm-run --no-gui --pass-io -u root $CUSTOM_TEMPLATE "apt install -y --no-install-recommends curl" || { echo "ERROR: apt install curl WITH --no-gui FAILED" && exit 1; }
	#...

cat > ~/test.txt <<'endmsg'
This is the content of the text file...
endmsg

	qvm-copy-to-vm target-appvm ~/test.txt
	# ...
	# ...

}

Removing the || { echo "ERROR: apt install ... FAILED" && exit 1; } results in: gedit will not be installed.

The command qvm-run --pass-io -u root $CUSTOM_TEMPLATE "..." always worked for me but for this function I need to add --no-gui to make it run correctly. (thanks @Insurgo !)

With the default –gui it does not install the program (but all files are correctly created and transferred to the the template).

https://dev.qubes-os.org/projects/core-admin-client/en/latest/manpages/qvm-run.html#cmdoption-qvm-run-no-gui

Could you please explain why?
For the creation of automated templates, does it make sense to run all qvm-run with --no-gui?

It makes sense to use salt instead.

For example, your --pass-io will always pass dom0 stdin to the target VM. That may lead to unexpected behaviour in your scripts and to leakages in the worst case.
Also, self-written commands are often not idempotent (same result after multiple executions).

Anyway --gui or --no-gui shouldn’t matter much in your case. If they do, it’s either a bug in your code or in Qubes OS.

For a starter, learning salt is a long and different process. I, too, am writing bash scripts for installing and customizing the minimal templates that I have, and bash is much more approachable than salt, I would say.

In salt:

add_extras:
  pkg.installed:
    - names:
      - gedit
      - curl
    - install_recommends: False

add_text:
  file.managed:
    - source:
      - salt://test.txt
    

That seems pretty clear.
It has the advantage that pkg.installed will do the right thing
regardless of the distro and package manager, and isn’t prone to the
issues that @tripleh noted.

Ok, beside my original question …

As intermediated Qubes OS users should I stop continuing my automated minimal template work and do all with salt now? Is it the better way to go forward (for an intermediated user!)? Your explanation looks so simple …

The file format may be fairly straightforward, but the salt documentation is an impenetrable morass of talking about towers and columns and what-not (without prior definitions!), utterly unrelatable to what I’m actually trying to accomplish.

As a result of the documentation’s focus at such an extremely abstract level, I have no notion where to put that file, what to call it, and how to invoke it.

I get the sense I’d be all over it, if I could first figure out which end was up.

1 Like

Man, you assume that one already knows the format for writing this “salt text” or other intricacies about how salt works, what kind of a process that is, or what happens when it throws an error, how to catch an error and such.

Showing a few text lines and saying “that seems pretty clear” is disingenuous.

Exactly this. When I tried to read the docs on salt, I got lost in abstract concepts without having a grasp on what they entail.

I’d suggest you start with the Qubes documentation, and my notes at
https://github.com/unman/notes, where there are many examples.

You can start being productive in Qubes with very basic understanding.
Once you’ve started, you will be able to see how those more advanced
features come in to play.
And yes, the “salt” metaphors can be tiresome.

The link is broken.

Somewhat disingenuous of you to ignore my many posts on salt in Qubes,
and my repeated offers of help where needed.
A sensible reply could have been: “That looks clear. Can you point me to
somewhere where I could learn what that snippet does, how to use it,
and how to write my own?”
If you had asked that question, I would have pointed you to the Qubes
docs, and my notes on GitHub.

My point was that by contrast to the bash script, salt states are clear.

I’m guessing here it is: https://github.com/unman/notes.

Upd: notes/salt at master · unman/notes · GitHub

Indeed - can someone fix my mistake with an edit.

I’m not totally familiar with github but this looks like a collection of a bunch of different notes about different cases of things to do with salt.

Which one should an utterly clueless person click on first?

1 Like

Done.

Thanks

The one named Index?

git clone https://github.com/unman/notes will create a local copy ,
which will make it easier for you to step between note and examples.
All plain text.

I have looked at the first few files in this tutorial, and still, it is a mystery to me.

As I have repeatedly said - these are notes for training, not a tutorial.
Don’t “look at” the files - work through them, and work with the examples. That way you will
learn by doing.