Hi List I'm using the "unit_copy_edit.cf" example from the units/ directory to perform convergent copying and editing of configuration files to a cf-agent host.
My unit_copy_edit copies template config files, creates staging files and then should generate final configurations, but instead it dies with the following types of error message for 2 files I'm trying to copy and edit (when doing cf-agent -f promises.cf): --- File /var/cfengine/staging/etc/pf.conf was marked for editing but could not be opened File /var/cfengine/staging/etc/rc.conf was marked for editing but could not be opened --- I note that the staging files are created: --- [r...@server1.ops.exyzed.co.na /var/cfengine/staging/etc]# ls -l total 4 -rw-r--r-- 1 cfengine 1010 1872 May 10 11:15 pf.conf-staging-file -rw-r--r-- 1 cfengine 1010 1239 May 10 11:15 rc.conf-staging-file --- Here is an example of the configuration blocks from the file I'm using (based on unit_copy_edit.cf): ---- ######################################################## # Copy and edit convergently ######################################################## bundle agent configure_ng02 { vars: "config_source" string => "/var/cfengine/client_conf"; "config_dest1" string => "var/cfengine/staging/etc"; "config_dest2" string => "var/cfengine/staging/usr/local/etc"; files: #define the rc.conf source, destination and condition (class) under which #the copy will happen: "/$(config_dest1)/rc.conf-staging-file" comment => "Copy rc.conf from source to buffer", copy_from => cp("$(config_source)/rc.conf_template"), classes => satisfied("server1_ops_exyzed_co_na"); #define the pf.conf source, destination and condition (class) under which #the copy will happen: "/$(config_dest1)/pf.conf-staging-file" comment => "Copy from source to buffer", copy_from => cp("$(config_source)/pf.conf_template"), classes => satisfied("server1_ops_exyzed_co_na"); server1_ops_exyzed_co_na:: "/$(config_dest1)/pf.conf" comment => "Build a pf file template and expand keys", edit_line => ng02_edits("/$(config_dest1)/pf.conf-staging-file"), edit_defaults => empty; "/$(config_dest2)/munin/munin-node.conf" comment => "Build a munin-node.conf file template and expand keys", edit_line => ng02_edits("/$(config_dest2)/munin-node.conf-staging-file"), edit_defaults => empty; "/$(config_dest1)/rc.conf" comment => "Build a rc.conf file template and expand keys", edit_line => ng02_edits("/$(config_dest1)/rc.conf-staging-file"), edit_defaults => empty; files: #define the rc.conf source, destination and condition (class) under which #the copy will happen: "/$(config_dest1)/rc.conf-staging-file" comment => "Copy rc.conf from source to buffer", copy_from => cp("$(config_source)/rc.conf_template"), classes => satisfied("any"); #define the resolv.conf source, destination and condition (class) under which #the copy will happen: "/$(config_dest1)/resolv.conf-staging-file" comment => "Copy resolv.conf from source to buffer", copy_from => cp("$(config_source)/resolv.conf_template"), classes => satisfied("any"); #define the pf.conf source, destination and condition (class) under which #the copy will happen: "/$(config_dest1)/pf.conf-staging-file" comment => "Copy from source to buffer", copy_from => cp("$(config_source)/pf.conf_template"), classes => satisfied("any"); #define the snmpd.conf source, destination and condition (class) under #which "/$(config_dest1)/snmpd.conf-staging-file" comment => "Copy snmpd.conf from source to buffer", copy_from => cp("$(config_source)/snmpd_template"), classes => satisfied("any"); #define the nrpe.conf source, destination and condition (class) under which #the copy will happen: "/$(config_dest2)/nrpe-staging-file" comment => "Copy nrpe.conf from source to buffer", copy_from => cp("$(config_source)/nrpe.conf_template"), classes => satisfied("any"); #define the munin.conf source, destination and condition (class) under which #the copy will happen: "/$(config_dest2)/munin/munin-node.conf-staging-file" comment => "Copy munin-node.conf from source to buffer", copy_from => cp("$(config_source)/munin-node.conf_template"), classes => satisfied("any"); server1_ops_exyzed_co_na:: "/$(config_dest1)/pf.conf" comment => "Build a pf file template and expand keys", edit_line => ng02_edits("/$(config_dest1)/pf.conf-staging-file"), edit_defaults => empty; "/$(config_dest1)/rc.conf" comment => "Build a rc.conf file template and expand keys", edit_line => ng02_edits("/$(config_dest1)/rc.conf-staging-file"), edit_defaults => empty; } ### body copy_from cp(from) { source => "$(from)"; # compare => "mtime"; type_check => "true"; } ### bundle edit_line ng02_edits(f) { insert_lines: "$(f)" comment => "Populate empty file", insert_type => "file"; replace_patterns: "HOSTADDRESS" comment => "Replace a place-marker with the ip-address of this host", replace_with => rp("$(sys.ipv4[bce0])"); replace_with => rp("196.7.215.9"); "INTERFACE0" comment => "Replace a place-marker with the 0th interface of this host", replace_with => rp("$(sys.interface)"); "REPLACEKEY" comment => "Replace a dummy place-marker with random text of your choice", replace_with => rp("pattern successfully replaced by cfengine. copy edit successful."); } ### ### body replace_with rp(x) { replace_value => "$(x)"; occurrences => "first"; } ### body classes satisfied(x) { promise_repaired => { "$(x)" }; persist_time => "0"; } ### body edit_defaults empty { empty_file_before_editing => "true"; } ----- NOTE: This e-mail message and all attachments thereto contain confidential information intended for a specific addressee and purpose. If you are not the addressee (a) you may not disclose, copy, distribute or take any action based on the contents hereof; (b) kindly inform the sender immediately and destroy all copies hereof. Any copying, publication or disclosure of this message, or part hereof, in any form whatsoever, without the sender's express written consent, is prohibited. No opinion expressed or implied by the sender necessarily constitutes the opinion of MTN. This message does not constitute a guarantee or proof of the facts mentioned herein. No Employee or intermediary is authorised to conclude a binding agreement on behalf of MTN Group Limited, or any of its subsidiary companies, by e-mail without the express written confirmation by a duly authorised representative of MTN Group Limited. _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine