Skip to content

Commit

Permalink
Fixes #11844: Port some more techniques to multi-versionned format
Browse files Browse the repository at this point in the history
  • Loading branch information
ncharles committed Dec 11, 2017
1 parent 82d6013 commit 9f20772
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 23 deletions.
4 changes: 3 additions & 1 deletion techniques/applications/packageManagement/1.2/metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
It will ensure that the defined packages are in the desired state (installed or removed) using the appropriate package manager.</DESCRIPTION>

<MULTIINSTANCE>true</MULTIINSTANCE>
<POLICYGENERATION>separated</POLICYGENERATION>

<COMPATIBLE>
<OS version=">= 4">RHEL / CentOS</OS>
<OS version=">= 10 SP1">SuSE LES / DES / OpenSuSE</OS>
Expand All @@ -29,7 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</COMPATIBLE>

<BUNDLES>
<NAME>package_management</NAME>
<NAME>package_management_RudderUniqueID</NAME>
</BUNDLES>

<TMLS>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# Warning: The content of this technique is very close to the content of the package_state() bundle in ncf
# particularly the log message building. All changes made here should also be done in ncf too.

bundle agent package_management {
bundle agent package_management_RudderUniqueID {

vars:
&PACKAGE_LIST:{name |"package[&i0&]" string => "&name&";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function copyFileFromSharedFolder {
function copyFileFromSharedFolder_RudderUniqueID {
[CmdletBinding()]
param (
[parameter(Mandatory=$true)] [string]$reportId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#####################################################################################


bundle agent download_from_shared_folder
bundle agent download_from_shared_folder_RudderUniqueID
{

vars:
Expand Down Expand Up @@ -138,7 +138,7 @@ bundle agent download_from_shared_folder
"${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 => rudder_common_classes("copy_file_${index}"),
classes => rudder_common_classes("copy_file_${index}_RudderUniqueID"),
ifvarclass => "(!exist_${index}|!is_file_${index}).!apply_regex_${index}";

# If it's a directory, with exclusion
Expand All @@ -152,7 +152,7 @@ bundle agent download_from_shared_folder
"${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 => rudder_common_classes("copy_file_${index}"),
classes => rudder_common_classes("copy_file_${index}_RudderUniqueID"),
ifvarclass => "(!exist_${index}|!is_file_${index}).need_exclusion_${index}";

# If it's a directory, with inclusion
Expand All @@ -166,7 +166,7 @@ bundle agent download_from_shared_folder
"${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 => rudder_common_classes("copy_file_${index}"),
classes => rudder_common_classes("copy_file_${index}_RudderUniqueID"),
ifvarclass => "(!exist_${index}|!is_file_${index}).need_inclusion_${index}";

# If it s a file, the depth_search prevents from enforcing the file content
Expand All @@ -182,7 +182,7 @@ bundle agent download_from_shared_folder
"${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 with exclusion of '${copyfile[${index}][exclude_include]}'",
classes => rudder_common_classes("copy_file_${index}"),
classes => rudder_common_classes("copy_file_${index}_RudderUniqueID"),
ifvarclass => "exist_${index}.is_file_${index}";

methods:
Expand All @@ -194,10 +194,10 @@ bundle agent download_from_shared_folder

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"),
ifvarclass => "copy_file_${index}_kept.!copy_file_${index}_repaired.!copy_file_${index}_error";
ifvarclass => "copy_file_${index}_RudderUniqueID_kept.!copy_file_${index}_RudderUniqueID_repaired.!copy_file_${index}_RudderUniqueID_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"),
ifvarclass => "copy_file_${index}_repaired.!copy_file_${index}_error";
ifvarclass => "copy_file_${index}_RudderUniqueID_repaired.!copy_file_${index}_RudderUniqueID_error";

# Error conditons

Expand All @@ -207,7 +207,7 @@ bundle agent download_from_shared_folder

## 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"),
ifvarclass => "copy_file_${index}_denied";
ifvarclass => "copy_file_${index}_RudderUniqueID_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"),
Expand All @@ -219,30 +219,30 @@ bundle agent download_from_shared_folder

## 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?)"),
ifvarclass => "copy_file_${index}_error.!copy_file_${index}_dest_notdir.!copy_file_${index}_denied.!copy_file_${index}_user_absent.!copy_file_${index}_group_absent";
ifvarclass => "copy_file_${index}_RudderUniqueID_error.!copy_file_${index}_dest_notdir.!copy_file_${index}_RudderUniqueID_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_na", "${copyfile[${index}][uuid]}", "Post-modification hook", "${copyfile[${index}][name]}", "No post-hook command for ${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"),
ifvarclass => "execute_command_${index}.!copy_file_${index}_failed.!copy_file_${index}_repaired.copy_file_${index}_kept";
"any" usebundle => rudder_common_report("copyFile", "result_na", "${copyfile[${index}][uuid]}", "Post-modification hook", "${copyfile[${index}][name]}", "${copyfile[${index}][destination]} was already in the desired state, so no command was executed"),
ifvarclass => "execute_command_${index}.!copy_file_${index}_RudderUniqueID_failed.!copy_file_${index}_RudderUniqueID_repaired.copy_file_${index}_RudderUniqueID_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"),
ifvarclass => "execute_command_${index}.copyfile_posthook_${index}_command_run_ok";
ifvarclass => "execute_command_${index}.copyfile_posthook_${index}_RudderUniqueID_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"),
ifvarclass => "execute_command_${index}.copyfile_posthook_${index}_command_run_failed";
ifvarclass => "execute_command_${index}.copyfile_posthook_${index}_RudderUniqueID_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"),
ifvarclass => "execute_command_${index}.copy_file_${index}_error";
ifvarclass => "execute_command_${index}.copy_file_${index}_RudderUniqueID_error";

commands:
"${copyfile[${index}][posthook]}"
contain => in_shell,
classes => if_else("copyfile_posthook_${index}_command_run_ok", "copyfile_posthook_${index}_command_run_failed"),
ifvarclass => "execute_command_${index}.copy_file_${index}_repaired.!copy_file_${index}_error",
classes => if_else("copyfile_posthook_${index}_RudderUniqueID_command_run_ok", "copyfile_posthook_${index}_RudderUniqueID_command_run_failed"),
ifvarclass => "execute_command_${index}.copy_file_${index}_RudderUniqueID_repaired.!copy_file_${index}_RudderUniqueID_error",
comment => "Execute the posthook command if a file was changed";

}
4 changes: 3 additions & 1 deletion techniques/fileDistribution/copyGitFile/2.2/metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
It ensures that some files are the copy of files on the shared folder of the Rudder Root Server, and optionally allows running a command in case a change was made.</DESCRIPTION>

