Re: variable if class
"'Nick Anderson' via help-cfengine" <[email protected]>
| Newsgroups | gmane.comp.sysutils.cfengine.general |
|---|---|
| Message-ID | <[email protected]> |
Bas van der Vlies <[email protected]> writes: > Hi Xander, your syntax is not correct: if => ( "exists_ssh_key" ); >must be: if => "exists_ssh_key"; Right, Alternatively, if there is just a single promise like this that you are guarding you can instead use a function. For example: ,---- | reports: | | "CFEngine $(sys.cf_version)"; | | "$(ssh_key)" | # if => "exists_ssh_key"; | if => fileexists( "$(ssh_key_dir)/$(user).cf" ); `---- Listing 1: Example Snippet But the benefit of having the class is that it can apply to multiple promises without having to re-check the file or re-state the dependancy. ,---- | bundle agent var_if_test { | | vars: | "user" string => "schast"; | | "ssh_key_dir" string => "/root/cfe_testbed/user_ssh_keys"; | | exists_ssh_key:: | "ssh_key" string => readfile("$(ssh_key_dir)/$(user).cf"); | | classes: | | "exists_ssh_key" | expression => fileexists("$(ssh_key_dir)/$(user).cf"); | | reports: | | "CFEngine $(sys.cf_version)"; | | exists_ssh_key:: | "$(ssh_key)"; | | "another promise, only if exists_ssh_key is defined"; | | } | bundle agent __main__ | { | methods: | "var_if_test"; | } `---- Listing 2: Example Policy -- 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/8735o5pfz0.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/8735o5pfz0.fsf%40northern.tech.