"$(this.promise_dirname)/logstash/."
create => "true",
copy_from => secure_cp("/var/cfengine/masterfiles/services/ELK/logstash/templates/.", "$(sys.policy_hub)"),
file_select => by_name(".*"),
depth_search => recurse("inf");
"$(logstash_config_dir)/."
create => "true",
copy_from => local_cp("$(this.promise_dirname)/logstash/templates/."),
file_select => by_name(".*"),
depth_search => recurse("inf"),
move_obstructions => "true",
Hi Bill,
Bill G <tc3d...@gmail.com> writes:
> I believe I have run across a bug with localcp (pertinent snippets from
> promise):
"$(this.promise_dirname)/logstash/." create => "true", copy_from => secure_cp( "/var/cfengine/masterfiles/services/ELK/logstash/templates/.", "$(sys.policy_hub)"), file_select => by_name(".*"), depth_search => recurse("inf");
"$(logstash_config_dir)/." create => "true", copy_from => local_cp("$(this.promise_dirname)/logstash/templates/."), file_select => by_name(".*"), depth_search => recurse("inf"), move_obstructions => "true",
> which results in:
cf-agent[9539]: CFEngine(agent) Can't stat file '$(this.promise_dir)/logstash/templates/.' on 'localhost' in files.copy_from promise
Hum, the error message here looks like there is a typo. It contains
$(this.promise_dir)
instead of $(this.promise_dirname)
. Ref
this.promisedirname. However in the policy snippet above it looks to be
correct.
bundle agent main { methods: "init"; "test"; "check"; } bundle agent init # Make sure there are files to copy from. { vars: "files" slist => { "dir1/file1.txt", "dir2/file2.txt", "file3.txt" }; files: "$(this.promise_dirname)/logstash/templates/$(files)" create => "true", edit_defaults => empty, edit_line => insert_lines( $(sys.date) ); } bundle agent test { vars: "logstash_config_dir" string => "/tmp/dest"; files:
"$(logstash_config_dir)/." create => "true", copy_from => local_cp("$(this.promise_dirname)/logstash/templates/."), file_select => by_name(".*"), depth_search => recurse("inf")
, move_obstructions => "true"; } bundle agent check { reports: "Files in destination: $(with)" with => join( ", ", findfiles("$(test.logstash_config_dir)/**/*") ); } body edit_defaults empty # @brief Empty the file before editing # # No backup is made { empty_file_before_editing => "true"; edit_backup => "false"; #max_file_size => "300000"; } body depth_search recurse(d) # @brief Search files and direcories recursively, up to the specified depth # Directories on different devices are included. # # @param d The maximum search depth { depth => "$(d)"; xdev => "true"; } body file_select by_name(names) # @brief Select files that match `names` # @param names A regular expression { leaf_name => { @(names)}; file_result => "leaf_name"; } body copy_from local_cp(from) # @brief Copy a file if the modification time or creation time of the source # file is newer (the default comparison mechanism). # @param from The path to the source file. # # **Example:** # # ```cf3 # bundle agent example # { # files: # "/tmp/file.bak" # copy_from => local_cp("/tmp/file"); # } # ``` # # **See Also:** `local_dcp()` { source => "$(from)"; } bundle edit_line insert_lines(lines) # @brief Alias for `lines_present` { insert_lines: "$(lines)" comment => "Append lines if they don't exist"; }
> $ cf-agent -KIf ./example.cf info: Created file '/tmp/source/./logstash/templates/dir1/file1.txt', mode 0600 info: Edit file '/tmp/source/./logstash/templates/dir1/file1.txt' info: Created file '/tmp/source/./logstash/templates/dir2/file2.txt', mode 0600 info: Edit file '/tmp/source/./logstash/templates/dir2/file2.txt' info: Created file '/tmp/source/./logstash/templates/file3.txt', mode 0600 info: Edit file '/tmp/source/./logstash/templates/file3.txt' info: Created directory '/tmp/dest/.' info: Copying from 'localhost:/tmp/source/./logstash/templates/./dir2/file2.txt' info: Copying from 'localhost:/tmp/source/./logstash/templates/./dir1/file1.txt' info: Copying from 'localhost:/tmp/source/./logstash/templates/./file3.txt' R: Files in destination: /tmp/dest/dir1/file1.txt, /tmp/dest/dir2/file2.txt
However, if I change the localcp to securecp and use the full path of the
'masterfiles' location it works as expected, just becomes a heavier
operation than what I would like to see. I will also note that the local
directories do exist and contain the expected files and directories.
Can you double check? It seems to work fine in my testing. Have I overlooked something?
> Other than that, it is fun to knock the rust off.
Hopefully it won't get rusty again. :-)
–
Nick Anderson
Doer of things, CFEngine
Have a great weekend.
Ok, please let us know how it works out.
Have a great weekend.
--
You received this message because you are subscribed to a topic in the Google Groups "help-cfengine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/help-cfengine/68_UnlLZHIQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to help-cfengine+unsubscribe@googlegroups.com.
To post to this group, send email to help-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/help-cfengine.
For more options, visit https://groups.google.com/d/optout.