<MULTIINSTANCE>true</MULTIINSTANCE>
<POLICYGENERATION>separated</POLICYGENERATION>

<COMPATIBLE>
<OS version=">= 4 (Etch)">Debian</OS>
<OS version=">= 4 (Nahant)">RHEL / CentOS</OS>
Expand All @@ -42,7 +44,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

<AGENT type="cfengine-community">
<BUNDLES>
<NAME>download_from_shared_folder</NAME>
<NAME>download_from_shared_folder_RudderUniqueID</NAME>
</BUNDLES>
<TMLS>
<TML name="copyFileFromSharedFolder"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
#####################################################################################

bundle agent manage_key_value_file {
bundle agent manage_key_value_file_RudderUniqueID {
vars:
&MANAGE_KEY_VALUE_FILEPATH:{file | "file[&i&]" string => "&file&";
}&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<TECHNIQUE name="Manage keys-values in file">
<DESCRIPTION>Manage keys-values in file</DESCRIPTION>
<MULTIINSTANCE>true</MULTIINSTANCE>
<POLICYGENERATION>separated</POLICYGENERATION>
<COMPATIBLE>
<OS>Every OS</OS>
<AGENT version=">= 3.5">cfengine-community</AGENT>
</COMPATIBLE>

<BUNDLES>
<NAME>manage_key_value_file</NAME>
<NAME>manage_key_value_file_RudderUniqueID</NAME>
</BUNDLES>

<TMLS>
Expand Down

0 comments on commit 9f20772

Please sign in to comment.