SALT: alternate execution of two domains within the same top file

I’m trying to configure a vm with 4 sls files, that should run in the following order (in square brackets is the domain in which the actions are executed):

  1. clone.sls [dom0]: clone debian-minimal into target-vm
  2. config1.sls [target-vm]: run initial vm configurations
  3. setprefs.sls [dom0]: configure target-vm prefs
  4. config2.sls [target-vm]: run final vm configurations

I cannot run (3) before (2). Initial vm configurations must be completed before I set vm prefs.

The most obvious way would be to define them in order, but this results in conflicting ID (since dom0 and target-vm are mentioned twice – changing names would also defeat the point):

$ cat /srv/user_salt/target-vm.top
user:
  dom0:
    - target-vm.clone

  target-vm:
    - target-vm.config1

  dom0:
    - target-vm.setprefs

  target-vm:
    - target-vm.config2

Then I tried with require, and then with order (not shown as the result is the same) but as it turns out: mapping values are not allowed in this context.

$ cat /srv/user_salt/target-vm.top
user:
  dom0:
    - target-vm.clone
    - target-vm.setprefs
      - require: target-vm.config1

  target-vm:
    - target-vm.config1
    - target-vm.config2
      - require: target-vm.setprefs

I know I could make two top files and run them sequentially, but since I want the process to be automated and as linear as possible, is there a way to have these actions complete in order, using one top file?

This appears to be a variation of another issue for which the suggestion is to run multiple vms configurations in different top files. But I run the configurations on only one vm (qubesctl --target=target-vm state.apply), so hopefully there is a way to achieve this without having to split the top file.

I also went through these other (great) guides but there seems to be no mention of this particular issue:

Unfortunately, you need two qubesctl calls for that. The execution order is hardcoded in qubesctl tool (first dom0, then templates, then standalones, then appvms).

1 Like

Got it. Cheers for the quick reply!