variable if class

Xander Cage <[email protected]>
Newsgroups gmane.comp.sysutils.cfengine.general
Message-ID <[email protected]>
hi,

i read this -> 
https://cmdln.org/2018/05/24/what-is-evaluated-first-in-cfengine-3-vars-or-classes/  
and i tried to use this higher kind of wisdom, but ...noooo

just want to read in a file in a string var if a specific class is defined 
eg. "the file exists".

body file control
{
  inputs => { "$(sys.libdir)/stdlib.cf", };
             }



bundle agent var_if_test {

    vars:
     "user" string => "schast";

     "ssh_key_dir" string => "/root/cfe_testbed/user_ssh_keys";

     "ssh_key" string => readfile("$(ssh_key_dir)/$(user).cf"),
               if => ( "exists_ssh_key" );


    classes:


            "exists_ssh_key"          expression => 
fileexists("$(ssh_key_dir)/$(user).cf");

    reports:

        "CFEngine $(sys.cf_version)";

      "$(ssh_key)"
        if => "exists_ssh_key";


}



bundle agent __main__
{
  methods:
      "var_if_test";
}

error: 

root@aixtest01: /root/cfe_testbed # /var/cfengine/bin/cf-agent -KI  -f 
./var_if_test.cf
./var_if_test.cf:17:23: error: syntax error
               if => ( "exists_ssh_key" );
                      ^
./var_if_test.cf:17:23: error: Invalid r-value type '('
               if => ( "exists_ssh_key" );
                      ^
./var_if_test.cf:17:40: error: Check previous line, Expected ';', got 
'"exists_ssh_key"'
               if => ( "exists_ssh_key" );
                                       ^
./var_if_test.cf:17:42: error: Expected promiser string, got ')'
               if => ( "exists_ssh_key" );
                                         ^
   error: There are syntax errors in policy files
   error: Policy failed validation with command 
'"/var/cfengine/bin/cf-promises" -c "./var_if_test.cf"'
   error: Failsafe condition triggered. Interactive session detected, 
skipping failsafe.cf execution.
   error: Error reading CFEngine policy. Exiting...

-- 
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/684af289-094e-420e-85ab-af4030b20decn%40googlegroups.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.