Forum: CFEngine Help Subject: Re: bundles: can a class argument be passed? Author: zzamboni Link to topic: https://cfengine.com/forum/read.php?3,24675,24682#msg-24682
If you have global classes, and you want to have a bundle that can act based on any of those classes, you could also use ifvarclass, something like this: body common control { version => "1.0.0"; bundlesequence => { "g", "main" }; } bundle common g { classes: "one" expression => "any"; } bundle agent main { methods: "any" usebundle => foo("one"); "any" usebundle => foo("two"); "any" usebundle => foo("three"); } bundle agent foo(classarg) { reports: cfengine:: # The decision is made based on the class whose name was passed as an argument "Class '$(classarg)' is defined" ifvarclass => "$(classarg)"; "Class '$(classarg)' is not defined" ifvarclass => "!$(classarg)"; } When run: $ /var/cfengine/bin/cf-agent -KI -f ./test.cf R: Class 'one' is defined R: Class 'two' is not defined R: Class 'three' is not defined _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine