2017-02-06 09:21:00 -05:00
|
|
|
---
|
2015-11-27 19:54:28 -05:00
|
|
|
layout: doc
|
|
|
|
title: Management stack
|
|
|
|
permalink: /doc/salt/
|
|
|
|
---
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
# Management Infrastructure
|
|
|
|
|
|
|
|
Since the Qubes R3.1 release we have included the Salt (also called SaltStack)
|
|
|
|
management engine in dom0 as default (with some states already configured).
|
|
|
|
Salt allows administrators to easily configure their systems.
|
|
|
|
In this guide we will show how it is set up and how you can modify it for your
|
|
|
|
own purpose.
|
2015-11-27 19:54:28 -05:00
|
|
|
|
|
|
|
In the current form the **API is provisional** and subject to change between
|
|
|
|
*minor* releases.
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
## Understanding Salt
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
This document is not meant to be comprehensive Salt documentation; however,
|
2015-11-27 19:54:28 -05:00
|
|
|
before writing anything it is required you have at least *some* understanding of
|
2017-05-08 04:45:56 -04:00
|
|
|
basic Salt-related vocabulary.
|
|
|
|
For more exhaustive documentation, visit [official site][salt-doc], though we
|
|
|
|
must warn you that it is not easy to read if you just start working with Salt
|
|
|
|
and know nothing.
|
|
|
|
|
|
|
|
### The Salt Architecture
|
|
|
|
|
|
|
|
Salt is a client-server model, where the server (called *master*) manages
|
|
|
|
its clients (called *minions*).
|
|
|
|
In typical situations, it is intended that the administrator interacts only
|
|
|
|
with the master and keeps the configurations there.
|
|
|
|
In Qubes, we don't have a master.
|
|
|
|
Instead we have one minion which resides in `dom0` and manages domains from
|
|
|
|
there.
|
|
|
|
This setup is also supported by Salt.
|
|
|
|
|
|
|
|
Salt is a management engine (similar to Ansible, Puppet, and Chef), that
|
|
|
|
enforces a particular state of a minion system.
|
|
|
|
A *state* is an end effect *declaratively* expressed by the administrator.
|
|
|
|
This is the most important concept in the entire engine.
|
|
|
|
All configurations (i.e., the states) are written in YAML.
|
|
|
|
|
|
|
|
A *pillar* is a data back-end declared by the administrator.
|
|
|
|
When states become repetitive, instead of pure YAML they can be written using a
|
|
|
|
template engine (preferably Jinja2); which can use data structures specified in
|
|
|
|
pillars.
|
|
|
|
|
|
|
|
A *formula* is a ready to use, packaged solution that combines a state and a
|
|
|
|
pillar (possibly with some file templates and other auxiliary files).
|
|
|
|
There are many formulas made by helpful people all over the Internet.
|
2015-11-27 19:54:28 -05:00
|
|
|
|
|
|
|
A *grain* is some data that is also available in templates, but its value is not
|
2017-05-08 04:45:56 -04:00
|
|
|
directly specified by administrator.
|
|
|
|
For example, the distribution (e.g., `"Debian"` or `"Gentoo"`) is a value of
|
|
|
|
the grain `"os"`. It also contains other information about the kernel,
|
|
|
|
hardware, etc.
|
|
|
|
|
|
|
|
A *module* is a Python extension to Salt that is responsible for actually
|
|
|
|
enforcing the state in a particular area.
|
|
|
|
It exposes some *imperative* functions for the administrator.
|
|
|
|
For example, there is a `system` module that has a `system.halt` function that,
|
|
|
|
when issued, will immediately halt a domain.
|
|
|
|
There is another function called `state.highstate` which will synchronize the
|
|
|
|
state of the system with the administrator's configuration/desires.
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-02-05 17:52:43 -05:00
|
|
|
### Configuration
|
|
|
|
|
|
|
|
#### States
|
|
|
|
|
|
|
|
The smallest unit of configuration is a state.
|
2017-05-08 04:45:56 -04:00
|
|
|
A state is written in YAML and looks like this:
|
2017-02-05 17:52:43 -05:00
|
|
|
|
|
|
|
stateid:
|
|
|
|
cmd.run: #this is the execution module. in this case it will execute a command on the shell
|
|
|
|
- name: echo 'hello world' #this is a parameter of the state.
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
The stateid has to be unique throughout all states running for a minion and can
|
|
|
|
be used to order the execution of the references state.
|
|
|
|
`cmd.run` is an execution module.
|
|
|
|
It executes a command on behalf of the administrator.
|
|
|
|
`name: echo 'hello world'` is a parameter for the execution module `cmd.run`.
|
|
|
|
The module used defines which parameters can be passed to it.
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
There is a list of [officially available states][salt-doc-states].
|
2017-02-05 17:52:43 -05:00
|
|
|
There are many very useful states:
|
2017-02-06 09:23:39 -05:00
|
|
|
|
2017-02-05 17:52:43 -05:00
|
|
|
* For [managing files][salt-doc-states-file]: Use this to create files or
|
|
|
|
directories and change them (append lines, replace text, set their content etc.)
|
|
|
|
* For [installing and uninstalling][salt-doc-states-pkg] packages.
|
2017-05-08 04:45:56 -04:00
|
|
|
* For [executing shell commands][salt-doc-states-cmd].
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
With these three states you can define most of the configuration of a VM.
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
You can also [order the execution][salt-doc-states-order] of your states:
|
2017-02-05 17:52:43 -05:00
|
|
|
|
|
|
|
D:
|
|
|
|
cmd.run:
|
|
|
|
- name: echo 1
|
|
|
|
- order: last
|
|
|
|
C:
|
|
|
|
cmd.run:
|
|
|
|
- name: echo 1
|
|
|
|
B:
|
|
|
|
cmd.run:
|
|
|
|
- name: echo 1
|
|
|
|
- require:
|
|
|
|
- cmd: A
|
|
|
|
- require_in:
|
|
|
|
- cmd:C
|
|
|
|
A:
|
|
|
|
cmd.run:
|
|
|
|
- name: echo 1
|
|
|
|
- order: 1
|
|
|
|
|
|
|
|
The order of execution will be `A, B, C, D`.
|
2017-05-08 04:45:56 -04:00
|
|
|
The official documentation has more details on the
|
|
|
|
[require][salt-doc-states-req] and [order][salt-doc-states-ord] arguments.
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
#### State Files
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
When configuring a system you will write one or more state files (`*.sls`) and
|
|
|
|
put (or symlink) them into the main Salt directory `/srv/salt/`.
|
|
|
|
Each state file contains multiple states and should describe some unit of
|
|
|
|
configuration (e.g., a state file `mail.sls` could setup a VM for e-mail).
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
#### Top Files
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
After you have several state files, you need something to assign them to a VM.
|
|
|
|
This is done by `*.top` files ([official documentation][salt-doc-top]).
|
2017-02-05 17:52:43 -05:00
|
|
|
Their structure looks like this:
|
|
|
|
|
|
|
|
environment:
|
|
|
|
target_matching_clause:
|
|
|
|
- statefile1
|
|
|
|
- folder2.statefile2
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
In most cases, the environment will be called `base`.
|
|
|
|
The `target_matching_clause` will be used to select your minions (VMs).
|
|
|
|
It can be either the name of a VM or a regular expression.
|
|
|
|
If you are using a regular expressions, you need to give Salt a hint you are
|
|
|
|
doing so:
|
2017-02-05 17:52:43 -05:00
|
|
|
|
|
|
|
environment:
|
|
|
|
^app-(work|(?!mail).*)$:
|
|
|
|
- match: pcre
|
|
|
|
- statefile
|
|
|
|
|
|
|
|
For each target you can write a list of state files.
|
2017-05-08 04:45:56 -04:00
|
|
|
Each line is a path to a state file (without the `.sls` extension) relative to
|
|
|
|
the main directory.
|
|
|
|
Each `/` is exchanged with a `.`, so you can't reference files or directories
|
|
|
|
with a `.` in their name.
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
### Enabling Top Files and Applying the States
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
Now, because we use custom extensions to manage top files (instead of just
|
|
|
|
enabling them all), to enable a particular top file you should issue command:
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
$ qubesctl top.enable my-new-vm
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
To list all enabled top files:
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
$ qubesctl top.enabled
|
2017-02-05 17:52:43 -05:00
|
|
|
|
|
|
|
And to disable one:
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
$ qubesctl top.disable my-new-vm
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
To apply the states to dom0 and all VMs:
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
$ qubesctl --all state.highstate
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
(More information on the `qubesctl` command further down.)
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
### Template Files
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
You will sometimes find yourself writing repetitive states.
|
|
|
|
To solve this, there is the ability to template files or states.
|
|
|
|
This is most commonly done with [Jinja][jinja].
|
|
|
|
Jinja is similar to Python and in many cases behaves in a similar fashion, but
|
|
|
|
there are sometimes differences when, for example, you set some variable inside
|
|
|
|
a loop: the variable outside will not get changed.
|
|
|
|
Instead, to get this behavior, you would use a `do` statement.
|
|
|
|
So you should take a look at the [Jinja API documentation][jinja-tmp].
|
|
|
|
Documentation about using Jinja to directly call Salt functions and get data
|
|
|
|
about your system can be found in the official
|
|
|
|
[Salt documentation][jinja-call-salt-functions].
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
## Salt Configuration, QubesOS layout
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
All Salt configuration files are in the `/srv/` directory, as usual.
|
|
|
|
The main directory is `/srv/salt/` where all state files reside.
|
|
|
|
States are contained in `*.sls` files.
|
|
|
|
However, the states that are part of the standard Qubes distribution are mostly
|
|
|
|
templates and the configuration is done in pillars from formulas.
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
The formulas are in `/srv/formulas`, including stock formulas for domains in
|
2015-11-27 19:54:28 -05:00
|
|
|
`/srv/formulas/dom0/virtual-machines-formula/qvm`, which are used by firstboot.
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
Because we use some code that is not found in older versions of Salt, there is
|
|
|
|
a tool called `qubesctl` that should be run instead of `salt-call --local`.
|
|
|
|
It accepts all the same arguments of the vanilla tool.
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-06-26 00:21:41 -04:00
|
|
|
## Configuring a VM's System from Dom0
|
2016-04-30 21:47:32 -04:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
Starting with Qubes R3.2, Salt in Qubes can be used to configure VMs from dom0.
|
|
|
|
Simply set the VM name as the target minion name in the top file.
|
|
|
|
You can also use the `qubes` pillar module to select VMs with a particular
|
|
|
|
property (see below).
|
|
|
|
If you do so, then you need to pass additional arguments to the `qubesctl` tool:
|
2016-04-30 21:47:32 -04:00
|
|
|
|
|
|
|
usage: qubesctl [-h] [--show-output] [--force-color] [--skip-dom0]
|
|
|
|
[--targets TARGETS | --templates | --app | --all]
|
|
|
|
...
|
|
|
|
|
|
|
|
positional arguments:
|
2017-05-08 04:45:56 -04:00
|
|
|
command Salt command to execute (e.g., state.highstate)
|
2016-04-30 21:47:32 -04:00
|
|
|
|
|
|
|
optional arguments:
|
|
|
|
-h, --help show this help message and exit
|
|
|
|
--show-output Show output of management commands
|
|
|
|
--force-color Force color output, allow control characters from VM,
|
|
|
|
UNSAFE
|
2017-05-08 04:45:56 -04:00
|
|
|
--skip-dom0 Skip dom0 configuration (VM creation etc)
|
2016-04-30 21:47:32 -04:00
|
|
|
--targets TARGETS Coma separated list of VMs to target
|
|
|
|
--templates Target all templates
|
|
|
|
--app Target all AppVMs
|
|
|
|
--all Target all non-disposable VMs (TemplateVMs and AppVMs)
|
|
|
|
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
To apply a state to all templates, call `qubesctl --templates state.highstate`.
|
2016-04-30 21:47:32 -04:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
The actual configuration is applied using `salt-ssh` (running over `qrexec`
|
|
|
|
instead of `ssh`).
|
|
|
|
Which means you don't need to install anything special in a VM you want to
|
|
|
|
manage.
|
|
|
|
Additionally, for each target VM, `salt-ssh` is started from a temporary VM.
|
|
|
|
This way dom0 doesn't directly interact with potentially malicious target VMs;
|
|
|
|
and in the case of a compromised Salt VM, because they are temporary, the
|
|
|
|
compromise cannot spread from one VM to another.
|
2016-04-30 21:47:32 -04:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
## Writing Your Own Configurations
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-05-11 04:48:59 -04:00
|
|
|
Let's start with a quick example:
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
my new and shiny VM:
|
2015-11-27 19:54:28 -05:00
|
|
|
qvm.present:
|
2015-11-29 09:14:16 -05:00
|
|
|
- name: salt-test # can be omitted when same as ID
|
2015-11-27 19:54:28 -05:00
|
|
|
- template: fedora-21
|
|
|
|
- label: yellow
|
|
|
|
- mem: 2000
|
|
|
|
- vcpus: 4
|
|
|
|
- flags:
|
|
|
|
- proxy
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
It uses the Qubes-specific `qvm.present` state, which ensures that the domain is
|
|
|
|
present (if not, it creates it).
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
* The `name` flag informs Salt that the domain should be named `salt-test` (not
|
|
|
|
`my new and shiny VM`).
|
|
|
|
* The `template` flag informs Salt which template should be used for the domain.
|
|
|
|
* The `label` flag informs Salt what color the domain should be.
|
|
|
|
* The `mem` flag informs Salt how much RAM should be allocated to the domain.
|
|
|
|
* The `vcpus` flag informs Salt how many Virtual CPUs should be allocated to the
|
|
|
|
domain
|
|
|
|
* The `proxy` flag informs Salt that the domain should be a ProxyVM.
|
|
|
|
|
|
|
|
As you will notice, the options are the same (or very similar) to those used in
|
|
|
|
`qvm-prefs`.
|
|
|
|
|
|
|
|
This should be put in `/srv/salt/my-new-vm.sls` or another `.sls` file.
|
|
|
|
A separate `*.top` file should be also written:
|
2015-11-27 19:54:28 -05:00
|
|
|
|
|
|
|
base:
|
|
|
|
dom0:
|
|
|
|
- my-new-vm
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
**Note** The third line should contain the name of the previous state file,
|
|
|
|
without the `.sls` extension.
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
To enable the particular top file you should issue the command:
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
$ qubesctl top.enable my-new-vm
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
To apply the state:
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
$ qubesctl state.highstate
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-06-26 00:21:41 -04:00
|
|
|
### Example of Configuring a VM's System from Dom0
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
Lets make sure that the `mc` package is installed in all templates.
|
|
|
|
Similar to the previous example, you need to create a state file
|
|
|
|
(`/srv/salt/mc-everywhere.sls`):
|
2016-04-30 21:47:32 -04:00
|
|
|
|
|
|
|
mc:
|
|
|
|
pkg.installed: []
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
Then the appropriate top file (`/srv/salt/mc-everywhere.top`):
|
2016-04-30 21:47:32 -04:00
|
|
|
|
|
|
|
base:
|
2017-01-03 07:46:28 -05:00
|
|
|
qubes:type:template:
|
2016-04-30 21:47:32 -04:00
|
|
|
- match: pillar
|
|
|
|
- mc-everywhere
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
Now you need to enable the top file:
|
2016-04-30 21:47:32 -04:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
$ qubesctl top.enable mc-everywhere
|
2016-04-30 21:47:32 -04:00
|
|
|
|
|
|
|
And apply the configuration:
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
$ qubesctl --all state.highstate
|
2016-04-30 21:47:32 -04:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
## All Qubes-specific States
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
### `qvm.present`
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
As in the example above, it creates a domain and sets its properties.
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
### `qvm.prefs`
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
You can set properties of an existing domain:
|
2015-11-27 19:54:28 -05:00
|
|
|
|
|
|
|
my preferences:
|
|
|
|
qvm.prefs:
|
|
|
|
- name: salt-test2
|
|
|
|
- netvm: sys-firewall
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
***Note*** The `name:` option will not change the name of a domain, it will only
|
|
|
|
be used to match a domain to apply the configurations to it.
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
### `qvm.service`
|
2015-11-27 19:54:28 -05:00
|
|
|
|
|
|
|
services in my domain:
|
|
|
|
qvm.service:
|
|
|
|
- name: salt-test3
|
|
|
|
- enable:
|
|
|
|
- service1
|
|
|
|
- service2
|
|
|
|
- disable:
|
|
|
|
- service3
|
|
|
|
- service4
|
|
|
|
- default:
|
|
|
|
- service5
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
This enables, disables, or sets to default, services as in `qvm-service`.
|
2015-11-27 19:54:28 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
### `qvm.running`
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
Ensures the specified domain is running:
|
2015-11-27 19:54:28 -05:00
|
|
|
|
|
|
|
domain is running:
|
|
|
|
qvm.running:
|
|
|
|
- name: salt-test4
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
## The `qubes` Pillar Module
|
2016-04-30 21:47:32 -04:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
Additional pillar data is available to ease targeting configurations (for
|
|
|
|
example all templates).
|
|
|
|
***Note*** List here may be subject to changes in future releases.
|
2016-04-30 21:47:32 -04:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
### `qubes:type`
|
2016-04-30 21:47:32 -04:00
|
|
|
|
|
|
|
VM type. Possible values:
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
- `admin` - Administration domain (`dom0`)
|
2016-04-30 21:47:32 -04:00
|
|
|
- `template` - Template VM
|
|
|
|
- `standalone` - Standalone VM
|
2017-05-08 04:45:56 -04:00
|
|
|
- `app` - Template based AppVM
|
2016-04-30 21:47:32 -04:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
### `qubes:template`
|
2016-04-30 21:47:32 -04:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
Template name on which a given VM is based (if any).
|
2016-04-30 21:47:32 -04:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
### `qubes:netvm`
|
2016-04-30 21:47:32 -04:00
|
|
|
|
|
|
|
VM which provides network to the given VM
|
|
|
|
|
2017-02-05 17:52:43 -05:00
|
|
|
## Debugging
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
The output for each VM is logged in `/var/log/qubes/mgmt-VM_NAME.log`.
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
If the log does not contain useful information:
|
2017-05-08 23:03:18 -04:00
|
|
|
1. Run `sudo qubesctl --skip-dom0 --target=VM_NAME state.highstate`
|
|
|
|
2. When your VM is being started (yellow) press Ctrl-z on qubesctl.
|
2017-02-05 17:52:43 -05:00
|
|
|
3. Open terminal in disp-mgmt-VM_NAME.
|
|
|
|
4. Look at /etc/qubes-rpc/qubes.SaltLinuxVM - this is what is
|
2017-05-08 04:45:56 -04:00
|
|
|
executed in the management VM.
|
2017-02-05 17:52:43 -05:00
|
|
|
5. Get the last two lines:
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
$ export PATH="/usr/lib/qubes-vm-connector/ssh-wrapper:$PATH"
|
|
|
|
$ salt-ssh "$target_vm" $salt_command
|
2017-02-05 17:52:43 -05:00
|
|
|
|
|
|
|
Adjust $target_vm (VM_NAME) and $salt_command (state.highstate).
|
|
|
|
6. Execute them, fix problems, repeat.
|
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
## Known Pitfalls
|
2017-02-06 09:34:48 -05:00
|
|
|
|
2017-02-05 17:52:43 -05:00
|
|
|
### Using fedora-24-minimal
|
2017-05-08 04:45:56 -04:00
|
|
|
|
|
|
|
The fedora-24-minimal package is missing the `sudo` package.
|
2017-02-05 17:52:43 -05:00
|
|
|
You can install it via:
|
|
|
|
|
2017-05-08 23:03:18 -04:00
|
|
|
$ qvm-run -p -u root fedora-24-minimal-template 'dnf install -y sudo'
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
The `-p` will cause the execution to wait until the package is installed.
|
2017-05-08 23:03:18 -04:00
|
|
|
Having the `-p` flag is important when using a state with `cmd.run`.
|
2017-05-08 04:45:56 -04:00
|
|
|
|
|
|
|
### Disk Quota Exceeded (When Installing Templates)
|
2017-02-05 17:52:43 -05:00
|
|
|
|
|
|
|
If you install multiple templates you may encounter this error.
|
2017-05-08 04:45:56 -04:00
|
|
|
The solution is to shut down the updateVM between each install:
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
install template and shutdown updateVM:
|
2017-02-05 17:52:43 -05:00
|
|
|
cmd.run:
|
2017-07-05 14:31:33 -04:00
|
|
|
- name: sudo qubes-dom0-update -y fedora-24; qvm-shutdown {% raw %}{{ salt.cmd.run(qubes-prefs updateVM) }}{% endraw %}
|
2017-02-05 17:52:43 -05:00
|
|
|
|
2017-05-08 04:45:56 -04:00
|
|
|
## Further Reading
|
2015-11-29 09:14:16 -05:00
|
|
|
|
|
|
|
* [Salt documentation][salt-doc]
|
2017-02-05 17:52:43 -05:00
|
|
|
* [Salt states][salt-doc-states] ([files][salt-doc-states-file], [commands][salt-doc-states-cmd],
|
|
|
|
[packages][salt-doc-states-pkg], [ordering][salt-doc-states-order])
|
|
|
|
* [Top files][salt-doc-top]
|
|
|
|
* [Jinja templates][jinja]
|
2015-11-29 09:14:16 -05:00
|
|
|
* [Qubes specific modules][salt-qvm-doc]
|
2017-05-08 04:45:56 -04:00
|
|
|
* [Formulas for default Qubes VMs][salt-virtual-machines-doc] ([and actual states][salt-virtual-machines-states])
|
2015-11-27 19:54:28 -05:00
|
|
|
|
|
|
|
[salt-doc]: https://docs.saltstack.com/en/latest/
|
2015-11-29 09:14:16 -05:00
|
|
|
[salt-qvm-doc]: https://github.com/QubesOS/qubes-mgmt-salt-dom0-qvm/blob/master/README.rst
|
|
|
|
[salt-virtual-machines-doc]: https://github.com/QubesOS/qubes-mgmt-salt-dom0-virtual-machines/blob/master/README.rst
|
|
|
|
[salt-virtual-machines-states]: https://github.com/QubesOS/qubes-mgmt-salt-dom0-virtual-machines/tree/master/qvm
|
2017-02-05 17:52:43 -05:00
|
|
|
[salt-doc-states]: https://docs.saltstack.com/en/latest/ref/states/all/
|
|
|
|
[salt-doc-states-file]: https://docs.saltstack.com/en/latest/ref/states/all/salt.states.file.html
|
|
|
|
[salt-doc-states-pkg]: https://docs.saltstack.com/en/latest/ref/states/all/salt.states.pkg.html
|
|
|
|
[salt-doc-states-cmd]: https://docs.saltstack.com/en/latest/ref/states/all/salt.states.file.html
|
|
|
|
[salt-doc-states-order]: https://docs.saltstack.com/en/latest/ref/states/ordering.html
|
|
|
|
[salt-doc-states-req]: https://docs.saltstack.com/en/latest/ref/states/requisites.html
|
|
|
|
[salt-doc-states-ord]: https://docs.saltstack.com/en/latest/ref/states/ordering.html#the-order-option
|
|
|
|
[salt-doc-top]:https://docs.saltstack.com/en/latest/ref/states/top.html
|
|
|
|
[jinja]: http://jinja.pocoo.org/
|
|
|
|
[jinja-tmp]: http://jinja.pocoo.org/docs/2.9/templates/
|
|
|
|
[jinja-call-salt-functions]: https://docs.saltstack.com/en/getstarted/config/jinja.html#get-data-using-salt
|