Re: [qubes-users] Failing Salt code: out of ideas and wrong error
On Wed, 2022-05-25 at 15:08 +0100, 'unman' via qubes-users wrote: > On Tue, May 24, 2022 at 11:54:27PM +0200, 'Johannes Graumann' via > qubes-users wrote: > > Can any one point me to why the following fails? I have been > > banging my > > head against this for a while ... > > > > --- SNIP --- > > create bind dirs config file: > > file.managed: > > - name: /rw/config/qubes-bind-dirs.d/50_user.conf > > - makedirs: True > > - mode: 644 > > - dir_mode: 755 > > > > {% set binddirs = ['/usr/local'] %} > > > > {% for binddir in binddirs %} > > configure '{{ binddir }}' to be persistent: > > file.replace: > > - name: /rw/config/qubes-bind-dirs.d/50_user.conf > > - pattern: "^binds+=( '{{ binddir }}' )$" > > - repl: "binds+=( '{{ binddir }}' )" > > - append_if_not_found: True > > {% endfor %} > > --- SNIP --- > > > > The corresponding error ("State 'create bind dirs config file' in > > SLS > > 'custom_dom0.sys-vpn-mpihlr_assert_vpn_setup' is not formed as a > > list") > > is a complete red herring, as the so called first part by itself > > works > > just fine and only fails when I add the latter (jinja) part ... > > > > How do I properly deal with the single quotes in `pattern` and > > `repl`? > > > > Thanks for any pointers. > > > > Sincerely, Joh > > > > > > Hi Joh > > Change the closing tag on the for statement to "-%}" > This is, I think, salt specific - according to the jinja specs it > will remove whitespace > Your use of single quotes in pattern and repl will be fine. > > A simpler (and lazier) formulation would use file.append: > > {% for binddir in binddirs %} > configure '{{ binddir }}' to be persistent: > file.append: > - name: /rw/config/qubes-bind-dirs.d/50_user.conf > - text: "binds+=( '{{ binddir }}' )" > - makedirs: True > {% endfor %} > > You can drop the explicit file.managed in this case. > > unman Thank you so much! Addition of the darn `-` made my problem disappear ... this one really had me pulling my hear out! Sincerely, Joh -- 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/63be168de19dca02f1e7760a318f6caff6fdf2ca.camel%40graumannschaft.org.
Re: [qubes-users] Failing Salt code: out of ideas and wrong error
On Tue, May 24, 2022 at 11:54:27PM +0200, 'Johannes Graumann' via qubes-users wrote: > Can any one point me to why the following fails? I have been banging my > head against this for a while ... > > --- SNIP --- > create bind dirs config file: > file.managed: > - name: /rw/config/qubes-bind-dirs.d/50_user.conf > - makedirs: True > - mode: 644 > - dir_mode: 755 > > {% set binddirs = ['/usr/local'] %} > > {% for binddir in binddirs %} > configure '{{ binddir }}' to be persistent: > file.replace: > - name: /rw/config/qubes-bind-dirs.d/50_user.conf > - pattern: "^binds+=( '{{ binddir }}' )$" > - repl: "binds+=( '{{ binddir }}' )" > - append_if_not_found: True > {% endfor %} > --- SNIP --- > > The corresponding error ("State 'create bind dirs config file' in SLS > 'custom_dom0.sys-vpn-mpihlr_assert_vpn_setup' is not formed as a list") > is a complete red herring, as the so called first part by itself works > just fine and only fails when I add the latter (jinja) part ... > > How do I properly deal with the single quotes in `pattern` and `repl`? > > Thanks for any pointers. > > Sincerely, Joh > > Hi Joh Change the closing tag on the for statement to "-%}" This is, I think, salt specific - according to the jinja specs it will remove whitespace Your use of single quotes in pattern and repl will be fine. A simpler (and lazier) formulation would use file.append: {% for binddir in binddirs %} configure '{{ binddir }}' to be persistent: file.append: - name: /rw/config/qubes-bind-dirs.d/50_user.conf - text: "binds+=( '{{ binddir }}' )" - makedirs: True {% endfor %} You can drop the explicit file.managed in this case. unman -- I **never** presume to speak for the Qubes team. When I comment in the Forum or in the mailing lists I speak for myself. -- 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/Yo44Q9qWm3fcpctZ%40thirdeyesecurity.org.
[qubes-users] Failing Salt code: out of ideas and wrong error
Can any one point me to why the following fails? I have been banging my head against this for a while ... --- SNIP --- create bind dirs config file: file.managed: - name: /rw/config/qubes-bind-dirs.d/50_user.conf - makedirs: True - mode: 644 - dir_mode: 755 {% set binddirs = ['/usr/local'] %} {% for binddir in binddirs %} configure '{{ binddir }}' to be persistent: file.replace: - name: /rw/config/qubes-bind-dirs.d/50_user.conf - pattern: "^binds+=( '{{ binddir }}' )$" - repl: "binds+=( '{{ binddir }}' )" - append_if_not_found: True {% endfor %} --- SNIP --- The corresponding error ("State 'create bind dirs config file' in SLS 'custom_dom0.sys-vpn-mpihlr_assert_vpn_setup' is not formed as a list") is a complete red herring, as the so called first part by itself works just fine and only fails when I add the latter (jinja) part ... How do I properly deal with the single quotes in `pattern` and `repl`? Thanks for any pointers. Sincerely, Joh -- 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/eb5ea5103d373739332790182caa3cec24049cdf.camel%40graumannschaft.org.