-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #3389 - Add possibility to exclude a file or files matching a regexp from a folder copy #171
Merged
jooooooon
merged 1 commit into
Normation:branches/rudder/2.4
from
nperron:ust_3364/dev/3389_add_exclude_file_or_regexp_from_folder_copy_BIS
Sep 22, 2013
Merged
Fixes #3389 - Add possibility to exclude a file or files matching a regexp from a folder copy #171
jooooooon
merged 1 commit into
Normation:branches/rudder/2.4
from
nperron:ust_3364/dev/3389_add_exclude_file_or_regexp_from_folder_copy_BIS
Sep 22, 2013
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@nperron, GitHub says this PR can't be merged. Can you rebase, and confirm it should be reviewed? |
…egexp from a folder copy
I've reworked, rebased and updated this PR. The diff with the previous version of the Technique is: diff -Naurw 1.4/copyFileFromSharedFolder.st 1.5/copyFileFromSharedFolder.st
--- 1.4/copyFileFromSharedFolder.st 2013-09-06 15:45:08.890069171 +0200
+++ 1.5/copyFileFromSharedFolder.st 2013-09-06 17:12:22.673821939 +0200
@@ -25,6 +25,12 @@
©FILE_NAME:{name |"copyfile[&i&][name]" string => "&name&";
}&
+ ©FILE_EXCLUDE_INCLUDE:{exclude_include |"copyfile[&i&][exclude_include]" string => "&exclude_include&";
+}&
+
+ ©FILE_EXCLUDE_INCLUDE_OPTION:{exclude_include_option |"copyfile[&i&][exclude_include_option]" string => "&exclude_include_option&";
+}&
+
©FILE_RECURSION:{rec |"copyfile[&i&][recursion]" string => "&rec&";
}&
@@ -74,11 +80,15 @@
"is_file_${index}" not => isdir("${copyfile[${index}][destination]}");
"exist_${index}" expression => fileexists("${copyfile[${index}][destination]}");
+ "need_exclusion_${index}" and => { isvariable("copyfile[${index}][exclude_include]"), strcmp("${copyfile[${index}][exclude_include_option]}", "exclude") };
+ "need_inclusion_${index}" and => { isvariable("copyfile[${index}][exclude_include]"), strcmp("${copyfile[${index}][exclude_include_option]}", "include") };
+ "apply_regex_${index}" or => { "need_exclusion_${index}", "need_inclusion_${index}"};
©FILE_SUID:{suid |"enable_suid_&i&" expression => strcmp("&suid&", "true");
}&
©FILE_SGID:{sgid |"enable_sgid_&i&" expression => strcmp("&sgid&", "true");
}&
+
# Set a class to define when we need to run the post-modification hook
©FILE_POST_HOOK_RUN:{run |"execute_command_&i&" expression => strcmp("&run&", "true");
}&
@@ -90,9 +100,24 @@
files:
is_valid.iteration_2::
+ # If it's a directory, without exclusion
+ "$(copyfile[$(index)][destination])"
+ copy_from => scp("&SHARED_FILES_FOLDER&/$(copyfile[$(index)][name])", "$(server_info.cfserved)", "$(copyfile[$(index)][compare_method])", "false", "false", "false"),
+ depth_search => recurse("$(copyfile[$(index)][recursion])"),
+ perms => mog(
+ "$(copyfile[$(index)][perm])",
+ "$(copyfile[$(index)][owner])",
+ "$(copyfile[$(index)][group])"
+ ),
+ comment => "Enforce content of $(copyfile[$(index)][destination]) based on the content on the Rudder server with $(copyfile[$(index)][compare_method]) method",
+ classes => kept_if_else("copy_file_$(index)_kept", "copy_file_$(index)_modified", "copy_file_$(index)_failed"),
+ ifvarclass => "(!exist_$(index)|!is_file_$(index)).!apply_regex_${index}";
+
+ # If it's a directory, with exclusion
"${copyfile[${index}][destination]}"
copy_from => scp("&SHARED_FILES_FOLDER&/${copyfile[${index}][name]}", "${server_info.cfserved}", "${copyfile[${index}][compare_method]}", "false", "false", "false"),
depth_search => recurse("${copyfile[${index}][recursion]}"),
+ file_select => exclude("${copyfile[${index}][exclude_include]}"),
perms => mog(
"${copyfile[${index}][perm]}",
"${copyfile[${index}][owner]}",
@@ -100,7 +125,21 @@
),
comment => "Enforce content of ${copyfile[${index}][destination]} based on the content on the Rudder server with ${copyfile[${index}][compare_method]} method",
classes => kept_if_else("copy_file_${index}_kept", "copy_file_${index}_modified", "copy_file_${index}_failed"),
- ifvarclass => "!exist_${index}|!is_file_${index}";
+ ifvarclass => "(!exist_${index}|!is_file_${index}).need_exclusion_${index}";
+
+ # If it's a directory, with inclusion
+ "${copyfile[${index}][destination]}"
+ copy_from => scp("&SHARED_FILES_FOLDER&/${copyfile[${index}][name]}", "${server_info.cfserved}", "${copyfile[${index}][compare_method]}", "false", "false", "false"),
+ depth_search => recurse("${copyfile[${index}][recursion]}"),
+ file_select => by_name("${copyfile[${index}][exclude_include]}"),
+ perms => mog(
+ "${copyfile[${index}][perm]}",
+ "${copyfile[${index}][owner]}",
+ "${copyfile[${index}][group]}"
+ ),
+ comment => "Enforce content of ${copyfile[${index}][destination]} based on the content on the Rudder server with ${copyfile[${index}][compare_method]} method with inclusion of '${copyfile[${index}][exclude_include]}'",
+ classes => kept_if_else("copy_file_${index}_kept", "copy_file_${index}_modified", "copy_file_${index}_failed"),
+ ifvarclass => "(!exist_${index}|!is_file_${index}).need_inclusion_${index}";
# If it s a file, the depth_search prevents from enforcing the file content
# Besides it is possible to specify suid or sgid only for a file since this
@@ -113,7 +152,7 @@
"${copyfile[${index}][owner]}",
"${copyfile[${index}][group]}"
),
- comment => "Enforce content of file ${copyfile[${index}][destination]} based on the content on the Rudder server with ${copyfile[${index}][compare_method]} method",
+ comment => "Enforce content of file ${copyfile[${index}][destination]} based on the content on the Rudder server with ${copyfile[${index}][compare_method]} method with exclusion of '${copyfile[${index}][exclude_include]}'",
classes => kept_if_else("copy_file_${index}_kept", "copy_file_${index}_modified", "copy_file_${index}_failed"),
ifvarclass => "exist_${index}.is_file_${index}";
diff -Naurw 1.4/metadata.xml 1.5/metadata.xml
--- 1.4/metadata.xml 2013-09-06 15:45:08.890069171 +0200
+++ 1.5/metadata.xml 2013-09-06 17:12:22.673821939 +0200
@@ -49,6 +49,36 @@
<DESCRIPTION>Path of the file to be copied</DESCRIPTION>
<LONGDESCRIPTION>This is the relative path of the file/folder to be copied, on the Rudder policy server</LONGDESCRIPTION>
</INPUT>
+ <SECTION name="Exclusion/Inclusion" multivalued="false" component="false" displayPriority="low">
+ <SELECT1>
+ <NAME>COPYFILE_EXCLUDE_INCLUDE_OPTION</NAME>
+ <DESCRIPTION>Exclude or include files from the copy</DESCRIPTION>
+ <LONGDESCRIPTION>Limit list of files to copy (include) or don't copy some files matching a pattern (exclude). Only applies if the path to copy from is a directory.</LONGDESCRIPTION>
+ <ITEM>
+ <VALUE>none</VALUE>
+ <LABEL>No include/exclude rules</LABEL>
+ </ITEM>
+ <ITEM>
+ <VALUE>exclude</VALUE>
+ <LABEL>Exclude file(s) matching</LABEL>
+ </ITEM>
+ <ITEM>
+ <VALUE>include</VALUE>
+ <LABEL>Include file(s) matching</LABEL>
+ </ITEM>
+ <CONSTRAINT>
+ <DEFAULT>none</DEFAULT>
+ </CONSTRAINT>
+ </SELECT1>
+ <INPUT>
+ <NAME>COPYFILE_EXCLUDE_INCLUDE</NAME>
+ <DESCRIPTION>File name patterns to exclude or include</DESCRIPTION>
+ <LONGDESCRIPTION>If one or several files should be excluded or included in this copy, please insert their name or a regular expression matching the appropriate file name(s))</LONGDESCRIPTION>
+ <CONSTRAINT>
+ <MAYBEEMPTY>true</MAYBEEMPTY>
+ </CONSTRAINT>
+ </INPUT>
+ </SECTION>
<INPUT>
<NAME>COPYFILE_DESTINATION</NAME>
<DESCRIPTION>Destination of the file</DESCRIPTION>
129,29 Bas
|
jooooooon
added a commit
that referenced
this pull request
Sep 22, 2013
…le_or_regexp_from_folder_copy_BIS Fixes #3389 - Add possibility to exclude a file or files matching a regexp from a folder copy
amousset
pushed a commit
to amousset/rudder-techniques
that referenced
this pull request
Dec 8, 2015
…rrect_migration_after_2_6_upgrade Fixes #4062: Prevent an upgrade failure in case of a property modificati...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3389 - Add possibility to exclude a file or files matching a regexp from a folder copy