Skip to content
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 #11844: Port some more techniques to multi-versionned format #1226

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion techniques/fileDistribution/copyGitFile/2.2/metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<TECHNIQUE name="File download (Rudder server)">
<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>
<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>
<COMPATIBLE>
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}][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";
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}][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";
ifvarclass => "copy_file_${index}_RudderUniqueID_repaired.!copy_file_${index}_RudderUniqueID_error";

# Error conditions

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}][destination]}", "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}][destination]}", "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}][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";
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}][destination]}", "No post-hook command for copy of ${copyfile[${index}][name]} to ${copyfile[${index}][destination]} was defined, not executing"),
"any" usebundle => rudder_common_report("copyFile", "result_na", "${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}][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_na", "${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}_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}][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";
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}][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";
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}][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";
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",
ifvarclass => "execute_command_${index}.copy_file_${index}_RudderUniqueID_repaired.!copy_file_${index}_RudderUniqueID_error",
comment => "Execute the posthook command if a file was changed";

}
24 changes: 21 additions & 3 deletions techniques/fileDistribution/copyGitFile/2.3/metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,34 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<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>
<POLICYGENERATION>separated</POLICYGENERATION>
<COMPATIBLE>
<OS version=">= 4 (Etch)">Debian</OS>
<OS version=">= 4 (Nahant)">RHEL / CentOS</OS>
<OS version=">= 10 SP1 (Agama Lizard)">SuSE LES / DES / OpenSuSE</OS>
<AGENT version=">= 3.2.0">cfengine-community</AGENT>
</COMPATIBLE>

<BUNDLES>
<NAME>download_from_shared_folder</NAME>
</BUNDLES>
<AGENT type="dsc">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a bug that should be fixed in previous version of the technique?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll do it in a separe issue, if it's ok with you

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

<BUNDLES>
<NAME>copyFileFromSharedFolder_RudderUniqueID</NAME>
</BUNDLES>
<TMLS>
<TML name="copyFileFromSharedFolder.ps1">
<OUTPATH>copyGitFile/2.1/copyFileFromSharedFolder.ps1</OUTPATH>
</TML>

</TMLS>
</AGENT>

<AGENT type="cfengine-community">
<BUNDLES>
<NAME>download_from_shared_folder_RudderUniqueID</NAME>
</BUNDLES>
<TMLS>
<TML name="copyFileFromSharedFolder"/>
</TMLS>
</AGENT>

<TMLS>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

damn, there shouldn't be this 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