Forum: CFEngine Help Subject: Suggestions needed on folder structure and paths in promises Author: sonofrage Link to topic: https://cfengine.com/forum/read.php?3,26715,26715#msg-26715
Hi everyone, I'm a beginner in cf-engine, and am starting with a simple project to run a few external shell scripts that I have created. Instead of directly working in the "masterfiles" folder, I have created a "/cf-test/project" folder which shall contain all the promises and required scripts. It has the following structure: /cf-test/project/ |-- promises.cf |-- cfengine_stdlib.cf |-- src/ (Contains all the bundles/bodies) | |-- check_jdk.cf |-- resources/ | |-- scripts/ (Contains scripts to be called from check_jdk.cf | |-- check_java_version.sh | |-- unzip_package.sh I'm using relative paths to call the scripts from check_jdk.cf, like: "scripts_folder" string => "resources/scripts"; My problem is, when I execute the promise, cfengine doesn't seem to find the sh files. # /var/cfengine/bin/cf-agent -f ./promises.cf -I -K Output: Proposed executable file "resources/scripts/check_java_version.sh" doesn't exist ... Proposed executable file "resources/scripts/unzip_package.sh" doesn't exist I tried to check the current directories by including the following commands: In promises.cf: "/bin/pwd"; In check_jdk.cf: "/bin/pwd | echo"; (the command /bin/pwd wouldn't get executed twice) And here's the output: -> Executing '/bin/pwd' ...(timeout=-678,owner=-1,group=-1) Q: ".../bin/pwd": /cf-test/project .. -> Executing '/bin/pwd | echo' ...(timeout=-678,owner=-1,group=-1) Q: ".../bin/pwd | echo": /bin/pwd: ignoring non-option arguments Q: ".../bin/pwd | echo": /cf-test I don't understand how the current directory changed between the promises.cf and the check_jdk.cf files. What could be the meaning of this? In essence, my question boils down to how I should go about referencing external files/paths inside promises, once I have defined a certain folder structure. Is it that everything needs to be an absolute path? Regards, sonofrage I have include below the relevant portions of promises.cf and check_jdk.cf: body common control { bundlesequence => { "path_check", "check_jdk" }; inputs => { "cfengine_stdlib.cf", "src/check_jdk.cf" }; } bundle agent path_check { commands: "/bin/pwd"; } bundle common pdef { vars: "scripts_folder" string => "resources/scripts"; "packages_folder" string => "/usr/local/packages"; "install_folder" string => "/usr/local/lib"; } body classes defclasses (x) { promise_repaired => { "$(x)_repaired" }; repair_failed => { "$(x)_repair_failed" }; promise_kept => { "$(x)_promise_kept" }; } bundle agent check_jdk { vars: any:: "jdk_version" string => "1.6.0_33"; 32_bit:: "jdk_arch" string => "i586"; 64_bit:: "jdk_arch" string => "x64"; commands: "/bin/pwd | echo"; "$(pdef.scripts_folder)/check_java_version.sh 6", classes => defclasses("jdk_6_check"); jdk_6_check_repair_failed:: "$(pdef.scripts_folder)/unzip_package.sh $(pdef.packages_folder)/jdk$(jdk_version).$(jdk_arch).zip $(pdef.install_folder)", } _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine