Daniel Dehennin <daniel.dehen...@baby-gnu.org> writes: > Hello,
Hello, First huge thanks to Michael Potter who helped me open my eyes on this issue. > ===== promises.cf > body common control > { > bundlesequence => { "test" }; > version => "0.0.1"; > } > > bundle common hati > { > vars: > hati:: > "ip" string => "192.168.1.2"; > } > > bundle common srv1 > { > vars: > > srv1:: > "ip" string => "192.168.1.3"; > } > > bundle agent test > { > classes: > "ok" expression => "any"; > > reports: > > ok:: > "$($(sys.host)_ip)"; ^ "$($(sys.host).ip)"; > } > ===== Many noises for a typo, shame on me. Dynamic variable name works natively, here is a complex artificial example: #v+ body common control { bundlesequence => { "test" }; version => "0.0.2"; } bundle common hati { vars: hati:: "ip" string => "192.168.1.2"; "array1[hati]" string => "string in hati scoped array array1"; "array2[hati]" string => "string in hati scoped array array2"; } bundle common hostsinfos { vars: "array1[hati]" string => "string in hostsinfos scoped array array1"; "array2[hati]" string => "string in hostsinfos scoped array array2"; } bundle agent test { classes: "ok" expression => "any"; vars: "infoscope" slist => { "hostsinfos", "$(sys.host)" }; "r" ilist => { 1, 2 }; reports: ok:: "IP is $($(sys.host).ip)"; "$(const.dollar)(sys.host).array$(const.dollar)(r)[$(const.dollar)(sys.host)] : $($(sys.host).array$(r)[$(sys.host)])"; "$(const.dollar)(infoscope).array$(const.dollar)(r)[sys.host]: $($(infoscope).array$(r)[$(sys.host)])"; } #v- Which results in: #v+ R: IP is 192.168.1.2 R: $(sys.host).array$(r)[$(sys.host)] : string in hati scoped array array1 R: $(sys.host).array$(r)[$(sys.host)] : string in hati scoped array array2 R: $(infoscope).array$(r)[sys.host]: string in hostsinfos scoped array array1 R: $(infoscope).array$(r)[sys.host]: string in hostsinfos scoped array array2 R: $(infoscope).array$(r)[sys.host]: string in hati scoped array array1 R: $(infoscope).array$(r)[sys.host]: string in hati scoped array array2 #v- Thanks and sorry. -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1
pgphQxVEBySi3.pgp
Description: PGP signature
_______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine