Using Salt to install packages in template VM (simple example) revisions

Go back to topic: Using Salt to install packages in template VM (simple example)

  1. v9 anchor; v9 full version
  2. v8 anchor; v8 full version
  3. v7 anchor; v7 full version
  4. v6 anchor; v6 full version
  5. v5 anchor; v5 full version
  6. v4 anchor; v4 full version
  7. v3 anchor; v3 full version
  8. v2 anchor; v2 full version

Revision #9

Edited on
2023-09-07
Edited by user
deeplow

Revision #8

Edited on
2022-08-24
Edited by user
gust
- fedora-general #sls file reference - fedora-general #sls file reference, omitting ".sls"
(The last argument is the name of your top file minus ".top")
If you get something like `State 'foo' in SLS 'bar' is not formed as a list`, it means either your YAML is invalid OR that the YAML is valid but does not constitute valid syntax for an SLS file. In my case it gave me this error when I forgot the dash and space before `pkgs:` in my SLS above.

Revision #7

Edited on
2022-08-24
Edited by user
gust
Today I decided to just buckle down and focus on a narrow, simple task: Use Salt to install packages into a new template VM (already installed). I usually do this manually, using a text file I maintain with instructions and lists of packages, typing and pasting things into the terminal. Today I decided to just buckle down and focus on a narrow, simple task: Use Salt to install packages into a new template VM (already existing on my machine). I usually do this manually, using a text file I maintain with instructions and lists of packages, typing and pasting things into the terminal.
Let's assume you have a list of packages to install in one or more template VMs. Let's assume for purposes of this guide that you call the list **fedora-general**. This is a conceptual name and is not used to select templates so it can anything. Just know that anywhere you see "fedora-general" here, replace with your own name if different. (I chose this name because I always have a fedora template ending "-general" - "fedora-33-general", "fedora-34-general" and so forth. In these I install broadly useful packages.) Let's assume you have a list of packages to install in one or more template VMs. Let's assume for purposes of this guide that you call the list **fedora-general**. This is a conceptual name and is not used to select templates so it can be anything. Just know that anywhere you see "fedora-general" here, replace with your own name if different. (I chose this name because I always have a fedora template ending "-general" - "fedora-33-general", "fedora-34-general" and so forth. In these I install broadly useful packages.)

Revision #6

Edited on
2022-08-24
Edited by user
gust
Today I decided to just buckle down and focus on a narrow, simple task: Use Salt to install packages into a new template VM. I usually do this manually, using a text file I maintain with instructions and lists of packages. Today I decided to just buckle down and focus on a narrow, simple task: Use Salt to install packages into a new template VM (already installed). I usually do this manually, using a text file I maintain with instructions and lists of packages, typing and pasting things into the terminal.
Why is the big main command called `state.highstate`? I have no idea. In addition to being redundant (two uses of "state", why not `state.high`?), it's also unclear what "high" means. Are there "low" states? Medium? Why not, like, `state.apply`? (I know this forum is not the place to complain about this stuff except I think other newbs might feel some comfort at knowing they are not the only ones who wonderwhat the heck is up with this weird phrasing.) Why is the big main command called `state.highstate`? I have no idea. In addition to being redundant (two uses of "state", why not `state.high`?), it's also unclear what "high" means. Are there "low" states? Medium? Why not, like, `state.apply`? (I know this forum is not the place to complain about this stuff except I think other newbs might feel some comfort at knowing they are not the only ones who wonder what the heck is up with this weird phrasing.)

Revision #5

Edited on
2022-08-24
Edited by user
gust
These are literally my first Salt files, **I am open to feedback**. Hopefully this helps other newbs. These are literally my first Salt files, **I am open to feedback**. Hopefully this helps other newbs. That said these are tested and do work for me.
Let's assume you have a list of packages to install that will be of use to some of your templates. Let's assume for purposes of this guide that you call the list **fedora-general**. This is a conceptual name and is not used to select templates so it can anything. Just know that anywhere you see "fedora-general" here, replace with your own name if different. (I chose this name because I always have a fedora template ending "-general" - "fedora-33-general", "fedora-34-general" and so forth. In these I install broadly useful packages.) Let's assume you have a list of packages to install in one or more template VMs. Let's assume for purposes of this guide that you call the list **fedora-general**. This is a conceptual name and is not used to select templates so it can anything. Just know that anywhere you see "fedora-general" here, replace with your own name if different. (I chose this name because I always have a fedora template ending "-general" - "fedora-33-general", "fedora-34-general" and so forth. In these I install broadly useful packages.)
Why is the big main command called `state.highstate`? I have no idea. In addition to being redundant (two uses of "state", why not `state.high`?), it's also unclear what "high" means. Are there "low" states? Medium? Why not, like, `state.apply`? (I know this forum is not the place to complain about this stuff except I think other newbs might feel some comfort at wondering what the heck is up with this weird phrasing - you are not alone if you wonder this!) Also, right now the top file fees a little like boilerplate to me. Couldn't I just invoke the states through a command line composition? Anyway, I'm new, maybe it will all make sense.Why is the big main command called `state.highstate`? I have no idea. In addition to being redundant (two uses of "state", why not `state.high`?), it's also unclear what "high" means. Are there "low" states? Medium? Why not, like, `state.apply`? (I know this forum is not the place to complain about this stuff except I think other newbs might feel some comfort at knowing they are not the only ones who wonderwhat the heck is up with this weird phrasing.) Also, right now the top file concept feels a little like boilerplate to me. Couldn't I just invoke the states through a command line composition that specifies machines? Anyway, I'm new, maybe it will all make sense in time as I learn more.

