Details
-
Type:
Bug
-
Status: Open
-
Priority:
(None)
-
Resolution: Unresolved
-
Affects Version/s: 3.19.0
-
Fix Version/s: None
-
Component/s: cf-agent
-
Labels:None
Description
if should be evaluated before with if $(with) is not used in if
bundle agent var_if_test { vars: "user" slist => {"schast", "wimm", "schama" }; #"ssh_key_dir" string => "/root/cfe_testbed/user_ssh_keys"; "ssh_key_dir" string => "/tmp"; classes: "exists_ssh_key_$(user)" expression => fileexists("$(ssh_key_dir)/$(user).cf"); reports: "CFEngine $(sys.cf_version)"; "$(user) -> $(with)" # This generates CfReadFile errors because it's trying to read a file that doesn't exist with => readfile("$(ssh_key_dir)/$(user).cf"), # But, the read should have been guarded by the check for the presence of this condition if => "exists_ssh_key_$(user)"; "ABSENT: $(user)" unless => "exists_ssh_key_$(user)"; } bundle agent __main__ { methods: "var_if_test"; }
error: CfReadFile: Could not examine file '/tmp/schast.cf' (stat: No such file or directory) error: CfReadFile: Could not examine file '/tmp/schama.cf' (stat: No such file or directory) R: CFEngine 3.19.0a.da01eaa81 error: CfReadFile: Could not examine file '/tmp/schast.cf' (stat: No such file or directory) R: wimm -> hello error: CfReadFile: Could not examine file '/tmp/schama.cf' (stat: No such file or directory) R: ABSENT: schast R: ABSENT: schama error: CfReadFile: Could not examine file '/tmp/schast.cf' (stat: No such file or directory) error: CfReadFile: Could not examine file '/tmp/schama.cf' (stat: No such file or directory) error: CfReadFile: Could not examine file '/tmp/schast.cf' (stat: No such file or directory) error: CfReadFile: Could not examine file '/tmp/schama.cf' (stat: No such file or directory)
https://groups.google.com/g/help-cfengine/c/xZmbOai_kis/m/v3ULNkNRAwAJ