Forum: Cfengine Help Subject: Re: Setting a variable conditionally, depending on a class? Author: phnakarin Link to topic: https://cfengine.com/forum/read.php?3,16796,16799#msg-16799
I would blame the problem on reports: stanza as it doesn't accept classes:: and 'ifvarclass' at the same time. The only way to sort it out in my mind is to include methods: to the policy. I haven't test the code yet, just following my fingers. body common control { bundlesequence => { "test" }; } # bundle agent test { vars: "nics" slist => getindices("sys.ipv4"); "ipregex" string => "192\.168\..*"; methods: linux:: "any" usebundle => display_matched("$(nics)","$(sys.ipv4[$(nics)])","$(ipregex)"); reports: linux:: "NICs found: $(nics)"; } # bundle agent display_matched(n,i,r) { classes: "ismatch" expression => regcmp("$(r)", "$(i)"); reports: ismatch:: "Matched NIC: $(n) ($(i))"; } Cheers, --Nakarin _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine