Project

General

Profile

« Previous | Next » 

Revision 73b67c1d

Added by Nicolas CHARLES over 6 years ago

Fixes #6564: The technique file copy from shared folder reports file source instead of file destination

View differences:

techniques/fileDistribution/copyGitFile/2.1/metadata.xml
-->
<TECHNIQUE name="File download (Rudder server)">
<DEPRECATED>This technique version has been superseded by a new version. It will no longer be available in the next stable version of Rudder. Please upgrade to the latest version.</DEPRECATED>
<DESCRIPTION>This technique ensure that some files are the copy of files on the shared folder of the Rudder Root Server, and let you optionally execute a command if the content of the file was modified</DESCRIPTION>
<MULTIINSTANCE>true</MULTIINSTANCE>
techniques/fileDistribution/copyGitFile/2.2/changelog
** Add option to set sticky bit on whole folder
-- Nicolas Charles <nicolas.charles@normation.com> Wed Dec 13 15:41:33 2017
* Version 2.2
** Report on desrination rather than on source
** Report on destination rather than on source
techniques/fileDistribution/copyGitFile/2.2/copyFileFromSharedFolder.st
"any" usebundle => file_check_symlink(dirname("${copyfile[${index}][destination]}"));
pass3.(!is_valid)::
"any" usebundle => rudder_common_report("copyFile", "result_error", "${copyfile[${index}][uuid]}", "Copy file", "${copyfile[${index}][name]}", "There is no shared folder on the Rudder Server, so it's not possible to copy a file from it");
"any" usebundle => rudder_common_report("copyFile", "result_error", "${copyfile[${index}][uuid]}", "Copy file", "${copyfile[${index}][destination]}", "There is no shared folder configured on the Rudder Server, so it's not possible to copy a file from it");
pass3.is_valid::
"any" usebundle => rudder_common_report("copyFile", "result_success", "${copyfile[${index}][uuid]}", "Copy file", "${copyfile[${index}][name]}", "The content of the file(s) is valid"),
"any" usebundle => rudder_common_report("copyFile", "result_success", "${copyfile[${index}][uuid]}", "Copy file", "${copyfile[${index}][destination]}", "The content of the file(s) (copied from ${copyfile[${index}][name]}) is valid"),
ifvarclass => "copy_file_${index}_kept.!copy_file_${index}_repaired.!copy_file_${index}_error";
"any" usebundle => rudder_common_report("copyFile", "result_repaired", "${copyfile[${index}][uuid]}", "Copy file", "${copyfile[${index}][name]}", "The content or permissions of the file(s) has been repaired"),
"any" usebundle => rudder_common_report("copyFile", "result_repaired", "${copyfile[${index}][uuid]}", "Copy file", "${copyfile[${index}][destination]}", "The content or permissions of the file(s) has been repaired from source ${copyfile[${index}][name]}"),
ifvarclass => "copy_file_${index}_repaired.!copy_file_${index}_error";
# Error conditons
# Error conditions
## The destination is not an existing directory or symbolic link
"any" usebundle => rudder_common_report("copyFile", "result_error", "${copyfile[${index}][uuid]}", "Copy file", "${copyfile[${index}][name]}", "The copy of the file failed: the destination (${copyfile[${index}][destination]}) is not stored in a valid directory"),
"any" usebundle => rudder_common_report("copyFile", "result_error", "${copyfile[${index}][uuid]}", "Copy file", "${copyfile[${index}][destination]}", "The copy of the file ${copyfile[${index}][name]} failed: the destination (${copyfile[${index}][destination]}) is not stored in a valid directory"),
ifvarclass => "copy_file_${index}_dest_notdir.file_check_symlink_${canon_dirname_${index}}_failed";
## File access denied
"any" usebundle => rudder_common_report("copyFile", "result_error", "${copyfile[${index}][uuid]}", "Copy file", "${copyfile[${index}][name]}", "The copy of the file failed: access to ${copyfile[${index}][name]} denied by the server"),
"any" usebundle => rudder_common_report("copyFile", "result_error", "${copyfile[${index}][uuid]}", "Copy file", "${copyfile[${index}][destination]}", "The copy of the file failed: access to ${copyfile[${index}][name]} denied by the server"),
ifvarclass => "copy_file_${index}_denied";
## User does not exist
"any" usebundle => rudder_common_report("copyFile", "result_error", "${copyfile[${index}][uuid]}", "Copy file", "${copyfile[${index}][name]}", "The permissions could not be applied on the file: user \"${copyfile[${index}][owner]}\" not found"),
"any" usebundle => rudder_common_report("copyFile", "result_error", "${copyfile[${index}][uuid]}", "Copy file", "${copyfile[${index}][destination]}", "The permissions could not be applied on the file: user \"${copyfile[${index}][owner]}\" not found"),
ifvarclass => "copy_file_${index}_user_absent";
## Group does not exist
"any" usebundle => rudder_common_report("copyFile", "result_error", "${copyfile[${index}][uuid]}", "Copy file", "${copyfile[${index}][name]}", "The permissions could not be applied on the file: group \"${copyfile[${index}][group]}\" not found"),
"any" usebundle => rudder_common_report("copyFile", "result_error", "${copyfile[${index}][uuid]}", "Copy file", "${copyfile[${index}][destination]}", "The permissions could not be applied on the file: group \"${copyfile[${index}][group]}\" not found"),
ifvarclass => "copy_file_${index}_group_absent";
## Generic failure
"any" usebundle => rudder_common_report("copyFile", "result_error", "${copyfile[${index}][uuid]}", "Copy file", "${copyfile[${index}][name]}", "The content or permissions of the file(s) could not have been repaired (file not found?)"),
"any" usebundle => rudder_common_report("copyFile", "result_error", "${copyfile[${index}][uuid]}", "Copy file", "${copyfile[${index}][destination]}", "The content or permissions of the file(s) could not have been repaired (file ${copyfile[${index}][name]} not found?)"),
ifvarclass => "copy_file_${index}_error.!copy_file_${index}_dest_notdir.!copy_file_${index}_denied.!copy_file_${index}_user_absent.!copy_file_${index}_group_absent";
#posthook reports
"any" usebundle => rudder_common_report("copyFile", "result_success", "${copyfile[${index}][uuid]}", "Post-modification hook", "${copyfile[${index}][name]}", "No post-hook command for ${copyfile[${index}][destination]} was defined, not executing"),
"any" usebundle => rudder_common_report("copyFile", "result_success", "${copyfile[${index}][uuid]}", "Post-modification hook", "${copyfile[${index}][destination]}", "No post-hook command for copy of ${copyfile[${index}][name]} to ${copyfile[${index}][destination]} was defined, not executing"),
ifvarclass => "!execute_command_${index}";
"any" usebundle => rudder_common_report("copyFile", "result_success", "${copyfile[${index}][uuid]}", "Post-modification hook", "${copyfile[${index}][name]}", "${copyfile[${index}][destination]} was already in the desired state, so no command was executed"),
"any" usebundle => rudder_common_report("copyFile", "result_success", "${copyfile[${index}][uuid]}", "Post-modification hook", "${copyfile[${index}][destination]}", "${copyfile[${index}][destination]} was already in the desired state, so no command was executed"),
ifvarclass => "execute_command_${index}.!copy_file_${index}_failed.!copy_file_${index}_repaired.copy_file_${index}_kept";
"any" usebundle => rudder_common_report("copyFile", "result_success", "${copyfile[${index}][uuid]}", "Post-modification hook", "${copyfile[${index}][name]}", "The post-hook command for ${copyfile[${index}][destination]} was correctly executed"),
"any" usebundle => rudder_common_report("copyFile", "result_success", "${copyfile[${index}][uuid]}", "Post-modification hook", "${copyfile[${index}][destination]}", "The post-hook command for copy of ${copyfile[${index}][name]} to ${copyfile[${index}][destination]} was correctly executed"),
ifvarclass => "execute_command_${index}.copyfile_posthook_${index}_command_run_ok";
"any" usebundle => rudder_common_report("copyFile", "result_error", "${copyfile[${index}][uuid]}", "Post-modification hook", "${copyfile[${index}][name]}", "The post-hook command for ${copyfile[${index}][destination]} couldn't be executed"),
"any" usebundle => rudder_common_report("copyFile", "result_error", "${copyfile[${index}][uuid]}", "Post-modification hook", "${copyfile[${index}][destination]}", "The post-hook command for copy of ${copyfile[${index}][name]} to ${copyfile[${index}][destination]} couldn't be executed"),
ifvarclass => "execute_command_${index}.copyfile_posthook_${index}_command_run_failed";
# A copy_from + perms could result in any combinaision of success/repaired/failed, so we have to cover the failed.modified which results in no copy
"any" usebundle => rudder_common_report("copyFile", "result_error", "${copyfile[${index}][uuid]}", "Post-modification hook", "${copyfile[${index}][name]}", "${copyfile[${index}][destination]} couldn't be copied, so the post-hook command is not executed"),
"any" usebundle => rudder_common_report("copyFile", "result_error", "${copyfile[${index}][uuid]}", "Post-modification hook", "${copyfile[${index}][destination]}", "${copyfile[${index}][destination]} couldn't be copied from ${copyfile[${index}][name]}, so the post-hook command is not executed"),
ifvarclass => "execute_command_${index}.copy_file_${index}_error";
commands:
techniques/fileDistribution/copyGitFile/2.2/metadata.xml
<SECTIONS>
<SECTION name="Copy file and PostHook" multivalued="true">
<SECTION name="Copy file" multivalued="false" component="true" componentKey="COPYFILE_NAME">
<SECTION name="Copy file" multivalued="false" component="true" componentKey="COPYFILE_DESTINATION">
<INPUT>
<NAME>COPYFILE_NAME</NAME>
<DESCRIPTION>Path of the file to be copied</DESCRIPTION>
......
</SECTION>
<SECTION name="Post-modification hook" component="true" multivalued="false" componentKey="COPYFILE_NAME" displayPriority="low">
<SECTION name="Post-modification hook" component="true" multivalued="false" componentKey="COPYFILE_DESTINATION" displayPriority="low">
<INPUT>
<NAME>COPYFILE_POST_HOOK_RUN</NAME>
<DESCRIPTION>Should the command(s) below be run if any modifications (permission or overwriting) are made on the files above?</DESCRIPTION>

Also available in: Unified diff