Re: Variables
"'Nick Anderson' via help-cfengine" <[email protected]>
| Newsgroups | gmane.comp.sysutils.cfengine.general |
|---|---|
| Message-ID | <[email protected]> |
thierry thunot <[email protected]> writes: > Hello everyone, I have a little problem with Cf. I want to use > parameterized variables to create classes more easily .. I tested this > for apache masi it is the philosophy that interests me to do this kind > of test bundle agent configuration_test_apache { vars: > "liste_module_apache" slist => {"rewrite","ssl","session"}; > "test_module_${liste_module_apache}_apache" string => > execresult("/usr/sbin/apache2ctl -M|grep > ${liste_module_apache}","noshell"); classes: > "module_${liste_module_apache}_nok" expression => > strcmp("${test_module_${liste_module_apache}_apache}",""); reports: > module_${liste_module_apache}_nok:: "MODULE APACHE > ${liste_module_apache} pas présent"; } Can you advise me on the best > way to proceed? Thank's !!! ;) Hi Thierry Not sure what specifically you are looking for, but on a quick scan of your policy: I don't believe that you can /pipe/ inside an `execresult()' without using a shell. ,---- | execresult("/usr/sbin/apache2ctl -M|grep ${liste_module_apache}","noshell"); `---- Also, I don't think it applies to apache modules since I don't think there are any whose names contain invalid class characters (e.g. `-'), but if you are creating classes from arbitrary strings, you should `canonify()' when /checking/. ,---- | "MODULE APACHE ${liste_module_apache} pas présent" | if => canonify( ${liste_module_apache} ); `---- And finally, you must /quote/ a variable class expression, again, beware if any `liste_module_apache' entry contains any characters that are not valid in a class name, this won't work. ,---- | "module_${liste_module_apache}_nok":: | "MODULE APACHE ${liste_module_apache} pas présent"; `---- -- You received this message because you are subscribed to the Google Groups "help-cfengine" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/help-cfengine/87h7c2wsc1.fsf%40northern.tech. -- Nick Anderson | Doer of Things | (+1) 785-550-1767 | https://northern.tech -- You received this message because you are subscribed to the Google Groups "help-cfengine" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/help-cfengine/87h7c2wsc1.fsf%40northern.tech.