Revision #4

Edited on
2022-08-24
Edited by user
gust
A Salt State file describes a state you want the machine/VM to reach and is composed of a series of sections like the above: ``` stateid: execution-module: - param - param ``` Docs for some of the more interesting execution modules are [linked here under "further reading" at the bottom](https://www.qubes-os.org/doc/salt/#further-reading).
Make a salt top file in dom0 at `/srv/salt/fedora-general.top` that looks like this: Make a salt top file in dom0 at `/srv/salt/fedora-general.top` that looks like this, replacing "fedora-36-general" with the name of the VM you wish to install packages into:
``` ``` If you want to install into multiple VMs, instead of specifying "fedora-36-general" or whatever you can use a regex syntax, described [in the "top files" section here](https://www.qubes-os.org/doc/salt/#top-files). The top file maps state files to machines, basically.
``` ```
(You can add additional templates using commas in `--targets=`. There are further options, like "all", in the help for `qubesctl`.) (You can add additional template vms using commas in `--targets=`. There are further options, like "all", in the help for `qubesctl`. Just make sure these template vms are also selected in your top file above.)
The [Qubes docs on Salt](https://www.qubes-os.org/doc/salt/) are my favorite Salt docs. A nice concise explanation of Salt (better than on the official tutorial) and then a nice explanation of Qubes integration. The Salt [docs on package state](https://docs.saltproject.io/en/latest/ref/states/all/salt.states.pkg.html) are linked from the previous and are perhaps useful for customizing the above. The [Qubes docs on Salt](https://www.qubes-os.org/doc/salt/) are my favorite Salt docs. A nice concise explanation of Salt (better than on the official tutorial) and then a nice explanation of Qubes integration. The Salt [docs on package state](https://docs.saltproject.io/en/latest/ref/states/all/salt.states.pkg.html) are linked from the previous and are perhaps useful for customizing the above. The [further reading section](https://www.qubes-os.org/doc/salt/#further-reading) of the Qubes docs on salt, at the bottom, is also useful.

Revision #3

Edited on
2022-08-24
Edited by user
gust
Let's assume you have a list of packages to install that will be of use to some of your templates. Let's assume you call them **fedora-general**. Anywhere you see "fedora-general" here, replace with your own name if different. Let's assume you have a list of packages to install that will be of use to some of your templates. Let's assume for purposes of this guide that you call the list **fedora-general**. This is a conceptual name and is not used to select templates so it can anything. Just know that anywhere you see "fedora-general" here, replace with your own name if different. (I chose this name because I always have a fedora template ending "-general" - "fedora-33-general", "fedora-34-general" and so forth. In these I install broadly useful packages.)

Revision #2

Edited on
2022-08-24
Edited by user
gust
##Backstory **Backstory**
##I'm a beginner **I'm a beginner**
##Howto **Howto**
*1. State file*
``` ``` *2. Top file*
*3. Enable top file*
``` ``` *4. Execute state change*
(You can add additional templates using commas. There are further options, like "all", in the help for qubesctl.) (You can add additional templates using commas in `--targets=`. There are further options, like "all", in the help for `qubesctl`.)
##Further reading The [Qubes docs on Salt](https://www.qubes-os.org/doc/salt/) are my favorite Salt docs. A nice concise explanation of Salt (better than on the official tutorial) and then a nice explanation of Qubes integration. The Salt [docs on package state](https://docs.saltproject.io/en/latest/ref/states/all/salt.states.pkg.html) are linked from the previous and are perhaps useful for customizing the above.**Further reading** The [Qubes docs on Salt](https://www.qubes-os.org/doc/salt/) are my favorite Salt docs. A nice concise explanation of Salt (better than on the official tutorial) and then a nice explanation of Qubes integration. The Salt [docs on package state](https://docs.saltproject.io/en/latest/ref/states/all/salt.states.pkg.html) are linked from the previous and are perhaps useful for customizing the above. **Annoyances** Why is the big main command called `state.highstate`? I have no idea. In addition to being redundant (two uses of "state", why not `state.high`?), it's also unclear what "high" means. Are there "low" states? Medium? Why not, like, `state.apply`? (I know this forum is not the place to complain about this stuff except I think other newbs might feel some comfort at wondering what the heck is up with this weird phrasing - you are not alone if you wonder this!) Also, right now the top file fees a little like boilerplate to me. Couldn't I just invoke the states through a command line composition? Anyway, I'm new, maybe it will all make sense.