From 630395e1d7bcaecc7f6f04e5b1afa0f5a89488aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Membr=C3=A9?= Date: Wed, 26 Jul 2017 21:59:57 +0200 Subject: [PATCH] Fixes #11174: Add new method to get file from Rudder shared folder --- .../file_from_shared_folder.cf | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tree/30_generic_methods/file_from_shared_folder.cf diff --git a/tree/30_generic_methods/file_from_shared_folder.cf b/tree/30_generic_methods/file_from_shared_folder.cf new file mode 100644 index 000000000..da0c528c1 --- /dev/null +++ b/tree/30_generic_methods/file_from_shared_folder.cf @@ -0,0 +1,41 @@ +##################################################################################### +# Copyright 2013 Normation SAS +##################################################################################### +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +##################################################################################### + +# @name File copy from Rudder shared folder +# @description Ensure that a file or directory is copied from Rudder shared folder (/var/rudder/configuration-repository/shared-files) +# +# @parameter source Source file (path relative to Rudder shared folder) +# @parameter destination Destination file (absolute path on the target node) +# @parameter hash_type Hash algorithm used to check if file is updated +# +# @class_prefix file_from_shared_folder +# @class_parameter destination + +bundle agent file_from_shared_folder(source, destination, hash_type) +{ + vars: + "promisers" slist => { @{this.callers_promisers}, cf_null }, policy => "ifdefined"; + "class_prefix" string => canonify(join("_", "promisers")); + "args" slist => { "${source}", "${destination}" }; + + methods: + "copy without recursion" usebundle => file_copy_from_remote_source_recursion("/var/rudder/configuration-repository/shared-files/${source}", "${destination}", "0"); + "new result classes" usebundle => _classes_copy("${class_prefix}_copy_without_recursion", "${class_prefix}"); + + "report" usebundle => _log("Copying ${destination} from ${source}", "", "${class_prefix}", @{args}); +}