reclass and jinja template

martin f krafft madduck at madduck.net
Thu Jul 30 20:02:15 CEST 2015


Sorry for the late reply.

also sprach Stephan de Bot <stephan at b-it.org> [2015-07-25 11:23 +0200]:
>         nameservers:
>             - 192.168.1.1
>             - 192.168.1.2
>             - 192.168.1.3
>  So the entry on hostlevel does not override the on hosted@ level.
>  When I run the state I get all 3 nameservers  in resolv.conf.

Yes, this is a feature, and I realise that half the world want it
and the other half would prefer if lists were replaced.

So far, I have not found a smart way to let you have both, as I am
limited by YAML syntax on this one. And I really don't want to go
down the path of syntax addons, e.g. hacking such functionality into
names and interpreting the parsed output.

One idea might be to let an empty list clear an existing list, so
that you'd include a helper class after the base class which would
set

  nameservers: []

but this also gets ugly quite fast.

So far, the way I've dealt with this was to have the base class
define "nameservers_base_set" and define "nameservers" per-host and
then either used parameter expansion to seed the per-host list with
the base set, or used some Jinja2 logic to get to the result.

>  When I define the nameserver in reclass in a different way on hosted@ level:
>     nameservers:
>       192.168.1.1
>       192.168.1.2

No you are defining the content of "nameservers" to be a string…

>                   +nameserver 1
>                   +nameserver 9
>                   +nameserver 2
[…]

and when you iterate a string in Python, this is what you get.

-- 
@martinkrafft | http://madduck.net/ | http://two.sentenc.es/
 
"i think, therefore i'm single"
                                                      -- lizz winstead
 
spamtraps: madduck.bogus at madduck.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: digital_signature_gpg.asc
Type: application/pgp-signature
Size: 1107 bytes
Desc: Digital signature (see http://martin-krafft.net/gpg/sig-policy/999bbcc4/current)
URL: <http://lists.pantsfullofunix.net/pipermail/reclass/attachments/20150730/61b866bd/attachment.sig>


More information about the reclass mailing list