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 #26089: Implement augeas module #6104

1,093 changes: 751 additions & 342 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ members = ["policies/rudderc",
"policies/rudder-commons-test",
"policies/rudder-report",
"policies/module-types/*",
"policies/minifusion",
"relay/sources/relayd",
"relay/sources/rudder-package"]
resolver = "2"
Expand Down
2 changes: 1 addition & 1 deletion policies/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN <<EOF
set -e
wget https://github.com/PowerShell/PowerShell/releases/download/v7.4.0/powershell_7.4.0-1.deb_amd64.deb
apt-get install ./powershell_7.4.0-1.deb_amd64.deb
apt-get update && apt-get install -y rsync msitools libapt-pkg-dev
apt-get update && apt-get install -y rsync msitools libapt-pkg-dev libaugeas-dev clang
# ignore postinst failures
curl https://repository.rudder.io/tools/rudder-setup | sed 's/rudder agent \(.*\)/rudder agent \1 \| true/g' | bash -s setup-agent $RUDDER_VER
pwsh -Command Install-Module -Name PSScriptAnalyzer -RequiredVersion $PSANALYZER_VERSION -Scope AllUsers -Confirm:\$false -Force
Expand Down
1 change: 1 addition & 0 deletions policies/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ build:
check:
cd rudderc && make check
cd module-types/system-updates && make check
cd module-types/augeas && make check

install:
cd rudderc && make install
35 changes: 34 additions & 1 deletion policies/lib/tree/20_cfe_basics/files.cf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#
#####################################################################################


bundle edit_line ncf_insert_block(block)
{
insert_lines:
Expand Down Expand Up @@ -742,3 +741,37 @@ body file_select date_pattern(age, pattern)
leaf_name => { "${pattern}" };
file_result => "leaf_name.mtime";
}

########################################################################
# Custom promise type #
########################################################################

promise agent augeas
{
path => "/opt/rudder/bin/rudder-module-augeas";
}

bundle agent ncf_augeas(script, if_script, context, path, show_diff, lens)
{
classes:
"pass3" expression => "pass2";
"pass2" expression => "pass1";
"pass1" expression => "any";

pass2.!pass3::
augeas:
"${report_data.method_id}"
rudder_module_protocol => "0",
state_dir => "/var/rudder/system-update/",
node_id => "${g.uuid}",
agent_frequency_minutes => "${g.agent_run_interval}",
classes => classes_generic("${report_data.method_id}"),
data => parsejson('{
"script": "${script}",
"if_script": "${if_script}",
"context": "${context}",
"path": "${path}",
"show_diff": ${show_diff},
"lens": "${lens}"
}');
}
94 changes: 0 additions & 94 deletions policies/minifusion/src/properties.rs

This file was deleted.

16 changes: 15 additions & 1 deletion policies/module-types/augeas/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,25 @@ license.workspace = true

[dependencies]
anyhow = "1"
bytesize = { version = "1.3.0" }
gumdrop = "0.8.1"
ipnet = "2.0.0"
iprange = { version = "0.6" }
nom = "7"
miette = { version = "7.4.0", features = ["fancy"] }
thiserror = "2"
chumsky = { version = "1.0.0-alpha.7", features = ["pratt", "label"] }
ariadne = "0.2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde-inline-default = "0.2"
serde_with = "3"
similar = "2.6.0"
regex = "1.11.1"
rudder_module_type = { path = "../../rudder-module-type" }
raugeas = "0.2.2"
raugeas = "0.3.0"
rustyline = "15"
zxcvbn = "3"

[dev-dependencies]
rudder_commons_test = { path = "../../rudder-commons-test" }
Expand Down
1 change: 0 additions & 1 deletion policies/module-types/augeas/Makefile

This file was deleted.

5 changes: 5 additions & 0 deletions policies/module-types/augeas/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include ../../../rust.makefile

check: lint
cargo test

7 changes: 7 additions & 0 deletions policies/module-types/augeas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Augeas module type.
This module provides a type to manage configuration files using Augeas.
It uses the C API through Rust bindings.

Provide an improved experience of Augeas.

## Usage

There are different ways to use this module:
Expand All @@ -18,3 +20,8 @@ There are different ways to use this module:
* By passing `commands`. This is the most flexible way to use the module, but it also bypasses all safeguards
and makes reporting less precise. It exposes the full power of Augeas (but also the full danger).
Use with caution.

## License

from https://github.com/puppetlabs/puppetlabs-augeas_core.git
under Apache-2.0
Loading