On Thu, Aug 24, 2023 at 11:26:30AM +0200, lik...@gmx.de wrote:
> Hi!
> 
> Running grains['os'] in a target returns always "Fedora" and grains['id'] 
> returns "dom0". For this reason I cannot branch in my state files for 
> different os templates.
> Executing this test in such a targeted state.sls:
> 
> test-grains-for-choosing-the-right-template:
>   test.configurable_test_state:
>     - name: "grains test"
>     - changes: True
>     - result: True
>     - comment: {{ grains['os'] ~ ", " ~ grains['id'] ~ ", " ~ 
> grains['osfullname'] ~ ", " ~ grains['os_family'] }}
> 
> returns
> grains['os']=Fedora, grains['os']=dom0, grains['osfullname']=Qubes, 
> grains['osfamily']=RedHat
> 
> Any ideas why this happens? How to branch correctly in a state file depending 
> on the os of the template?
> 
> Best, P!
> 

When you use qubesctl it acts in the following order - dom0, templates,
template based qube. Unless you specifically exclude dom0, the state
will be applied to dom0.

You havent said what command you entered, which would have been useful,
but my guess is that you used `qubesctl state.apply ...`
If you want to target a template, then you should use:
`qubesctl --skip-dom0 --targets=LIST_OF_TARGETS .....`

If you want a state file to be used BOTH for dom0 and templates, you can
use a "defensive" approach - there are examples of this at
http://github.com/unman/shaker
Use a jinja block like - {% if grains['nodename'] != 'dom0' %}
This will ensure that non-dom0 stuff gets correctly applied, while
making sure that those parts of the state dont get applied to dom0.

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/ZOh%2Bxvf2ReSaLmeP%40thirdeyesecurity.org.

Reply via email to