diff --git a/ncf b/ncf index 11be88ad6..ed5c658a5 100755 --- a/ncf +++ b/ncf @@ -6,6 +6,7 @@ import os import sys import shutil import json +import grp from pprint import pprint DEFAULT_NCF_DIR = '/usr/share/ncf' @@ -13,6 +14,7 @@ DEFAULT_NCF_DIR = '/usr/share/ncf' NCF_DIR = os.path.dirname(os.path.realpath(__file__)) NCF_TREE_DIR = os.path.join(NCF_DIR, 'tree') NCF_TOOLS_DIR = os.path.join(NCF_DIR, 'tools') +GROUP_OWNER = 'rudder' sys.path[0:0] = [NCF_TOOLS_DIR, DEFAULT_NCF_DIR] @@ -63,10 +65,13 @@ def write_all_methods(path): methods = ncf.get_all_generic_methods_metadata() methodsFile = '/var/rudder/configuration-repository/ncf/generic_methods.json' + gid = grp.getgrnam(GROUP_OWNER)[2] if not os.path.exists(os.path.dirname(methodsFile)): os.makedirs(os.path.dirname(methodsFile)) + os.chown(os.path.dirname(methodsFile), -1, gid) with open(methodsFile, 'w') as outfile: json.dump(methods["data"]["generic_methods"], outfile, indent=2) + os.chown(methodsFile, -1, gid) def write_all_techniques(path, migrate_old): techniques = ncf.get_all_techniques_metadata(True,migrate_old) @@ -77,8 +82,8 @@ def write_all_techniques(path, migrate_old): techniqueFile = '/var/rudder/configuration-repository/techniques/'+category+"/"+ bundle_name +"/"+version+'/technique.json' if not os.path.exists(techniqueFile): with open('/var/rudder/configuration-repository/techniques/'+category+"/"+ bundle_name +"/"+version+'/technique.json', 'w') as outfile: - json.dump(technique, outfile, indent=2) - + json.dump(technique, outfile, indent=2) + os.chown(techniqueFile, -1, grp.getgrnam(GROUP_OWNER)[2]) def usage(): diff --git a/tests/acceptance/30_generic_methods/command_execution.cf b/tests/acceptance/30_generic_methods/command_execution.cf index 7e744b961..6700c5dab 100644 --- a/tests/acceptance/30_generic_methods/command_execution.cf +++ b/tests/acceptance/30_generic_methods/command_execution.cf @@ -24,7 +24,7 @@ bundle agent init vars: "tmp" string => getenv("TEMP", 1024); - "command[1]" string => "/bin/date | egrep '[0-9]'"; + "command[1]" string => "/bin/date | ${paths.path[egrep]} '[0-9]'"; "result[1]" string => "repaired"; "command[2]" string => "/bin/false"; diff --git a/tests/acceptance/30_generic_methods/staging/file_augeas_set.cf b/tests/acceptance/30_generic_methods/file_augeas_set.cf similarity index 51% rename from tests/acceptance/30_generic_methods/staging/file_augeas_set.cf rename to tests/acceptance/30_generic_methods/file_augeas_set.cf index ea4e0c680..0b792849a 100644 --- a/tests/acceptance/30_generic_methods/staging/file_augeas_set.cf +++ b/tests/acceptance/30_generic_methods/file_augeas_set.cf @@ -1,13 +1,3 @@ - ####################################################### -# -# Read a file into a string -# Currently in staging since the method does not behave -# as intended. The fix need to deprecate this one and -# develop a new one. Until then, the test will be set -# to staging. -# -####################################################### - bundle common acc_path { vars: @@ -28,40 +18,32 @@ bundle agent init vars: "tmp" string => getenv("TEMP", 1024); - "file[0]" string => "${tmp}/etc/hosts0"; - "value[0]" string => "127.0.0.1"; - "lens[0]" string => "Hosts"; - "path[0]" string => "/etc/hosts/1/ipaddr"; + "file[0]" string => "${tmp}/etc/sshd_config0"; + "value[0]" string => "yes"; + "lens[0]" string => "Sshd"; + "path[0]" string => "${tmp}/etc/sshd_config0/PermitRootLogin"; "status[0]" string => "success"; "mode[0]" string => "enforce"; - "file[1]" string => "${tmp}/etc/hosts1"; - "value[1]" string => "127.0.0.1"; - "lens[1]" string => ""; - "path[1]" string => "/etc/hosts/1/ipaddr"; - "status[1]" string => "error"; + "file[1]" string => "${tmp}/etc/sshd_config1"; + "value[1]" string => "no"; + "lens[1]" string => "Sshd"; + "path[1]" string => "${tmp}/etc/sshd_config1/PermitRootLogin"; + "status[1]" string => "repaired"; "mode[1]" string => "enforce"; - #file is null but the lens should be enough for augeas - "file[2]" string => ""; - "value[2]" string => "127.0.0.1"; - "lens[2]" string => "Hosts"; - "path[2]" string => "/etc/hosts/1/ipaddr"; + "file[2]" string => "${tmp}/etc/sshd_config1"; + "value[2]" string => "yes"; + "lens[2]" string => "Sshd"; + "path[2]" string => "${tmp}/etc/sshd_config1/StrictModes"; "status[2]" string => "success"; "mode[2]" string => "enforce"; - "file[3]" string => "${tmp}/etc/hosts3"; - "value[3]" string => "0.1.2.3"; - "lens[3]" string => "Hosts"; - "path[3]" string => "/etc/hosts/1/ipaddr"; - "status[3]" string => "repaired"; - "mode[3]" string => "enforce"; - "indices" slist => getindices("file"); files: - "${tmp}/etc/hosts${indices}" - copy_from => local_cp("/etc/hosts"); + "${tmp}/etc/sshd_config${indices}" + copy_from => local_cp("${this.promise_dirname}/file_augeas_set.sshd_config_yes"); } ####################################################### @@ -75,7 +57,6 @@ bundle agent test "ph0" usebundle => apply_gm("file_augeas_set", @{args0}, "${init.status[0]}", "ph0", "${init.mode[0]}"); "ph1" usebundle => apply_gm("file_augeas_set", @{args1}, "${init.status[1]}", "ph1", "${init.mode[1]}"); "ph2" usebundle => apply_gm("file_augeas_set", @{args2}, "${init.status[2]}", "ph2", "${init.mode[2]}"); - "ph3" usebundle => apply_gm("file_augeas_set", @{args3}, "${init.status[3]}", "ph3", "${init.mode[3]}"); } ####################################################### @@ -83,10 +64,13 @@ bundle agent test bundle agent check { classes: + "classes_ok" expression => "ph0_ok.ph1_ok.ph2_ok"; + classes_ok:: + "content_0" expression => returnszero("diff ${init.file[0]} ${this.promise_dirname}/file_augeas_set.sshd_config_yes 2>/dev/null", "useshell"); + "content_1" expression => returnszero("diff ${init.file[1]} ${this.promise_dirname}/file_augeas_set.sshd_config_no 2>/dev/null", "useshell"); + "content_ok" expression => "content_0.content_1"; - "classes_ok" expression => "ph0_ok.ph1_ok.ph2_ok.ph3_ok"; - - "ok" expression => "classes_ok"; + "ok" expression => "classes_ok.content_ok"; reports: ok:: diff --git a/tests/acceptance/30_generic_methods/file_augeas_set.sshd_config_no b/tests/acceptance/30_generic_methods/file_augeas_set.sshd_config_no new file mode 100644 index 000000000..eb59570e5 --- /dev/null +++ b/tests/acceptance/30_generic_methods/file_augeas_set.sshd_config_no @@ -0,0 +1,7 @@ +# Authentication: + +#LoginGraceTime 2m +PermitRootLogin no +StrictModes yes +#MaxAuthTries 6 +#MaxSessions 10 diff --git a/tests/acceptance/30_generic_methods/file_augeas_set.sshd_config_yes b/tests/acceptance/30_generic_methods/file_augeas_set.sshd_config_yes new file mode 100644 index 000000000..d389889de --- /dev/null +++ b/tests/acceptance/30_generic_methods/file_augeas_set.sshd_config_yes @@ -0,0 +1,7 @@ +# Authentication: + +#LoginGraceTime 2m +PermitRootLogin yes +StrictModes yes +#MaxAuthTries 6 +#MaxSessions 10 diff --git a/tests/acceptance/30_generic_methods/file_check_block_device.cf b/tests/acceptance/30_generic_methods/file_check_block_device.cf index bf67b7c2d..f887251f4 100644 --- a/tests/acceptance/30_generic_methods/file_check_block_device.cf +++ b/tests/acceptance/30_generic_methods/file_check_block_device.cf @@ -1,7 +1,7 @@ ######################################### # -# Test checking if a block device or not -# +# Test checking if a block device or not +# ######################################### bundle common acc_path @@ -30,14 +30,26 @@ bundle agent init "block_device_canon" string => canonify("${block_device}"); "file_list" slist => { "${file}", "${block_device}" }; + solaris:: + "mknod" string => "/usr/sbin/mknod"; + debian:: + "mknod" string => "/bin/mknod"; + !solaris.!debian:: + "mknod" string => "/usr/bin/mknod"; files: "${file}" create => "true"; commands: - "/bin/mknod" - args => "-m 640 \"${block_device}\" b 7 0"; # /dev/loop0 + "${mknod}" + args => "\"${block_device}\" b 7 0", # /dev/loop0 + if => "solaris"; + + "${mknod}" + args => "-m 640 \"${block_device}\" b 7 0", # /dev/loop0 + if => "!solaris"; + } ####################################################### diff --git a/tests/acceptance/30_generic_methods/file_content.cf b/tests/acceptance/30_generic_methods/file_content.cf index 8879468c4..74408379c 100644 --- a/tests/acceptance/30_generic_methods/file_content.cf +++ b/tests/acceptance/30_generic_methods/file_content.cf @@ -23,6 +23,7 @@ bundle agent init { vars: "tmp" string => getenv("TEMP", 1024); + "file_1" string => "${tmp}/test_1"; "file_1_canon" string => canonify("${file_1}"); "file_2" string => "${tmp}/test_2"; @@ -73,10 +74,10 @@ bundle agent test bundle agent check { vars: - "line_1_present_exists_test" string => "/bin/grep -E \"^${init.line_present}$\" \"${init.file_1}\""; - "line_1_added_exists_test" string => "/bin/grep -E \"^${init.line_to_add}$\" \"${init.file_1}\""; - "line_2_present_exists_test" string => "/bin/grep -E \"^${init.line_present}$\" \"${init.file_2}\""; - "line_2_added_exists_test" string => "/bin/grep -E \"^${init.line_to_add}$\" \"${init.file_2}\""; + "line_1_present_exists_test" string => "${paths.path[grep]} -E \"^${init.line_present}$\" \"${init.file_1}\""; + "line_1_added_exists_test" string => "${paths.path[grep]} -E \"^${init.line_to_add}$\" \"${init.file_1}\""; + "line_2_present_exists_test" string => "${paths.path[grep]} -E \"^${init.line_present}$\" \"${init.file_2}\""; + "line_2_added_exists_test" string => "${paths.path[grep]} -E \"^${init.line_to_add}$\" \"${init.file_2}\""; "file_3_test" string => "/usr/bin/diff \"${init.ref_3}\" \"${init.file_3}\""; classes: diff --git a/tests/acceptance/30_generic_methods/file_from_local_source_with_check.cf b/tests/acceptance/30_generic_methods/file_from_local_source_with_check.cf index efba7e1e7..21c8daece 100644 --- a/tests/acceptance/30_generic_methods/file_from_local_source_with_check.cf +++ b/tests/acceptance/30_generic_methods/file_from_local_source_with_check.cf @@ -37,6 +37,7 @@ bundle agent init "${source_file}" edit_line => insert_lines("test file"), create => "true"; + "${destination_file_3}" edit_line => insert_lines("test file"), create => "true"; @@ -50,7 +51,7 @@ bundle agent test "ph1" usebundle => file_from_local_source_with_check("${init.source_file}", "${init.destination_file_1}", "/bin/true", "0"); "ph2" usebundle => file_from_local_source_with_check("${init.source_file}", "${init.destination_file_2}", "/bin/false", "0"); "ph3" usebundle => file_from_local_source_with_check("${init.source_file}", "${init.destination_file_3}", "/bin/false", "0"); - "ph4" usebundle => file_from_local_source_with_check("${init.source_file}", "${init.destination_file_4}", "/bin/false", "1"); + "ph4" usebundle => file_from_local_source_with_check("${init.source_file}", "${init.destination_file_4}", "exit 1", "1"); } ####################################################### @@ -78,7 +79,7 @@ bundle agent check "ok_3" expression => "file_3.content_3.file_from_local_source_with_check_${init.destination_file_canon_3}_kept"; "ok_4" expression => "file_4.content_4.file_from_local_source_with_check_${init.destination_file_canon_4}_repaired.!file_from_local_source_with_check_${init.destination_file_canon_4}_error"; "ok" expression => "ok_1.ok_2.ok_3.ok_4"; - + reports: ok:: "$(this.promise_filename) Pass"; diff --git a/tests/acceptance/30_generic_methods/file_from_string_mustache.cf b/tests/acceptance/30_generic_methods/file_from_string_mustache.cf index 6b0c2592b..c737d710d 100644 --- a/tests/acceptance/30_generic_methods/file_from_string_mustache.cf +++ b/tests/acceptance/30_generic_methods/file_from_string_mustache.cf @@ -44,8 +44,8 @@ bundle agent test bundle agent check { vars: - "file_length_check_1" string => "/usr/bin/test `/bin/cat ${init.destination_file_1} | wc -l` = '1'"; - "file_content_check_1" string => "/bin/cat ${init.destination_file_1} | head -n1 | grep '^sys.host is: ${sys.host}$'"; + "file_length_check_1" string => "${paths.path[test]} `${paths.path[cat]} ${init.destination_file_1} | wc -l` = '1'"; + "file_content_check_1" string => "${paths.path[cat]} ${init.destination_file_1} | ${ncf_paths.path[head]} -n1 | ${paths.path[grep]} '^sys.host is: ${sys.host}$'"; classes: # By default, should create the file if it doesn't exist diff --git a/tests/acceptance/30_generic_methods/file_from_template.cf b/tests/acceptance/30_generic_methods/file_from_template.cf index 4102fbcbf..bf85aa632 100644 --- a/tests/acceptance/30_generic_methods/file_from_template.cf +++ b/tests/acceptance/30_generic_methods/file_from_template.cf @@ -47,8 +47,8 @@ bundle agent test bundle agent check { vars: - "file_length_check" string => "/usr/bin/test `/bin/cat ${init.destination_file} | wc -l` = '1'"; - "file_content_check" string => "/bin/cat ${init.destination_file} | head -n1 | grep '^sys.host is: ${sys.host}$'"; + "file_length_check" string => "${paths.path[test]} `${paths.path[cat]} ${init.destination_file} | wc -l` = '1'"; + "file_content_check" string => "${paths.path[cat]} ${init.destination_file} | ${ncf_paths.path[head]} -n1 | ${paths.path[grep]} '^sys.host is: ${sys.host}$'"; classes: # By default, should create the file if it doesn't exist diff --git a/tests/acceptance/30_generic_methods/file_from_template_mustache.cf b/tests/acceptance/30_generic_methods/file_from_template_mustache.cf index e0b278ff4..04b423b6a 100644 --- a/tests/acceptance/30_generic_methods/file_from_template_mustache.cf +++ b/tests/acceptance/30_generic_methods/file_from_template_mustache.cf @@ -47,8 +47,8 @@ bundle agent test bundle agent check { vars: - "file_length_check" string => "/usr/bin/test `/bin/cat ${init.destination_file} | wc -l` = '1'"; - "file_content_check" string => "/bin/cat ${init.destination_file} | head -n1 | grep '^sys.host is: ${sys.host}$'"; + "file_length_check" string => "${paths.path[test]} `${paths.path[cat]} ${init.destination_file} | wc -l` = '1'"; + "file_content_check" string => "${paths.path[cat]} ${init.destination_file} | ${ncf_paths.path[head]} -n1 | ${paths.path[grep]} '^sys.host is: ${sys.host}$'"; classes: # By default, should create the file if it doesn't exist diff --git a/tests/acceptance/30_generic_methods/file_lines_absent.cf b/tests/acceptance/30_generic_methods/file_lines_absent.cf index 89ac3a658..25a193d09 100644 --- a/tests/acceptance/30_generic_methods/file_lines_absent.cf +++ b/tests/acceptance/30_generic_methods/file_lines_absent.cf @@ -44,7 +44,7 @@ bundle agent test bundle agent check { vars: - "line_exists_test" string => "/bin/grep -E \"^${init.line_to_test}$\" \"${init.file}\""; + "line_exists_test" string => "${paths.path[grep]} -E \"^${init.line_to_test}$\" \"${init.file}\""; classes: "file_exists" expression => fileexists("${init.file}"); diff --git a/tests/acceptance/30_generic_methods/file_lines_present.cf b/tests/acceptance/30_generic_methods/file_lines_present.cf index 8d6702105..7670b6730 100644 --- a/tests/acceptance/30_generic_methods/file_lines_present.cf +++ b/tests/acceptance/30_generic_methods/file_lines_present.cf @@ -41,12 +41,12 @@ bundle agent test bundle agent check { vars: - "line_exists_test" string => "/bin/grep -E \"^${init.line_to_add}$\" \"${init.file}\""; + "line_exists_test" string => "${paths.path[grep]} -E \"^${init.line_to_add}$\" \"${init.file}\""; classes: # By default, file_lines_present should create the file if it doesn't exist "file_exists" expression => fileexists("${init.file}"); - "line_exists" + "line_exists" expression => returnszero("${line_exists_test}", "noshell"), ifvarclass => canonify("file_lines_present_${init.file}_reached"); diff --git a/tests/acceptance/30_generic_methods/file_lines_present_test_already_present.cf b/tests/acceptance/30_generic_methods/file_lines_present_test_already_present.cf index 74a02abd8..5ef4eab77 100644 --- a/tests/acceptance/30_generic_methods/file_lines_present_test_already_present.cf +++ b/tests/acceptance/30_generic_methods/file_lines_present_test_already_present.cf @@ -48,12 +48,12 @@ bundle agent test bundle agent check { vars: - "line_exists_test" string => "/usr/bin/test `/bin/grep \"^${init.line_to_add}$\" \"${init.file}\" | wc -l` = '1'"; + "line_exists_test" string => "${paths.path[test]} `${paths.path[grep]} \"^${init.line_to_add}$\" \"${init.file}\" | wc -l` = '1'"; classes: # By default, file_lines_present should create the file if it doesn't exist "file_exists" expression => fileexists("${init.file}"); - + "line_exists" expression => returnszero("${line_exists_test}", "useshell"), ifvarclass => canonify("file_lines_present_${init.file}_reached"); diff --git a/tests/acceptance/30_generic_methods/file_lines_test_from_empty_file.cf b/tests/acceptance/30_generic_methods/file_lines_test_from_empty_file.cf index ef27e6663..3d65bd339 100644 --- a/tests/acceptance/30_generic_methods/file_lines_test_from_empty_file.cf +++ b/tests/acceptance/30_generic_methods/file_lines_test_from_empty_file.cf @@ -47,7 +47,7 @@ bundle agent test bundle agent check { vars: - "line_exists_test" string => "/bin/grep -E \"^${init.line_to_test}$\" \"${init.file}\""; + "line_exists_test" string => "${paths.path[grep]} -E \"^${init.line_to_test}$\" \"${init.file}\""; classes: "file_exists" expression => fileexists("${init.file}"); diff --git a/tests/acceptance/30_generic_methods/file_replace_lines.cf b/tests/acceptance/30_generic_methods/file_replace_lines.cf index 57e1033cb..929f4be77 100644 --- a/tests/acceptance/30_generic_methods/file_replace_lines.cf +++ b/tests/acceptance/30_generic_methods/file_replace_lines.cf @@ -45,7 +45,7 @@ bundle agent test bundle agent check { vars: - "line_exists_test" string => "/bin/grep -E \"^${init.line_for_replacement}$\" \"${init.file}\""; + "line_exists_test" string => "${paths.path[grep]} -E \"^${init.line_for_replacement}$\" \"${init.file}\""; classes: # By default, file_replace_lines should create the file if it doesn't exist diff --git a/tests/acceptance/30_generic_methods/file_report_content_head_tail.cf b/tests/acceptance/30_generic_methods/file_report_content_head_tail.cf index 4857fd482..9f0088629 100644 --- a/tests/acceptance/30_generic_methods/file_report_content_head_tail.cf +++ b/tests/acceptance/30_generic_methods/file_report_content_head_tail.cf @@ -91,7 +91,7 @@ bundle agent result(id, result) ####################################################### bundle agent check -{ +{ classes: "ok_1" expression => strcmp("${init.file_1_expected}", "${result.file_1}"); "ok_1_class" expression => "file_report_content_head_${init.file_1_canon}_kept.!file_report_content_head_${init.file_1_canon}_error"; @@ -103,7 +103,15 @@ bundle agent check "ok" expression => "ok_1.ok_2.ok_1_class.ok_2_class.ok_3_class.ok_4_class"; reports: - "'${result.file_1}'"; + "'${result.file_1}'"; + !ok_1:: + "Issue in 1"; + !ok_2:: + "Issue in 2"; + !ok_3:: + "Issue in 3"; + !ok_4:: + "Issue in 4"; ok:: "$(this.promise_filename) Pass"; !ok:: diff --git a/tests/acceptance/30_generic_methods/unsafe/service_started_start.cf b/tests/acceptance/30_generic_methods/unsafe/service_started_start.cf index dcf8aa48a..fd1a3b486 100644 --- a/tests/acceptance/30_generic_methods/unsafe/service_started_start.cf +++ b/tests/acceptance/30_generic_methods/unsafe/service_started_start.cf @@ -47,7 +47,7 @@ bundle agent test bundle agent check { vars: - "command_ps" string => "/bin/ps afux | /bin/grep ${init.service_name} | /bin/grep -v grep"; + "command_ps" string => "/bin/ps afux | ${paths.path[grep]} ${init.service_name} | ${paths.path[grep]} -v grep"; classes: "service_running" expression => returnszero("${command_ps}", "useshell"), diff --git a/tests/acceptance/30_generic_methods/unsafe/user_create.cf b/tests/acceptance/30_generic_methods/unsafe/user_create.cf index f9bc579a2..cf45bf39b 100644 --- a/tests/acceptance/30_generic_methods/unsafe/user_create.cf +++ b/tests/acceptance/30_generic_methods/unsafe/user_create.cf @@ -44,7 +44,7 @@ bundle agent check { vars: pass1:: - "user_line" string => execresult("/bin/grep '^${init.user}:' /etc/passwd", "useshell"); + "user_line" string => execresult("${paths.path[grep]} '^${init.user}:' /etc/passwd", "useshell"); classes: pass1:: @@ -53,7 +53,7 @@ bundle agent check "ph1_ok" expression => "!user_create_${init.user}_kept.user_create_${init.user}_repaired.!user_create_${init.user}_error"; "ok" expression => "user1_ok.ph1_ok"; - + any:: "pass1" expression => "any"; diff --git a/tests/acceptance/30_generic_methods/unsafe/user_fullname.cf b/tests/acceptance/30_generic_methods/unsafe/user_fullname.cf index abfb00008..14bf06712 100644 --- a/tests/acceptance/30_generic_methods/unsafe/user_fullname.cf +++ b/tests/acceptance/30_generic_methods/unsafe/user_fullname.cf @@ -44,8 +44,8 @@ bundle agent check { vars: pass1:: - "user_line1" string => execresult("/bin/grep '^${init.user1}:' /etc/passwd", "useshell"); - "user_line2" string => execresult("/bin/grep '^${init.user2}:' /etc/passwd", "useshell"); + "user_line1" string => execresult("${paths.path[grep]} '^${init.user1}:' /etc/passwd", "useshell"); + "user_line2" string => execresult("${paths.path[grep]} '^${init.user2}:' /etc/passwd", "useshell"); classes: diff --git a/tests/acceptance/30_generic_methods/unsafe/user_home.cf b/tests/acceptance/30_generic_methods/unsafe/user_home.cf index c0683a04b..ec09eb823 100644 --- a/tests/acceptance/30_generic_methods/unsafe/user_home.cf +++ b/tests/acceptance/30_generic_methods/unsafe/user_home.cf @@ -44,8 +44,8 @@ bundle agent check { vars: pass1:: - "user_line1" string => execresult("/bin/grep '^${init.user1}:' /etc/passwd", "useshell"); - "user_line2" string => execresult("/bin/grep '^${init.user2}:' /etc/passwd", "useshell"); + "user_line1" string => execresult("${paths.path[grep]} '^${init.user1}:' /etc/passwd", "useshell"); + "user_line2" string => execresult("${paths.path[grep]} '^${init.user2}:' /etc/passwd", "useshell"); classes: diff --git a/tests/acceptance/30_generic_methods/unsafe/user_locked.cf b/tests/acceptance/30_generic_methods/unsafe/user_locked.cf index 283fc5616..553bc8519 100644 --- a/tests/acceptance/30_generic_methods/unsafe/user_locked.cf +++ b/tests/acceptance/30_generic_methods/unsafe/user_locked.cf @@ -46,8 +46,8 @@ bundle agent check { vars: pass1:: - "user_line1" string => execresult("/bin/grep '^${init.user1}:' /etc/shadow", "useshell"); - "user_line2" string => execresult("/bin/grep '^${init.user2}:' /etc/shadow", "useshell"); + "user_line1" string => execresult("${paths.path[grep]} '^${init.user1}:' /etc/shadow", "useshell"); + "user_line2" string => execresult("${paths.path[grep]} '^${init.user2}:' /etc/shadow", "useshell"); classes: pass1:: diff --git a/tests/acceptance/30_generic_methods/unsafe/user_password_hash.cf b/tests/acceptance/30_generic_methods/unsafe/user_password_hash.cf index 7e63567a7..ce55a6cc3 100644 --- a/tests/acceptance/30_generic_methods/unsafe/user_password_hash.cf +++ b/tests/acceptance/30_generic_methods/unsafe/user_password_hash.cf @@ -49,9 +49,9 @@ bundle agent check { vars: pass1:: - "user_line1" string => execresult("/bin/grep '^${init.user1}:' /etc/shadow", "useshell"); - "user_line2" string => execresult("/bin/grep '^${init.user2}:' /etc/shadow", "useshell"); - "user_line3" string => execresult("/bin/grep '^${init.user3}:' /etc/shadow", "useshell"); + "user_line1" string => execresult("${paths.path[grep]} '^${init.user1}:' /etc/shadow", "useshell"); + "user_line2" string => execresult("${paths.path[grep]} '^${init.user2}:' /etc/shadow", "useshell"); + "user_line3" string => execresult("${paths.path[grep]} '^${init.user3}:' /etc/shadow", "useshell"); classes: pass1:: diff --git a/tests/acceptance/30_generic_methods/unsafe/user_present.cf b/tests/acceptance/30_generic_methods/unsafe/user_present.cf index b04f3b831..9f420d665 100644 --- a/tests/acceptance/30_generic_methods/unsafe/user_present.cf +++ b/tests/acceptance/30_generic_methods/unsafe/user_present.cf @@ -42,8 +42,8 @@ bundle agent check { vars: pass1:: - "user_line1" string => execresult("/bin/grep '^${init.user1}:' /etc/passwd", "useshell"); - "user_line2" string => execresult("/bin/grep '^${init.user2}:' /etc/passwd", "useshell"); + "user_line1" string => execresult("${paths.path[grep]} '^${init.user1}:' /etc/passwd", "useshell"); + "user_line2" string => execresult("${paths.path[grep]} '^${init.user2}:' /etc/passwd", "useshell"); classes: pass1:: diff --git a/tests/acceptance/30_generic_methods/unsafe/user_primary_group.cf b/tests/acceptance/30_generic_methods/unsafe/user_primary_group.cf index 75f734456..b91d6d76e 100644 --- a/tests/acceptance/30_generic_methods/unsafe/user_primary_group.cf +++ b/tests/acceptance/30_generic_methods/unsafe/user_primary_group.cf @@ -64,10 +64,10 @@ bundle agent init "indices" slist => getindices("user"); pass2:: - "line3" string => execresult("${paths.grep} '^${user[3]}:' /etc/passwd", "useshell"); - "line5" string => execresult("${paths.grep} '^${user[5]}:' /etc/passwd", "useshell"); - "line6" string => execresult("${paths.grep} '^${user[6]}:' /etc/passwd", "useshell"); - "line7" string => execresult("${paths.grep} '^${user[7]}:' /etc/passwd", "useshell"); + "line3" string => execresult("${paths.path[grep]} '^${user[3]}:' /etc/passwd", "useshell"); + "line5" string => execresult("${paths.path[grep]} '^${user[5]}:' /etc/passwd", "useshell"); + "line6" string => execresult("${paths.path[grep]} '^${user[6]}:' /etc/passwd", "useshell"); + "line7" string => execresult("${paths.path[grep]} '^${user[7]}:' /etc/passwd", "useshell"); classes: "pass2" expression => "pass1"; @@ -118,13 +118,13 @@ bundle agent check "gid2" int => getgid("${init.primary_group[2]}"); "uid${init.indices}" int => getuid("${init.user[${init.indices}]}"); - "user_line1" string => execresult("${paths.grep} '^${init.user[1]}:' /etc/passwd", "useshell"); - "user_line2" string => execresult("${paths.grep} '^${init.user[2]}:' /etc/passwd", "useshell"); - "user_line3" string => execresult("${paths.grep} '^${init.user[3]}:' /etc/passwd", "useshell"); - "user_line4" string => execresult("${paths.grep} '^${init.user[4]}:' /etc/passwd", "useshell"); - "user_line5" string => execresult("${paths.grep} '^${init.user[5]}:' /etc/passwd", "useshell"); - "user_line6" string => execresult("${paths.grep} '^${init.user[6]}:' /etc/passwd", "useshell"); - "user_line7" string => execresult("${paths.grep} '^${init.user[7]}:' /etc/passwd", "useshell"); + "user_line1" string => execresult("${paths.path[grep]} '^${init.user[1]}:' /etc/passwd", "useshell"); + "user_line2" string => execresult("${paths.path[grep]} '^${init.user[2]}:' /etc/passwd", "useshell"); + "user_line3" string => execresult("${paths.path[grep]} '^${init.user[3]}:' /etc/passwd", "useshell"); + "user_line4" string => execresult("${paths.path[grep]} '^${init.user[4]}:' /etc/passwd", "useshell"); + "user_line5" string => execresult("${paths.path[grep]} '^${init.user[5]}:' /etc/passwd", "useshell"); + "user_line6" string => execresult("${paths.path[grep]} '^${init.user[6]}:' /etc/passwd", "useshell"); + "user_line7" string => execresult("${paths.path[grep]} '^${init.user[7]}:' /etc/passwd", "useshell"); classes: pass1:: @@ -139,7 +139,7 @@ bundle agent check "users_ok" expression => "user1_ok.user2_ok.user3_ok.user4_ok.user5_ok.user6_ok.user7_ok"; "classes_ok" expression => "ph1_ok.ph2_ok.ph3_ok.ph4_ok.ph5_ok.ph6_ok.ph7_ok"; "ok" expression => "users_ok.classes_ok"; - + any:: "pass2" expression => "pass1"; "pass1" expression => "any"; diff --git a/tests/acceptance/30_generic_methods/unsafe/user_shell.cf b/tests/acceptance/30_generic_methods/unsafe/user_shell.cf index 8b10014f0..5662b41e7 100644 --- a/tests/acceptance/30_generic_methods/unsafe/user_shell.cf +++ b/tests/acceptance/30_generic_methods/unsafe/user_shell.cf @@ -44,8 +44,8 @@ bundle agent check { vars: pass1:: - "user_line1" string => execresult("/bin/grep '^${init.user1}:' /etc/passwd", "useshell"); - "user_line2" string => execresult("/bin/grep '^${init.user2}:' /etc/passwd", "useshell"); + "user_line1" string => execresult("${paths.path[grep]} '^${init.user1}:' /etc/passwd", "useshell"); + "user_line2" string => execresult("${paths.path[grep]} '^${init.user2}:' /etc/passwd", "useshell"); classes: pass1:: diff --git a/tests/acceptance/30_generic_methods/unsafe/user_uid.cf b/tests/acceptance/30_generic_methods/unsafe/user_uid.cf index a7940ebe4..35097b204 100644 --- a/tests/acceptance/30_generic_methods/unsafe/user_uid.cf +++ b/tests/acceptance/30_generic_methods/unsafe/user_uid.cf @@ -60,9 +60,9 @@ bundle agent check { vars: pass1:: - "user_line1" string => execresult("/bin/grep '^${init.user1}:' /etc/passwd", "useshell"); - "user_line2" string => execresult("/bin/grep '^${init.user2}:' /etc/passwd", "useshell"); - "user_line3" string => execresult("/bin/grep '^${init.user3}:' /etc/passwd", "useshell"); + "user_line1" string => execresult("${paths.path[grep]} '^${init.user1}:' /etc/passwd", "useshell"); + "user_line2" string => execresult("${paths.path[grep]} '^${init.user2}:' /etc/passwd", "useshell"); + "user_line3" string => execresult("${paths.path[grep]} '^${init.user3}:' /etc/passwd", "useshell"); classes: any:: diff --git a/tests/quick/test_generic_methods.py b/tests/quick/test_generic_methods.py index a066bd4ec..d88d4a0c3 100755 --- a/tests/quick/test_generic_methods.py +++ b/tests/quick/test_generic_methods.py @@ -15,7 +15,6 @@ import avocado class TestNcfBundles(avocado.Test): -#class TestNcfBundles(unittest.TestCase): """ Sanity tests for methods """ @@ -25,6 +24,21 @@ def setUp(self): """ self.methods = testlib.get_methods() + def test_deprecated_bundle_calls(self): + """ + Methods should not call deprecated methods + """ + deprecated_methods = [x.get_bundle_name() + for x in self.methods if 'deprecated' in x.metadata] + + for method in self.methods: + with self.subTest(i=method.path): + for line in method.content: + match = re.match( + r'\s*usebundle\s*=>\s*([a-zA-Z_]+)\s*.*$', line, flags=re.UNICODE + ) + if match: + self.assertNotIn(match.group(1), deprecated_methods) def test_methods_should_have_a_metadata(self): """ Methods should have a metadata @@ -96,6 +110,18 @@ def test_class_prefix(self): if not skip(method): self.assertTrue(testlib.test_pattern_on_file(method.path, class_prefix_pattern) is not None) + @avocado.skip('Some methods are still using _log') + def test_methods_should_use_latest_logger(self): + """ + Methods should always use the latest logger available + Currently not applied since some methods are using _log instead for some reasons + """ + for method in self.methods: + logger_pattern = r'.*usebundle\s+=>\s+_log_v3.*' + with self.subTest(i=method.path): + if not skip(method): + self.assertTrue(testlib.test_pattern_on_file(method.path, logger_pattern) is not None) + def test_methods_should_not_contain_unescaped_chars(self): """ Test if the documentation fields contain unescaped dollar characters that would break pdflatex @@ -106,6 +132,17 @@ def test_methods_should_not_contain_unescaped_chars(self): if 'documentation' in method.metadata: self.assertFalse(check_backquotes.match(method.metadata['documentation'])) + def test_methods_name_should_be_bundle_name(self): + """ + Methods filename should be base on their name + """ + for method in self.methods: + with self.subTest(i=method.path): + bundle_name = method.get_bundle_name() + filename = method.path_basename + compared_filename = re.sub(r'[0-9]+', '', filename) + self.assertTrue(bundle_name == compared_filename, '\nbundle_name = %s\n filename = %s'%(bundle_name, filename)) + @avocado.skip('Lots of methods are not correct atm') def test_methods_name_should_be_class_prefix(self): """ @@ -117,6 +154,49 @@ def test_methods_name_should_be_class_prefix(self): path = method.path_basename self.assertTrue(class_prefix == path, '\nprefix = %s\n path = %s'%(class_prefix, path)) + def test_methods_shouldi_not_use_deprecated_loggers(self): + """ + Methods should never use deprecated helper bundles/bodies + """ + deprecated_bundles = ['_logger_default', '_logger'] + deprecated_bodies = [ + 'do_if_immediate', + 'classes_generic_return_codes', + 'kept_if_else', + 'kept_if_else_persist', + 'ncf_ensure_section_content', + 'rudder_delete_if_not_in_list', + 'rudder_section_selector', + 'rudder_empty_select', + 'noempty_backup', + 'empty_backup', + 'cp', + 'rudder_copy_from', + 'copy_digest', + 'u_p', + 'rudder_common_minutes_old', + 'rudder_debian_knowledge', + 'rudder_rpm_knowledge', + 'yum_rpm_no_version', + 'redhat_local_install', + 'redhat_install', + 'debian_local_install', + 'ncf_generic', + 'ncf_generic_version', + 'apt_get_version', + 'rudder_rug', + 'rudder_yum', + 'cron_bin' + ] + for method in self.methods: + with self.subTest(i=method.path): + bodies_matching = [x for x in deprecated_bodies if '"%s"'%x in method.raw_content] + self.assertEqual(bodies_matching, [], "%s contains deprecated bodies %s"%(method.path, bodies_matching)) + + bundle_regex = '(' + '|'.join(deprecated_bundles) + ')' + bundle_pattern = r'.*usebundle\s+=>\s+%s.*'%bundle_regex + matches = re.findall(bundle_pattern, method.raw_content, flags=re.UNICODE) + self.assertEqual(matches, [], method.path + ' contains deprecated bundles ' + str(matches)) ### Helper functions def skip(method): @@ -134,6 +214,3 @@ def skip(method): pass return result -#if __name__ == '__main__': -# #unittest.main() -# main() diff --git a/tools/ncf.py b/tools/ncf.py index bdbc63e8c..4caf74eec 100644 --- a/tools/ncf.py +++ b/tools/ncf.py @@ -182,8 +182,11 @@ def parse_bundlefile_metadata(content, bundle_type): parameters.append({'name': param_name, 'description': match.group(4)}) param_names.add(param_name) else: - parameter = json.loads(match.group(2)) - parameters.append(parameter) + try: + parameter = json.loads(match.group(2)) + parameters.append(parameter) + except: + print("Error while loading JSON " +match.group(2)) if tag == "parameter_constraint": constraint = json.loads("{" + match.group(4).replace('\\', '\\\\') + "}") # extend default_constraint if it was not already defined) diff --git a/tree/10_ncf_internals/modules/packages/ips b/tree/10_ncf_internals/modules/packages/ips new file mode 100755 index 000000000..db17c8fbc --- /dev/null +++ b/tree/10_ncf_internals/modules/packages/ips @@ -0,0 +1,85 @@ +#!/bin/sh + +LEVEL=0 + +fatal () { + echo "ErrorMessage=$@" + exit 2 +} + +warn () { + [ $LEVEL -gt 0 ] && echo "[TRACE]: $*" >&2 +} + +supports_api_version () { + echo 1 +} + +get_package_data() { + if [ -f "${File}" ] + then + echo "PackageType=file" + # this probably doesn't work + echo "Name=${File}" + else + echo "PackageType=repo" + pkg list -H --no-refresh "${File}" | head -n1 | awk '{print "Name=" $1}' + fi +} + +list_installed () { + arch=$(uname -p) + pkg list -H --no-refresh | awk '{print "Name=" $1 "\nVersion=" $2 "\nArchitecture=" "'${arch}'"}' +} + +list_updates () { + # The difference between list-updates and list-updates-local + # is that list-updates expects to refresh from the upstream repo. + pkg refresh -q + list_updates_local +} + +list_updates_local () { + arch=$(uname -p) + pkg list -H --no-refresh -u | awk '{print "Name=" $1 "\nVersion=" $2 "\nArchitecture=" "'${arch}'"}' +} + +repo_install () { + # ignore architecture + [ "${Version}" != "" ] && Name="${Name}@${Version}" + pkg install -q --accept --no-refresh "${Name}" +} + +file_install () { + fatal "File installation not supported" +} + +remove () { + # ignore architecture + [ "${Version}" != "" ] && Name="${Name}@${Version}" + pkg uninstall -q --ignore-missing "${Name}" +} + +# Cfengine passes data on STDIN. Absorb that and convert to shell variables. +while IFS= read -r line; do + eval "$line" + # options can be passed multiple times so we need to avoid clobbering + # previous instances. Plus, what we really want to eval is the value of + # each option. + if [ -n "$options" ]; then + eval "$options" + fi +done + +case "$1" in + supports-api-version) supports_api_version;; + repo-install) repo_install;; + file-install) file_install;; + remove) remove;; + list-installed) list_installed;; + list-updates) list_updates;; + list-updates-local) list_updates_local;; + get-package-data) get_package_data;; + *) fatal "Invalid operation";; +esac + diff --git a/tree/20_cfe_basics/cfengine/packages.cf b/tree/20_cfe_basics/cfengine/packages.cf index a1de1c689..d4ba11c7f 100644 --- a/tree/20_cfe_basics/cfengine/packages.cf +++ b/tree/20_cfe_basics/cfengine/packages.cf @@ -72,6 +72,9 @@ bundle common package_module_knowledge slackware:: "platform_default" string => "slackpkg"; + solaris:: + "platform_default" string => "ips"; + # CFEngine 3.12.2+ and 3.14+ have new package module on Windows windows.cfengine_3_12.!(cfengine_3_12_0|cfengine_3_12_1):: "platform_default" string => "msiexec"; diff --git a/tree/20_cfe_basics/def.cf b/tree/20_cfe_basics/def.cf index 5cfcc8e87..e41916b49 100644 --- a/tree/20_cfe_basics/def.cf +++ b/tree/20_cfe_basics/def.cf @@ -20,4 +20,6 @@ bundle common ncf_def { vars: "package_module_query_installed_ifelapsed" string => "${node.properties[rudder][packages][installed_cache_expire]}"; "package_module_query_updates_ifelapsed" string => "${node.properties[rudder][packages][updates_cache_expire]}"; + classes: + "mpf_stdlib_use_posix_utils" expression => "solaris"; } diff --git a/tree/20_cfe_basics/packages.cf b/tree/20_cfe_basics/packages.cf index f65a81213..e53875b07 100644 --- a/tree/20_cfe_basics/packages.cf +++ b/tree/20_cfe_basics/packages.cf @@ -32,6 +32,14 @@ body package_module zypper_pattern #default_options => {}; } +# Not upstream +body package_module ips +{ + query_installed_ifelapsed => "$(ncf_def.package_module_query_installed_ifelapsed)"; + query_updates_ifelapsed => "$(ncf_def.package_module_query_updates_ifelapsed)"; + #default_options => {}; +} + # Called by package_* generic methods bundle agent ncf_package(name, version, architecture, provider, state, options) { @@ -110,11 +118,13 @@ bundle agent ncf_package(name, version, architecture, provider, state, options) "use_zypper_pattern_provider" expression => strcmp("zypper_pattern", "${provider}"); "use_pkg_provider" expression => strcmp("pkg", "${provider}"); "use_slackpkg_provider" expression => strcmp("slackpkg", "${provider}"); + "use_ips_provider" expression => strcmp("ips", "${provider}"); + "use_nimclient_provider" expression => strcmp("nimclient", "${provider}"); # Used in tests "use_test_provider" expression => strcmp("test", "${provider}"); any:: - "supported_provider" expression => "use_apt_provider|use_yum_provider|use_zypper_provider|use_pkg_provider|use_slackpkg_provider|use_test_provider|use_zypper_pattern_provider"; + "supported_provider" expression => "use_apt_provider|use_yum_provider|use_zypper_provider|use_pkg_provider|use_slackpkg_provider|use_test_provider|use_zypper_pattern_provider|use_ips_provider|use_nimclient_provider"; "pass3" expression => "pass2"; "pass2" expression => "pass1"; @@ -327,7 +337,74 @@ bundle agent ncf_package(name, version, architecture, provider, state, options) package_module => slackpkg, options => { "${options}" }, classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); - + + #### ips #### + + use_ips_provider.architecture_specified.version_specified:: + "${name}" + policy => "${state}", + package_module => ips, + architecture => "${architecture}", + version => "${version}", + options => { "${options}" }, + classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); + + use_ips_provider.architecture_specified.!version_specified:: + "${name}" + policy => "${state}", + package_module => ips, + architecture => "${architecture}", + options => { "${options}" }, + classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); + + use_ips_provider.!architecture_specified.version_specified:: + "${name}" + policy => "${state}", + package_module => ips, + version => "${version}", + options => { "${options}" }, + classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); + + use_ips_provider.!architecture_specified.!version_specified:: + "${name}" + policy => "${state}", + package_module => ips, + options => { "${options}" }, + classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); + + #### nimclient #### + + use_nimclient_provider.architecture_specified.version_specified:: + "${name}" + policy => "${state}", + package_module => nimclient, + architecture => "${architecture}", + version => "${version}", + options => { "${options}" }, + classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); + + use_nimclient_provider.architecture_specified.!version_specified:: + "${name}" + policy => "${state}", + package_module => nimclient, + architecture => "${architecture}", + options => { "${options}" }, + classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); + + use_nimclient_provider.!architecture_specified.version_specified:: + "${name}" + policy => "${state}", + package_module => nimclient, + version => "${version}", + options => { "${options}" }, + classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); + + use_nimclient_provider.!architecture_specified.!version_specified:: + "${name}" + policy => "${state}", + package_module => nimclient, + options => { "${options}" }, + classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); #### test #### use_test_provider.architecture_specified.version_specified:: diff --git a/tree/20_cfe_basics/paths.cf b/tree/20_cfe_basics/paths.cf index 5e3ddd417..b8568f769 100644 --- a/tree/20_cfe_basics/paths.cf +++ b/tree/20_cfe_basics/paths.cf @@ -26,7 +26,16 @@ bundle common ncf_paths "path[curl]" string => "${paths.path[curl]}", unless => isvariable("g.rudder_curl"); - "path[augtool]" string => "/usr/bin/augtool"; + "path[augtool]" string => "/opt/rudder/bin/augtool", + if => fileexists("/opt/rudder/bin/augtool"); + "path[augtool]" string => "/usr/bin/augtool", + unless => fileexists("/opt/rudder/bin/augtool"); + + "path[head]" string => "/usr/bin/head"; + "path[tail]" string => "/usr/bin/tail"; + "path[tail]" string => "/usr/xpg4/bin/tail", + if => "solaris.(mpf_stdlib_use_posix_utils.!disable_mpf_stdlib_use_posix_utils)"; + "path[id]" string => "/usr/bin/id"; diff --git a/tree/30_generic_methods/_file_check_special.cf b/tree/30_generic_methods/_file_check_special.cf index 2146f02af..b041e41b2 100644 --- a/tree/30_generic_methods/_file_check_special.cf +++ b/tree/30_generic_methods/_file_check_special.cf @@ -20,29 +20,31 @@ # @name File check is special # @description Checks if a file exists and is a special file # -# @parameter file_name File name +# @parameter path File name # @parameter file_type File type to check, can be "block device", "character device", "directory", "FIFO/pipe", "regular file", "socket", "symlink" # +# @parameter_name path file_name +# # @class_prefix file_check -# @class_parameter file_name -# This bundle will define a condition file_check_${file_type}_${file_name}_{ok, reached, kept} if the -# file is a special file of type ${file_type}, or file_check_${file_type}_${file_name}_{not_ok, reached, not_kept, failed} if +# @class_parameter path +# This bundle will define a condition file_check_${file_type}_${path}_{ok, reached, kept} if the +# file is a special file of type ${file_type}, or file_check_${file_type}_${path}_{not_ok, reached, not_kept, failed} if # the file is not a special file or does not exist -bundle agent file_check_special(file_name, file_type) +bundle agent file_check_special(path, file_type) { vars: - "file_has_type" string => filestat("${file_name}", "type"); + "file_has_type" string => filestat("${path}", "type"); - "old_class_prefix" string => canonify("file_check_${file_type}_${file_name}"); + "old_class_prefix" string => canonify("file_check_${file_type}_${path}"); - "args" slist => { "${file_name}", "${file_type}" }; + "args" slist => { "${path}", "${file_type}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_check_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); classes: - "file_exists" expression => fileexists("${file_name}"); + "file_exists" expression => fileexists("${path}"); "file_is_special" expression => strcmp("${file_has_type}", "${file_type}"); "exists_special" expression => "file_exists.file_is_special"; @@ -62,5 +64,5 @@ bundle agent file_check_special(file_name, file_type) any:: "report" - usebundle => _log_v3("Check if ${file_name} exists and is a ${file_type}", "${file_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Check if ${path} exists and is a ${file_type}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/_log_v3.cf b/tree/30_generic_methods/_log_v3.cf index ce51efe9c..dc7dda0c7 100644 --- a/tree/30_generic_methods/_log_v3.cf +++ b/tree/30_generic_methods/_log_v3.cf @@ -39,6 +39,6 @@ bundle agent _log_v3(message, class_parameter, old_class_prefix, class_prefix, a methods: # Report using the appropriate bundle(s) "wrapper for log_rudder" - usebundle => log_rudder("${message}", "${class_parameter}", "${old_class_prefix}", "${class_prefix}", "@{args}"), + usebundle => log_rudder("${message}", "", "${old_class_prefix}", "${class_prefix}", "@{args}"), comment => "Call the log_rudder bundle for directive ${report_data.directive_id} with arguments ${old_class_prefix}, ${class_prefix}, @{args}"; } diff --git a/tree/30_generic_methods/condition_from_command.cf b/tree/30_generic_methods/condition_from_command.cf index 393ce8136..be4cb9206 100644 --- a/tree/30_generic_methods/condition_from_command.cf +++ b/tree/30_generic_methods/condition_from_command.cf @@ -19,19 +19,19 @@ # @name Condition from command # @description Execute a command and create result conditions depending on its exit code # @documentation -# This method executes a command, and defines a `${condition_prefix}_true` or a -# `${condition_prefix}_false` condition depending on the result of the command: +# This method executes a command, and defines a `${condition}_true` or a +# `${condition}_false` condition depending on the result of the command: # # * If the exit code **is in the "True codes"** list, this will produce a # kept outcome and a -# `${condition_prefix}_true` condition, +# `${condition}_true` condition, # * If the exit code **is in the "False codes"** list, this will produce a # kept outcome and a -# `${condition_prefix}_false` condition, +# `${condition}_false` condition, # * If the exit code **is not in "True codes" nor in "False codes"**, or if # the command can not be found, it will produce an # error outcome and -# and no condition from `${condition_prefix}` +# and no condition from `${condition}` # # # The created condition is global to the agent. @@ -69,19 +69,19 @@ # * Rudder will automatically "canonify" the given **Condition prefix** at execution time, # which means that all non `[a-zA-Z0-9_]` characters will be replaced by an underscore. # -# @parameter condition_prefix The condition name +# @parameter condition The condition name # @parameter command The command to run # @parameter true_codes List of codes that produce a true status separated with commas (ex: 1,2,5) # @parameter false_codes List of codes that produce a false status separated with commas (ex: 3,4,6) # # @class_prefix condition_from_command -# @class_parameter condition_prefix +# @class_parameter condition -bundle agent condition_from_command(condition_prefix, command, true_codes, false_codes) +bundle agent condition_from_command(condition, command, true_codes, false_codes) { vars: - "old_class_prefix" string => canonify("condition_from_command_${condition_prefix}"); - "args" slist => { "${condition_prefix}", "${command}", "${true_codes}", "${false_codes}" }; + "old_class_prefix" string => canonify("condition_from_command_${condition}"); + "args" slist => { "${condition}", "${command}", "${true_codes}", "${false_codes}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("condition_from_command_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -102,11 +102,11 @@ bundle agent condition_from_command(condition_prefix, command, true_codes, false "restore_dry_run_${class_prefix}" usebundle => pop_dry_run_mode(); pass3:: "report" - usebundle => _log_v3("Execute the test command ${command} to create ${condition_prefix}_{true,false}", "${condition_prefix}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Execute the test command ${command} to create ${condition}_{true,false}", "${condition}", "${old_class_prefix}", "${class_prefix}", @{args}); commands: pass1.!pass2:: "${command}" contain => in_shell, - classes => classes_generic_return_boolean_list_two("${old_class_prefix}", "${class_prefix}", "${condition_prefix}", @{true_list}, @{false_list}); + classes => classes_generic_return_boolean_list_two("${old_class_prefix}", "${class_prefix}", "${condition}", @{true_list}, @{false_list}); } diff --git a/tree/30_generic_methods/condition_from_expression.cf b/tree/30_generic_methods/condition_from_expression.cf index f4284036a..055e053a2 100644 --- a/tree/30_generic_methods/condition_from_expression.cf +++ b/tree/30_generic_methods/condition_from_expression.cf @@ -19,15 +19,15 @@ # @name Condition from expression # @description Create a new condition # @documentation -# This method evaluates an expression, and produces a `${condition_prefix}_true` -# or a `${condition_prefix}_false` condition depending on the result of the +# This method evaluates an expression, and produces a `${condition}_true` +# or a `${condition}_false` condition depending on the result of the # expression evaluation: # # * This method always result with a *success* outcome status # * If the evaluation results in a "defined" state, this will define a -# `${condition_prefix}_true` condition, +# `${condition}_true` condition, # * If the evaluation results in an "undefined" state, this will produce a -# `${condition_prefix}_false` condition. +# `${condition}_false` condition. # # # Calling this method with a condition expression transforms a complex expression into a single condition. @@ -57,31 +57,33 @@ # Rudder will automatically "canonify" the given **Condition prefix** at execution time, # which means that all non `[a-zA-Z0-9_]` characters will be replaced by an underscore. # -# @parameter condition_prefix The condition prefix +# @parameter condition The condition prefix # @parameter condition_expression The expression evaluated to create the condition (use 'any' to always evaluate to true) +# +# @parameter_name condition condition_prefix # # @class_prefix condition_from_expression -# @class_parameter condition_prefix +# @class_parameter condition -bundle agent condition_from_expression(condition_prefix, condition_expression) +bundle agent condition_from_expression(condition, condition_expression) { vars: - "old_class_prefix" string => canonify("condition_from_expression_${condition_prefix}"); - "args" slist => { "${condition_prefix}", "${condition_expression}" }; + "old_class_prefix" string => canonify("condition_from_expression_${condition}"); + "args" slist => { "${condition}", "${condition_expression}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("condition_from_expression_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); classes: - "${condition_prefix}_true" expression => "${condition_expression}", + "${condition}_true" expression => "${condition_expression}", scope => "namespace"; - "${condition_prefix}_false" expression => "!(${condition_expression})", + "${condition}_false" expression => "!(${condition_expression})", scope => "namespace"; methods: "success" usebundle => _classes_success("${old_class_prefix}"); "success" usebundle => _classes_success("${class_prefix}"); - "report" usebundle => _log_v3("Create the condition ${condition_prefix}_{true,false} with ${condition_expression}", "${condition_prefix}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Create the condition ${condition}_{true,false} with ${condition_expression}", "${condition}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/condition_from_expression_persistent.cf b/tree/30_generic_methods/condition_from_expression_persistent.cf index 1d1d5795d..9ccdd462d 100644 --- a/tree/30_generic_methods/condition_from_expression_persistent.cf +++ b/tree/30_generic_methods/condition_from_expression_persistent.cf @@ -19,13 +19,13 @@ # @name Condition from expression persistent # @description Create a new condition that persists across runs # @documentation -# This method evaluates an expression (=condition combination), and produces a `${condition_prefix}_true` -# or a `${condition_prefix}_false` condition depending on the result on the expression, +# This method evaluates an expression (=condition combination), and produces a `${condition}_true` +# or a `${condition}_false` condition depending on the result on the expression, # which will lasts for the **Duration** time: # # * This method always result with a *success* outcome status -# * If the expression evaluation results in a "defined" state, this will define a `${condition_prefix}_true` condition, -# * If the expression evaluation results in an "undefined" state, this will produce a `${condition_prefix}_false` condition. +# * If the expression evaluation results in a "defined" state, this will define a `${condition}_true` condition, +# * If the expression evaluation results in an "undefined" state, this will produce a `${condition}_false` condition. # # # Calling this method with a condition expression transforms a complex expression into a single class condition. @@ -57,28 +57,30 @@ # Rudder will automatically "canonify" the given **Condition prefix** at execution time, # which means that all non `[a-zA-Z0-9_]` characters will be replaced by an underscore. # -# @parameter condition_prefix The condition prefix +# @parameter condition The condition prefix # @parameter condition_expression The expression evaluated to create the condition (use 'any' to always evaluate to true) # @parameter duration The persistence suffix in minutes # +# @parameter_name condition condition_prefix +# # @class_prefix condition_from_expression_persistent -# @class_parameter condition_prefix +# @class_parameter condition -bundle agent condition_from_expression_persistent(condition_prefix, condition_expression, duration) +bundle agent condition_from_expression_persistent(condition, condition_expression, duration) { vars: - "old_class_prefix" string => canonify("condition_from_expression_persistent_${condition_prefix}"); - "args" slist => { "${condition_prefix}", "${condition_expression}", "${duration}" }; + "old_class_prefix" string => canonify("condition_from_expression_persistent_${condition}"); + "args" slist => { "${condition}", "${condition_expression}", "${duration}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("condition_from_expression_persistent_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); classes: - "${condition_prefix}_true" expression => "${condition_expression}", + "${condition}_true" expression => "${condition_expression}", persistence => "${duration}", scope => "namespace"; - "${condition_prefix}_false" expression => "!(${condition_expression})", + "${condition}_false" expression => "!(${condition_expression})", persistence => "${duration}", scope => "namespace"; @@ -86,5 +88,5 @@ bundle agent condition_from_expression_persistent(condition_prefix, condition_ex "success" usebundle => _classes_success("${old_class_prefix}"); "success" usebundle => _classes_success("${class_prefix}"); - "report" usebundle => _log_v3("Create the persistent condition ${condition_prefix}_{true,false} with ${condition_expression}", "${condition_prefix}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Create the persistent condition ${condition}_{true,false} with ${condition_expression}", "${condition}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/condition_from_variable_existence.cf b/tree/30_generic_methods/condition_from_variable_existence.cf index e5533afb3..c9d58c3e2 100644 --- a/tree/30_generic_methods/condition_from_variable_existence.cf +++ b/tree/30_generic_methods/condition_from_variable_existence.cf @@ -27,32 +27,34 @@ # # Also, this method always result with a *success* outcome status. # -# @parameter condition_prefix Prefix of the condition +# @parameter condition Prefix of the condition # @parameter variable_name Complete name of the variable being tested, like my_prefix.my_variable +# +# @parameter_name condition condition_prefix # # @class_prefix condition_from_variable_existence -# @class_parameter condition_prefix +# @class_parameter condition -bundle agent condition_from_variable_existence(condition_prefix, variable_name) +bundle agent condition_from_variable_existence(condition, variable_name) { vars: - "old_class_prefix" string => canonify("condition_from_variable_existence_${condition_prefix}"); - "args" slist => { "${condition_prefix}", "${variable_name}" }; + "old_class_prefix" string => canonify("condition_from_variable_existence_${condition}"); + "args" slist => { "${condition}", "${variable_name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("condition_from_variable_existence_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); classes: - "${condition_prefix}_true" expression => isvariable("${variable_name}"), + "${condition}_true" expression => isvariable("${variable_name}"), scope => "namespace"; - "${condition_prefix}_false" not => isvariable("${variable_name}"), + "${condition}_false" not => isvariable("${variable_name}"), scope => "namespace"; methods: "success" usebundle => _classes_success("${old_class_prefix}"); "success" usebundle => _classes_success("${class_prefix}"); - "report" usebundle => _log_v3("Create the condition ${condition_prefix}_{true,false} from the existence of variable ${variable_name}", "${condition_prefix}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Create the condition ${condition}_{true,false} from the existence of variable ${variable_name}", "${condition}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/condition_from_variable_match.cf b/tree/30_generic_methods/condition_from_variable_match.cf index 9fcef076c..a0ed746cb 100644 --- a/tree/30_generic_methods/condition_from_variable_match.cf +++ b/tree/30_generic_methods/condition_from_variable_match.cf @@ -21,13 +21,13 @@ # @documentation # Test a variable content and create conditions depending on its value: # * If the variable **is found and its content matches** the given regex: -# * a `${condition_prefix}_true` condition, +# * a `${condition}_true` condition, # * and **kept outcome** status # * If the variable **is found but its content does not match** the given regex: -# * a `${condition_prefix}_false` condition, +# * a `${condition}_false` condition, # * and a **kept outcome** status # * If the variable **can not be found**: -# * a `${condition_prefix}_false` condition +# * a `${condition}_false` condition # * and an **error outcome** status # # /!\ Regex for unix machine must be PCRE compatible and those for Windows agent must respect the .Net regex format. @@ -35,19 +35,20 @@ # * If you want to test a technique parameter, use the `technique_id` of the technique # as variable prefix and the`parameter_name` as variable name. # -# @parameter condition_prefix Prefix of the class (condition) generated +# @parameter condition Prefix of the class (condition) generated # @parameter variable_name Complete name of the variable being tested, like my_prefix.my_variable # @parameter expected_match Regex to use to test if the variable content is compliant +# +# @parameter_name condition condition_prefix # # @class_prefix condition_from_variable_match -# @class_parameter condition_prefix +# @class_parameter condition - -bundle agent condition_from_variable_match(condition_prefix, variable_name, expected_match) +bundle agent condition_from_variable_match(condition, variable_name, expected_match) { vars: - "old_class_prefix" string => canonify("condition_from_variable_match_${condition_prefix}"); - "args" slist => { "${condition_prefix}", "${variable_name}", "${expected_match}" }; + "old_class_prefix" string => canonify("condition_from_variable_match_${condition}"); + "args" slist => { "${condition}", "${variable_name}", "${expected_match}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("condition_from_variable_match_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -60,10 +61,10 @@ bundle agent condition_from_variable_match(condition_prefix, variable_name, expe pass2:: "var_exists" expression => isvariable("${variable_name}"); - "${condition_prefix}_true" and => {regcmp("${expected_match}", "${${variable_name}}"), "var_exists"}, + "${condition}_true" and => {regcmp("${expected_match}", "${${variable_name}}"), "var_exists"}, scope => "namespace"; - "${condition_prefix}_false" or => {"!${condition_prefix}_true", "!var_exists"}, + "${condition}_false" or => {"!${condition}_true", "!var_exists"}, scope => "namespace"; methods: @@ -78,5 +79,5 @@ bundle agent condition_from_variable_match(condition_prefix, variable_name, expe "success" usebundle => _classes_success("${class_prefix}"), ifvarclass => "var_exists"; - "report" usebundle => _log("Create the condition ${condition_prefix}_{true,false} from the result of regex: /${expected_match}/ on variable ${variable_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log("Create the condition ${condition}_{true,false} from the result of regex: /${expected_match}/ on variable ${variable_name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/directory_absent.cf b/tree/30_generic_methods/directory_absent.cf index 92b9364c3..0b6bd0476 100644 --- a/tree/30_generic_methods/directory_absent.cf +++ b/tree/30_generic_methods/directory_absent.cf @@ -20,21 +20,23 @@ # @description Ensure a directory's absence # @documentation If `recursive` is false, only an empty directory can be deleted. # -# @parameter target Directory to remove +# @parameter path Directory to remove # @parameter recursive Should deletion be recursive, "true" or "false" (defaults to "false") # @parameter_constraint recursive "allow_empty_string" : true +# +# @parameter_name path target # # @class_prefix directory_absent -# @class_parameter target +# @class_parameter path -bundle agent directory_absent(target, recursive) +bundle agent directory_absent(path, recursive) { vars: - "old_class_prefix" string => canonify("directory_absent_${target}"); + "old_class_prefix" string => canonify("directory_absent_${path}"); # don't rewrite the class prefix based on defaults !pass1:: - "args" slist => { "${target}", "${recursive}" }; + "args" slist => { "${path}", "${recursive}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("directory_absent_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -46,8 +48,8 @@ bundle agent directory_absent(target, recursive) "is_recursive" expression => strcmp("true", "${recursive}"); pass2:: - "directory_exists_after" expression => isdir("${target}"); - "target_exists_after" expression => fileexists("${target}"); + "directory_exists_after" expression => isdir("${path}"); + "path_exists_after" expression => fileexists("${path}"); any:: "pass3" expression => "pass2"; @@ -57,14 +59,14 @@ bundle agent directory_absent(target, recursive) files: pass1.is_recursive:: - "${target}/." + "${path}/." delete => tidy, file_select => all, depth_search => recurse_with_base("inf"), classes => classes_generic_two("${old_class_prefix}_inside", "${class_prefix}_inside"); pass1:: - "${target}/." + "${path}/." delete => tidy, file_select => all, classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"), @@ -72,7 +74,7 @@ bundle agent directory_absent(target, recursive) methods: - # If target was not empty, we need to trigger an error manually as the files promise will be kept + # If path was not empty, we need to trigger an error manually as the files promise will be kept # Because of https://tracker.mender.io/browse/CFE-1570 pass3.directory_exists_after:: "fail_if_not_empty" usebundle => _classes_failure("${class_prefix}"); @@ -88,9 +90,9 @@ bundle agent directory_absent(target, recursive) "copy_inside_error" usebundle => _classes_copy("${old_class_prefix}_inside", "${old_class_prefix}"), ifvarclass => "${old_class_prefix}_inside_error"; - "report" usebundle => _log_v3("Remove directory ${target}", "${target}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Remove directory ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); reports: - pass3.info.target_exists_after.!directory_exists_after:: - "${configuration.info} Found a non-directory object with the name ${target} while ensuring this directory did not exist"; + pass3.info.path_exists_after.!directory_exists_after:: + "${configuration.info} Found a non-directory object with the name ${path} while ensuring this directory did not exist"; } diff --git a/tree/30_generic_methods/directory_check_exists.cf b/tree/30_generic_methods/directory_check_exists.cf index f08d66895..d6a128bc6 100644 --- a/tree/30_generic_methods/directory_check_exists.cf +++ b/tree/30_generic_methods/directory_check_exists.cf @@ -18,26 +18,28 @@ # @name Directory check exists # @description Checks if a directory exists -# @documentation This bundle will define a condition `directory_check_exists_${directory_name}_{ok, reached, kept}` if the -# directory exists, or `directory_check_exists_${directory_name}_{not_ok, reached, not_kept, failed}` if +# @documentation This bundle will define a condition `directory_check_exists_${path}_{ok, reached, kept}` if the +# directory exists, or `directory_check_exists_${path}_{not_ok, reached, not_kept, failed}` if # the directory doesn't exists # -# @parameter directory_name Full path of the directory to check +# @parameter path Full path of the directory to check # +# @parameter_name path directory_name +# # @class_prefix directory_check_exists -# @class_parameter directory_name +# @class_parameter path -bundle agent directory_check_exists(directory_name) +bundle agent directory_check_exists(path) { vars: - "old_class_prefix" string => canonify("directory_check_exists_${directory_name}"); - "args" slist => { "${directory_name}" }; + "old_class_prefix" string => canonify("directory_check_exists_${path}"); + "args" slist => { "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("directory_check_exists_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); classes: - "directory_exists" expression => isdir("${directory_name}"); + "directory_exists" expression => isdir("${path}"); methods: directory_exists:: @@ -49,5 +51,5 @@ bundle agent directory_check_exists(directory_name) "directory_doesnt_exists" usebundle => _classes_failure("${class_prefix}"); any:: - "report" usebundle => _log_v3("Check if directory ${directory_name} exists", "${directory_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Check if directory ${path} exists", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/directory_create.cf b/tree/30_generic_methods/directory_create.cf index 83d5ff785..601dd85e2 100644 --- a/tree/30_generic_methods/directory_create.cf +++ b/tree/30_generic_methods/directory_create.cf @@ -21,34 +21,36 @@ # @rename directory_present # @deprecated Use [directory_present](#_directory_present) instead. # -# @parameter target Full path of directory to create (trailing '/' is optional) +# @parameter path Full path of directory to create (trailing '/' is optional) +# +# @parameter_name path target # # @class_prefix directory_create -# @class_parameter target +# @class_parameter path -bundle agent directory_create(target) +bundle agent directory_create(path) { vars: - "canonified_target" string => canonify("${target}"); + "canonified_path" string => canonify("${path}"); - "old_class_prefix" string => canonify("directory_create_${target}"); - "full_class_prefix" string => canonify("directory_create_${target}"); + "old_class_prefix" string => canonify("directory_create_${path}"); + "full_class_prefix" string => canonify("directory_create_${path}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "args" slist => { "${target}" }; + "args" slist => { "${path}" }; classes: "should_report" expression => "${report_data.should_report}"; methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => directory_present("${target}"); + "action" usebundle => directory_present("${path}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("directory_present_${canonified_target}", "${old_class_prefix}"), - ifvarclass => "directory_present_${canonified_target}_reached"; - "new result classes" usebundle => _classes_copy("directory_present_${canonified_target}","${class_prefix}"), - ifvarclass => "directory_present_${canonified_target}_reached"; - "report" usebundle => _log_v3("Create directory ${target}", "${target}", "${old_class_prefix}", "${class_prefix}", @{args}); + "class copy" usebundle => _classes_copy("directory_present_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "directory_present_${canonified_path}_reached"; + "new result classes" usebundle => _classes_copy("directory_present_${canonified_path}","${class_prefix}"), + ifvarclass => "directory_present_${canonified_path}_reached"; + "report" usebundle => _log_v3("Create directory ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/directory_present.cf b/tree/30_generic_methods/directory_present.cf index 385ccc182..585847a9e 100644 --- a/tree/30_generic_methods/directory_present.cf +++ b/tree/30_generic_methods/directory_present.cf @@ -20,25 +20,27 @@ # @description Create a directory if it doesn't exist # @documentation Create a directory if it doesn't exist. # -# @parameter target Full path of directory to create (trailing '/' is optional) +# @parameter path Full path of directory to create (trailing '/' is optional) +# +# @parameter_name path target # # @class_prefix directory_present -# @class_parameter target +# @class_parameter path -bundle agent directory_present(target) +bundle agent directory_present(path) { vars: - "old_class_prefix" string => canonify("directory_present_${target}"); - "args" slist => { "${target}" }; + "old_class_prefix" string => canonify("directory_present_${path}"); + "args" slist => { "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("directory_present_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); files: - "${target}/." - create => "true", - classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); + "${path}/." + create => "true", + classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); methods: - "report" usebundle => _log_v3("Create directory ${target}", "${target}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Create directory ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/environment_variable.cf b/tree/30_generic_methods/environment_variable_present.cf similarity index 100% rename from tree/30_generic_methods/environment_variable.cf rename to tree/30_generic_methods/environment_variable_present.cf diff --git a/tree/30_generic_methods/file_absent.cf b/tree/30_generic_methods/file_absent.cf index 21429857a..4cc53a642 100644 --- a/tree/30_generic_methods/file_absent.cf +++ b/tree/30_generic_methods/file_absent.cf @@ -19,27 +19,29 @@ # @name File absent # @description Remove a file if it exists # -# @parameter target File to remove (absolute path on the target node) +# @parameter path File to remove (absolute path on the path node) +# +# @parameter_name path target # # @class_prefix file_absent -# @class_parameter target +# @class_parameter path -bundle agent file_absent(target) +bundle agent file_absent(path) { vars: - "old_class_prefix" string => canonify("file_absent_${target}"); - "args" slist => { "${target}" }; + "old_class_prefix" string => canonify("file_absent_${path}"); + "args" slist => { "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_absent_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); classes: #need to ensure if it's a folder or a file - "is_folder" expression => isdir("${target}"); + "is_folder" expression => isdir("${path}"); files: !is_folder:: - "${target}" + "${path}" delete => tidy, classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); @@ -51,7 +53,7 @@ bundle agent file_absent(target) "success_if_nothing" usebundle => _classes_success("${class_prefix}"), ifvarclass => "!${class_prefix}_reached"; - "report" usebundle => _log_v3("Remove file ${target}", "${target}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Remove file ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); is_folder:: "error" usebundle => _classes_failure("${old_class_prefix}"), @@ -60,7 +62,7 @@ bundle agent file_absent(target) "error" usebundle => _classes_failure("${class_prefix}"), ifvarclass => "!${class_prefix}_reached"; - "report" usebundle => _log_v3("${target} is a directory, and cannot be removed as a file", "${target}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("${path} is a directory, and cannot be removed as a file", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_augeas_commands.cf b/tree/30_generic_methods/file_augeas_commands.cf index d723d198a..6e030419e 100644 --- a/tree/30_generic_methods/file_augeas_commands.cf +++ b/tree/30_generic_methods/file_augeas_commands.cf @@ -56,17 +56,18 @@ # # @parameter variable_prefix The prefix of the variable name # @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name -# @parameter commands The augeas command(s) +# @parameter commands The augeas command(s) # @parameter autoload Deactivate the `autoload` option if you don't want augeas to charge all the files/lens, it's `true` by default. # @parameter_constraint autoload "allow_empty_string" : true # @parameter_constraint autoload "select" : [ "", "true", "false" ] +# # @class_prefix file_augeas_commands # @class_parameter variable_name bundle agent file_augeas_commands(variable_prefix, variable_name, commands, autoload) { - vars: + vars: "old_class_prefix" string => canonify("file_augeas_commands_${variable_name}"); "promisers" slist => { @{this.callers_promisers}, cf_null }, policy => "ifdefined"; "class_prefix" string => canonify(join("_", "promisers")); @@ -78,7 +79,6 @@ bundle agent file_augeas_commands(variable_prefix, variable_name, commands, auto pass1.autoload_defined:: "${variable_prefix}.${variable_name}" string => execresult("printf \"${commands}\n\" | ${ncf_paths.path[augtool]}","useshell"); - defaults: "autoload" string => "true", if_match_regex => ""; diff --git a/tree/30_generic_methods/file_augeas_set.cf b/tree/30_generic_methods/file_augeas_set.cf index 0ba80d464..e921afc47 100644 --- a/tree/30_generic_methods/file_augeas_set.cf +++ b/tree/30_generic_methods/file_augeas_set.cf @@ -17,7 +17,7 @@ ##################################################################################### # # @name File Augeas set -# @description Use Augeas binaries to call Augtool commands and options to set a node label's value. +# @description Use augeas commands and options to set a node label's value. # # @documentation Augeas is a tool that provides an abstraction layer for all the complexities that turn around editing files with regular expressions. # It's a tree based hierarchy tool, that handles system configuration files where you can securely modify your files and to do so you have to provide @@ -27,16 +27,18 @@ # # In this method, we introduce using augtool commands and options in order to set the value of a given node's label in the parameters # (which means that you simply want to modify your configuration file), this can be done by specifying the path to it. -# The method has in total 4 parameters: path, value, lens and hosts. # -# Actually there is two ways you can use this method, either you simply provide a path to the node's label as a parameter or you specify a file +# Actually there are two ways you can use this method, either you simply provide a path to the node's label as a parameter or you specify a file # associated with a lens then you put the regular path. When you only specify the path to the node's label, your request will includes by default Augeas # charging all the lenses and files, on the other hand, if you have a specific file for example such as a Json file and you want to associate it # to the existing Json lens, then in that case, you need to fill in addition the file and the lens parameter, this way Augeas won't load all its files and # lenses except the ones you have specified. # -# The generic method will set a node label's value on the agent, otherwise, if Augeas isn't installed on the agent, it will produces an error. -# The method provides a way to make a backup of the file you modified before applying any changes on the node, you can find them in the '/var/rudder/modified-files/' directory. +# *Warning*: When you don't specify the file and lens to use, no backup of the file is made before +# editing it. +# +# *Note*: Specifying the file and lens makes the edition way faster as it avoids having to load +# all the default lenses and files. # # #### Two uses cases examples: # @@ -56,58 +58,94 @@ # # @parameter path The path to the file and node label # @parameter value The value to set -# @parameter lens The lens specified by the user in case he wants to load a specified lens associated with its file -# @parameter file The file specified by the user in case he wants to load a specified file associated with its lens +# @parameter lens Load a specific lens (optional) +# @parameter file Load a specific file (optional) # @parameter_constraint file "allow_empty_string" : true # @parameter_constraint lens "allow_empty_string" : true # @class_prefix file_augeas_set # @class_parameter path - bundle agent file_augeas_set(path, value, lens, file) { - vars: - "old_class_prefix" string => canonify("file_augeas_set_${path}"); - "args" slist => {"${path}", "${value}", "${lens}","${file}"}; - "report_param" string => join("_", args); - "class_prefix" string => canonify("file_augeas_set_${report_param}"); - - pass1.file_defined:: - "result" string => "printf \"set /augeas/load/${lens}/lens \"${lens}.lns\" \n set /augeas/load/${lens}/incl \"${file}\" \n load \n set /files${path} ${value} \n save\" | ${ncf_paths.path[augtool]} --noautoload -b"; - "timestamp" string => execresult("LANG=C date +%s","useshell"); - "date" string => canonify(execresult("LANG=C date +\"%a_%b_%e_%H_%M_%S_%Y\"","useshell")); - "cfile" string => canonify("${file}"); - - pass1.!file_defined:: - "result" string => "printf \"set /files${path} ${value} \n save\" | ${ncf_paths.path[augtool]}"; - - classes: - "pass2" expression => "pass1"; - "pass1"; - - pass2:: - "variable_defined" expression => returnszero("${result}","useshell"); - "copy" expression => returnszero("mv ${file}.augsave /var/rudder/modified-files/${cfile}_$(timestamp)_$(date)_cf_before_edit","useshell"), - if => fileexists("${file}.augsave"); - "augeas_binaries" expression => fileexists("${ncf_paths.path[augtool]}"); - - pass1:: - "file_defined" expression => not(strcmp("${file}","")); - - methods: - pass2.augeas_binaries.variable_defined:: + vars: + "old_class_prefix" string => canonify("file_augeas_set_${path}"); + "args" slist => {"${path}", "${value}", "${lens}","${file}"}; + "report_param" string => join("_", args); + "class_prefix" string => canonify("file_augeas_set_${report_param}"); + + "cpath" string => canonify("${path}"); + + pass1.file_defined:: + "command" string => "printf \"set /augeas/load/${lens}/lens \"${lens}.lns\" \n set /augeas/load/${lens}/incl \"${file}\" \n load \n set /files${path} ${value} \n save \n errors\" | ${ncf_paths.path[augtool]} --noautoload --new"; + "cfile" string => canonify("${file}"); + + pass1.!file_defined:: + "command" string => "printf \"set /files${path} ${value} \n save \" | ${ncf_paths.path[augtool]}"; + + pass1.augeas_binaries.!pass2:: + "output" string => execresult("${command}", "useshell"), comment => "${path}"; + + classes: + "pass3" expression => "pass2"; + "pass2" expression => "pass1"; + "pass1"; + + "should_report" expression => "${report_data.should_report}"; + + pass1:: + "augeas_binaries" expression => fileexists("${ncf_paths.path[augtool]}"); + "file_defined" expression => not(strcmp("${file}","")); + + pass2.augeas_binaries:: + "repaired" expression => regcmp("Saved.*", "${output}"); + # when there is an errors command + "kept" expression => regcmp(" *\(no errors\)", "${output}"); + # when there is no errors command + "kept" expression => regcmp(" *", "${output}"); + "error" expression => regcmp("error:.*", "${output}"); + # failsafe in case nothing matched + "error" expression => "!kept.!repaired"; + + pass3.augeas_binaries:: + "cp_ok" expression => "file_from_local_source_${cfile}_ok"; + "ok" expression => "!error", + if => "!file_defined"; + "ok" expression => "!error.(!repaired|cp_ok)", + if => "file_defined"; + + methods: + pass2:: + "disable_reporting_${class_prefix}" usebundle => disable_reporting; + # allows automatic backup in case file path was provided + "copy file" usebundle => file_from_local_source("${file}.augnew", "${file}"), + if => "file_defined.repaired"; + "remove" usebundle => file_absent("${file}.augnew"), + if => fileexists("${file}.augnew"); + "reenable_reporting_${class_prefix}" usebundle => enable_reporting, + if => "should_report"; + + pass3.augeas_binaries.ok.kept:: "success" usebundle => _classes_success("${old_class_prefix}"); "success" usebundle => _classes_success("${class_prefix}"); - "report" usebundle => _log("Setting the node value for ${path}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log("Setting the node value for ${path}", "${old_class_prefix}", "${class_prefix}", @{args}); + + pass3.augeas_binaries.ok.repaired:: + "repaired" usebundle => _classes_repaired("${old_class_prefix}"); + "repaired" usebundle => _classes_repaired("${class_prefix}"); + "report" usebundle => _log("Setting the node value for ${path}", "${old_class_prefix}", "${class_prefix}", @{args}); - pass2.augeas_binaries.!variable_defined:: + pass3.augeas_binaries.!ok:: "failure" usebundle => _classes_failure("${old_class_prefix}"); "failure" usebundle => _classes_failure("${class_prefix}"); - "report" usebundle => _log("Augeas binaries does exist, but your request has failed. Setting the node value for ${path}","${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log("Augeas binaries does exist, but your request has failed. Setting the node value for ${path}","${old_class_prefix}", "${class_prefix}", @{args}); - pass2.!augeas_binaries:: + pass3.!augeas_binaries:: "failure" usebundle => _classes_failure("${old_class_prefix}"); "failure" usebundle => _classes_failure("${class_prefix}"); - "report" usebundle => _log("Augeas binaries does not exist.", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log("Augeas binaries does not exist.", "${old_class_prefix}", "${class_prefix}", @{args}); + + reports: + info:: + "Augeas output: ${output}"; } diff --git a/tree/30_generic_methods/file_block_present.cf b/tree/30_generic_methods/file_block_present.cf index 85ba90930..31d75cfca 100644 --- a/tree/30_generic_methods/file_block_present.cf +++ b/tree/30_generic_methods/file_block_present.cf @@ -44,23 +44,25 @@ # orange # ``` # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter block Block(s) to add in the file # +# @parameter_name path file +# # @class_prefix file_block_present -# @class_parameter file +# @class_parameter path -bundle agent file_block_present(file, block) +bundle agent file_block_present(path, block) { vars: - "old_class_prefix" string => canonify("file_block_present_${file}"); - "args" slist => { "${file}", "${block}" }; + "old_class_prefix" string => canonify("file_block_present_${path}"); + "args" slist => { "${path}", "${block}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_block_present_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); files: - "${file}" + "${path}" create => "true", edit_line => ncf_insert_block("${block}"), edit_defaults => ncf_empty_select("false"), @@ -69,5 +71,5 @@ bundle agent file_block_present(file, block) methods: "sanitize" usebundle => _classes_sanitize("${class_prefix}"); "sanitize" usebundle => _classes_sanitize("${old_class_prefix}"); - "report" usebundle => _log_v3("Insert text block into ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Insert text block into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_block_present_in_section.cf b/tree/30_generic_methods/file_block_present_in_section.cf index 7b4874a10..00f063e3b 100644 --- a/tree/30_generic_methods/file_block_present_in_section.cf +++ b/tree/30_generic_methods/file_block_present_in_section.cf @@ -23,25 +23,27 @@ # * If the section exists, its content will be replaced if needed # * Otherwise it will be created at the end of the file # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter section_start Start of the section # @parameter section_end End of the section # @parameter block Block representing the content of the section # +# @parameter_name path file +# # @class_prefix file_block_present_in_section -# @class_parameter file +# @class_parameter path -bundle agent file_block_present_in_section(file, section_start, section_end, block) +bundle agent file_block_present_in_section(path, section_start, section_end, block) { vars: - "old_class_prefix" string => canonify("file_block_present_in_section_${file}"); - "args" slist => { "${file}", "${section_start}", "${section_end}", "${block}" }; + "old_class_prefix" string => canonify("file_block_present_in_section_${path}"); + "args" slist => { "${path}", "${section_start}", "${section_end}", "${block}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_block_present_in_section_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); files: - "${file}" + "${path}" create => "true", edit_line => ncf_ensure_section_content_type("${section_start}", "${section_end}", "${block}", "preserve_block"), edit_defaults => ncf_empty_select("false"), @@ -50,5 +52,5 @@ bundle agent file_block_present_in_section(file, section_start, section_end, blo methods: "sanitize" usebundle => _classes_sanitize("${class_prefix}"); "sanitize" usebundle => _classes_sanitize("${old_class_prefix}"); - "report" usebundle => _log_v3("Insert text block into ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Insert text block into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_check_FIFO_pipe.cf b/tree/30_generic_methods/file_check_FIFO_pipe.cf index c1b721c3c..04f77d138 100644 --- a/tree/30_generic_methods/file_check_FIFO_pipe.cf +++ b/tree/30_generic_methods/file_check_FIFO_pipe.cf @@ -19,20 +19,22 @@ # @name File check is FIFO/Pipe # @description Checks if a file exists and is a FIFO/Pipe -# @documentation This bundle will define a condition `file_check_FIFO_pipe_${file_name}_{ok, reached, kept}` if the -# file is a FIFO, or `file_check_FIFO_pipe_${file_name}_{not_ok, reached, not_kept, failed}` if +# @documentation This bundle will define a condition `file_check_FIFO_pipe_${path}_{ok, reached, kept}` if the +# file is a FIFO, or `file_check_FIFO_pipe_${path}_{not_ok, reached, not_kept, failed}` if # the file is not a fifo or does not exist # -# @parameter file_name File name (absolute path on the target node) +# @parameter path File name (absolute path on the target node) +# +# @parameter_name path file_name # # @class_prefix file_check_FIFO_pipe -# @class_parameter file_name +# @class_parameter path -bundle agent file_check_FIFO_pipe(file_name) +bundle agent file_check_FIFO_pipe(path) { methods: "file_exists" - usebundle => file_check_special("${file_name}", "FIFO/pipe"); + usebundle => file_check_special("${path}", "FIFO/pipe"); } diff --git a/tree/30_generic_methods/file_check_block_device.cf b/tree/30_generic_methods/file_check_block_device.cf index 8861b6987..cbe7c3de3 100644 --- a/tree/30_generic_methods/file_check_block_device.cf +++ b/tree/30_generic_methods/file_check_block_device.cf @@ -19,19 +19,21 @@ # @name File check if block device # @description Checks if a file exists and is a block device -# @documentation This bundle will define a condition `file_check_block_device_${file_name}_{ok, reached, kept}` if the -# file is a block_device, or `file_check_block_device_${file_name}_{not_ok, reached, not_kept, failed}` if +# @documentation This bundle will define a condition `file_check_block_device_${path}_{ok, reached, kept}` if the +# file is a block_device, or `file_check_block_device_${path}_{not_ok, reached, not_kept, failed}` if # the file is not a block device or does not exist # -# @parameter file_name File name (absolute path on the target node) +# @parameter path File name (absolute path on the target node) +# +# @parameter_name path file_name # # @class_prefix file_check_block_device -# @class_parameter file_name +# @class_parameter path -bundle agent file_check_block_device(file_name) +bundle agent file_check_block_device(path) { methods: "file_exists_and_is_block_device" - usebundle => file_check_special( "${file_name}", "block device"); + usebundle => file_check_special( "${path}", "block device"); } diff --git a/tree/30_generic_methods/file_check_character_device.cf b/tree/30_generic_methods/file_check_character_device.cf index 22f7f29d3..a0f4b496e 100644 --- a/tree/30_generic_methods/file_check_character_device.cf +++ b/tree/30_generic_methods/file_check_character_device.cf @@ -19,19 +19,21 @@ # @name File check if character device # @description Checks if a file exists and is a character device -# @documentation This bundle will define a condition `file_check_character_device_${file_name}_{ok, reached, kept}` if the -# file is a character device, or `file_check_character_device_${file_name}_{not_ok, reached, not_kept, failed}` if +# @documentation This bundle will define a condition `file_check_character_device_${path}_{ok, reached, kept}` if the +# file is a character device, or `file_check_character_device_${path}_{not_ok, reached, not_kept, failed}` if # the file is not a character device or does not exist # -# @parameter file_name File name (absolute path on the target node) -# +# @parameter path File name (absolute path on the target node) +# +# @parameter_name path file_name +# # @class_prefix file_check_character_device -# @class_parameter file_name +# @class_parameter path -bundle agent file_check_character_device(file_name) +bundle agent file_check_character_device(path) { methods: "file_exists_and_is_character_device" - usebundle => file_check_special( "${file_name}", "character device"); + usebundle => file_check_special( "${path}", "character device"); } diff --git a/tree/30_generic_methods/file_check_exists.cf b/tree/30_generic_methods/file_check_exists.cf index eb8ad3830..c4e245a95 100644 --- a/tree/30_generic_methods/file_check_exists.cf +++ b/tree/30_generic_methods/file_check_exists.cf @@ -18,26 +18,28 @@ # @name File check exists # @description Checks if a file exists -# @documentation This bundle will define a condition `file_check_exists_${file_name}_{ok, reached, kept}` if the -# file exists, or `file_check_exists_${file_name}_{not_ok, reached, not_kept, failed}` if +# @documentation This bundle will define a condition `file_check_exists_${path}_{ok, reached, kept}` if the +# file exists, or `file_check_exists_${path}_{not_ok, reached, not_kept, failed}` if # the file doesn't exists # -# @parameter file_name File name (absolute path on the target node) +# @parameter path File name (absolute path on the target node) +# +# @parameter_name path file_name # # @class_prefix file_check_exists -# @class_parameter file_name +# @class_parameter path -bundle agent file_check_exists(file_name) +bundle agent file_check_exists(path) { vars: - "old_class_prefix" string => canonify("file_check_exists_${file_name}"); - "args" slist => { "${file_name}" }; + "old_class_prefix" string => canonify("file_check_exists_${path}"); + "args" slist => { "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_check_exists_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); classes: - "file_exists" expression => fileexists("${file_name}"); + "file_exists" expression => fileexists("${path}"); methods: file_exists:: @@ -49,5 +51,5 @@ bundle agent file_check_exists(file_name) "file_dont_exists" usebundle => _classes_failure("${class_prefix}"); any:: - "report" usebundle => _log_v3("Check if ${file_name} exists", "${file_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Check if ${path} exists", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_check_hardlink.cf b/tree/30_generic_methods/file_check_hardlink.cf index 263aef9ce..11322cfd4 100644 --- a/tree/30_generic_methods/file_check_hardlink.cf +++ b/tree/30_generic_methods/file_check_hardlink.cf @@ -19,36 +19,39 @@ # @name File check is hardlink # @description Checks if two files are the same (hard links) -# @documentation This bundle will define a condition `file_check_hardlink_${file_name_1}_{ok, reached, kept}` if the -# two files `${file_name_1}` and `${file_name_2}` are hard links of each other, or `file_check_hardlink_${file_name_1}_{not_ok, reached, not_kept, failed}` if +# @documentation This bundle will define a condition `file_check_hardlink_${path}_{ok, reached, kept}` if the +# two files `${path}` and `${path_2}` are hard links of each other, or `file_check_hardlink_${path}_{not_ok, reached, not_kept, failed}` if # if the files are not hard links. # -# @parameter file_name_1 File name #1 (absolute path on the target node) -# @parameter file_name_2 File name #2 (absolute path on the target node) -# +# @parameter path File name #1 (absolute path on the target node) +# @parameter path_2 File name #2 (absolute path on the target node) +# +# @parameter_name path file_name_1 +# @parameter_name path_2 file_name_2 +# # @class_prefix file_check_hardlink -# @class_parameter file_name_1 +# @class_parameter path -bundle agent file_check_hardlink(file_name_1, file_name_2) +bundle agent file_check_hardlink(path, path_2) { vars: - "old_class_prefix" string => canonify("file_check_hardlink_${file_name_1}"); - "args" slist => { "${file_name_1}", "${file_name_2}" }; + "old_class_prefix" string => canonify("file_check_hardlink_${path}"); + "args" slist => { "${path}", "${path_2}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_check_hardlink_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "file_1_devno" string => filestat("${file_name_1}", "devno"); - "file_1_ino" string => filestat("${file_name_1}", "ino"); - "file_2_devno" string => filestat("${file_name_2}", "devno"); - "file_2_ino" string => filestat("${file_name_2}", "ino"); + "file_1_devno" string => filestat("${path}", "devno"); + "file_1_ino" string => filestat("${path}", "ino"); + "file_2_devno" string => filestat("${path_2}", "devno"); + "file_2_ino" string => filestat("${path_2}", "ino"); classes: - "file_1_exists" expression => fileexists("${file_name_1}"); - "file_2_exists" expression => fileexists("${file_name_2}"); + "file_1_exists" expression => fileexists("${path}"); + "file_2_exists" expression => fileexists("${path_2}"); "files_match_device" expression => strcmp("${file_1_devno}", "${file_2_devno}"); "files_match_inode" expression => strcmp("${file_1_ino}", "${file_2_ino}"); "files_are_hardlinks" expression => "file_1_exists.file_2_exists.files_match_device.files_match_inode"; @@ -69,5 +72,5 @@ bundle agent file_check_hardlink(file_name_1, file_name_2) any:: "report" - usebundle => _log_v3("Check if ${file_name_1} and ${file_name_2} are the same", "${file_name_1}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Check if ${path} and ${path_2} are the same", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_check_regular.cf b/tree/30_generic_methods/file_check_regular.cf index 39c9fd6d8..9cd19a60b 100644 --- a/tree/30_generic_methods/file_check_regular.cf +++ b/tree/30_generic_methods/file_check_regular.cf @@ -19,21 +19,23 @@ # @name File check if regular # @description Checks if a file exists and is a regular file -# @documentation This bundle will define a condition `file_check_regular_${file_name}_{ok, reached, kept}` if the -# file is a regular_file, or `file_check_regular_${file_name}_{not_ok, reached, not_kept, failed}` if +# @documentation This bundle will define a condition `file_check_regular_${path}_{ok, reached, kept}` if the +# file is a regular_file, or `file_check_regular_${path}_{not_ok, reached, not_kept, failed}` if # the file is not a regular file or does not exist # -# @parameter file_name File name (absolute path on the target node) +# @parameter path File name (absolute path on the target node) +# +# @parameter_name path file_name # # @class_prefix file_check_regular -# @class_parameter file_name +# @class_parameter path -bundle agent file_check_regular(file_name) +bundle agent file_check_regular(path) { vars: - "old_class_prefix" string => canonify("file_check_regular_${file_name}"); - "args" slist => { "${file_name}" }; + "old_class_prefix" string => canonify("file_check_regular_${path}"); + "args" slist => { "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_check_regular_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -41,7 +43,7 @@ bundle agent file_check_regular(file_name) classes: "file_exists_and_is_regular" - expression => isplain("${file_name}"); + expression => isplain("${path}"); methods: file_exists_and_is_regular:: @@ -58,5 +60,5 @@ bundle agent file_check_regular(file_name) any:: "report" - usebundle => _log_v3("Check if ${file_name} is a regular file", "${file_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Check if ${path} is a regular file", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_check_socket.cf b/tree/30_generic_methods/file_check_socket.cf index 074cd9c5e..e479295dc 100644 --- a/tree/30_generic_methods/file_check_socket.cf +++ b/tree/30_generic_methods/file_check_socket.cf @@ -19,19 +19,21 @@ # @name File check if socket # @description Checks if a file exists and is a socket -# @documentation This bundle will define a condition `file_check_socket_${file_name}_{ok, reached, kept}` if the -# file is a socket, or `file_check_socket_${file_name}_{not_ok, reached, not_kept, failed}` if +# @documentation This bundle will define a condition `file_check_socket_${path}_{ok, reached, kept}` if the +# file is a socket, or `file_check_socket_${path}_{not_ok, reached, not_kept, failed}` if # the file is not a socket or does not exist # -# @parameter file_name File name (absolute path on the target node) +# @parameter path File name (absolute path on the target node) +# +# @parameter_name path file_name # # @class_prefix file_check_socket -# @class_parameter file_name +# @class_parameter path -bundle agent file_check_socket(file_name) +bundle agent file_check_socket(path) { methods: "file_exists_and_is_socket" - usebundle => file_check_special( "${file_name}", "socket"); + usebundle => file_check_special( "${path}", "socket"); } diff --git a/tree/30_generic_methods/file_check_symlink.cf b/tree/30_generic_methods/file_check_symlink.cf index 37ecea60e..09ffe571b 100644 --- a/tree/30_generic_methods/file_check_symlink.cf +++ b/tree/30_generic_methods/file_check_symlink.cf @@ -19,27 +19,29 @@ # @name File check if symlink # @description Checks if a file exists and is a symlink -# @documentation This bundle will define a condition `file_check_symlink_${file_name}_{ok, reached, kept}` if the -# file is a symlink, or `file_check_symlink_${file_name}_{not_ok, reached, not_kept, failed}` if +# @documentation This bundle will define a condition `file_check_symlink_${path}_{ok, reached, kept}` if the +# file is a symlink, or `file_check_symlink_${path}_{not_ok, reached, not_kept, failed}` if # the file is not a symlink or does not exist # -# @parameter file_name File name (absolute path on the target node) +# @parameter path File name (absolute path on the target node) +# +# @parameter_name path file_name # # @class_prefix file_check_symlink -# @class_parameter file_name +# @class_parameter path -bundle agent file_check_symlink(file_name) +bundle agent file_check_symlink(path) { vars: - "old_class_prefix" string => canonify("file_check_symlink_${file_name}"); - "args" slist => { "${file_name}" }; + "old_class_prefix" string => canonify("file_check_symlink_${path}"); + "args" slist => { "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_check_symlink_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); classes: "file_exists_and_is_symlink" - expression => islink("${file_name}"); + expression => islink("${path}"); methods: file_exists_and_is_symlink:: @@ -56,5 +58,5 @@ bundle agent file_check_symlink(file_name) any:: "report" - usebundle => _log_v3("Check if ${file_name} is a symlink", "${file_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Check if ${path} is a symlink", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_check_symlinkto.cf b/tree/30_generic_methods/file_check_symlinkto.cf index 30cd14b09..8eeaea9b5 100644 --- a/tree/30_generic_methods/file_check_symlinkto.cf +++ b/tree/30_generic_methods/file_check_symlinkto.cf @@ -19,33 +19,35 @@ # @name File check is symlink to # @description Checks if first file is symlink to second file -# @documentation This bundle will define a condition `file_check_symlinkto_${target}_{ok, reached, kept}` if the file `${symlink}` +# @documentation This bundle will define a condition `file_check_symlinkto_${target}_{ok, reached, kept}` if the file `${path}` # is a symbolic link to `${target}`, or `file_check_symlinkto_${target}_{not_ok, reached, not_kept, failed}` if # if it is not a symbolic link, or any of the files does not exist. The symlink's path is resolved to the # absolute path and checked against the target file's path, which must also be an absolute path. # -# @parameter symlink Symbolic link (absolute path on the target node) +# @parameter path Symbolic link (absolute path on the target node) # @parameter target Target file (absolute path on the target node) +# +# @parameter_name path symlink # # @class_prefix file_check_symlinkto -# @class_parameter symlink +# @class_parameter path -bundle agent file_check_symlinkto(symlink, target) +bundle agent file_check_symlinkto(path, target) { vars: - "old_class_prefix" string => canonify("file_check_symlinkto_${symlink}"); - "args" slist => { "${symlink}", "${target}" }; + "old_class_prefix" string => canonify("file_check_symlinkto_${path}"); + "args" slist => { "${path}", "${target}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_check_symlinkto_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "real_path" string => execresult("/bin/readlink -f \"${symlink}\"", "noshell"); + "real_path" string => execresult("/bin/readlink -f \"${path}\"", "noshell"); classes: "file_exists" expression => fileexists("${target}"); "symlink_to_file" expression => strcmp("${real_path}", "${target}"); - "is_symlink" expression => islink("${symlink}"); + "is_symlink" expression => islink("${path}"); "is_ok" expression => "file_exists.is_symlink.symlink_to_file"; methods: @@ -62,6 +64,6 @@ bundle agent file_check_symlinkto(symlink, target) any:: "report" - usebundle => _log_v3("Check if ${symlink} points to ${target}", "${symlink}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Check if ${path} points to ${target}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_content.cf b/tree/30_generic_methods/file_content.cf index 77abeaf38..89d0d897d 100644 --- a/tree/30_generic_methods/file_content.cf +++ b/tree/30_generic_methods/file_content.cf @@ -56,17 +56,19 @@ # Alice # ``` # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter lines Line(s) to add in the file - if lines is a list, please use @{lines} to pass the iterator rather than iterating over each values # @parameter enforce Enforce the file to contain only line(s) defined (true or false) # +# @parameter_name path file +# # @class_prefix file_lines_present -# @class_parameter file +# @class_parameter path -bundle agent file_content(file, lines, enforce) +bundle agent file_content(path, lines, enforce) { vars: - "old_class_prefix" string => canonify("file_lines_present_${file}"); + "old_class_prefix" string => canonify("file_lines_present_${path}"); # We need to detect if lines is an iterator or a scalar !pass1:: @@ -78,10 +80,10 @@ bundle agent file_content(file, lines, enforce) "length_list" int => "0"; pass1.!islist:: - "args" slist => { "${file}", "${lines}", "${enforce}" }; + "args" slist => { "${path}", "${lines}", "${enforce}" }; pass1.islist:: - "args" slist => { "${file}", "@{lines}", "${enforce}" }; + "args" slist => { "${path}", "@{lines}", "${enforce}" }; pass1:: "report_param" string => join("_", args); @@ -99,14 +101,14 @@ bundle agent file_content(file, lines, enforce) files: pass2.!islist:: - "${file}" + "${path}" create => "true", edit_line => insert_lines("${lines}"), edit_defaults => ncf_empty_select("${enforce}"), classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); pass2.islist:: - "${file}" + "${path}" create => "true", edit_line => insert_lines("@{lines}"), # If it's a list, we don't want to iterate each time over the element edit_defaults => ncf_empty_select("${enforce}"), @@ -116,5 +118,5 @@ bundle agent file_content(file, lines, enforce) pass2:: "sanitize" usebundle => _classes_sanitize("${old_class_prefix}"); "sanitize" usebundle => _classes_sanitize("${class_prefix}"); - "report" usebundle => _log_v3("Insert content into ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Insert content into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_copy_from_local_source.cf b/tree/30_generic_methods/file_copy_from_local_source.cf index 99d1025e1..aa624adc2 100644 --- a/tree/30_generic_methods/file_copy_from_local_source.cf +++ b/tree/30_generic_methods/file_copy_from_local_source.cf @@ -22,17 +22,19 @@ # @description Ensure that a file or directory is copied from a local source # # @parameter source Source file (absolute path on the target node) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) +# +# @parameter_name path destination # # @class_prefix file_copy_from_local_source -# @class_parameter destination +# @class_parameter path -bundle agent file_copy_from_local_source(source, destination) +bundle agent file_copy_from_local_source(source, path) { vars: - "old_class_prefix" string => canonify("file_copy_from_local_source_${destination}"); + "old_class_prefix" string => canonify("file_copy_from_local_source_${path}"); - "args" slist => { "${source}", "${destination}" }; + "args" slist => { "${source}", "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_copy_from_local_source_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -47,11 +49,11 @@ bundle agent file_copy_from_local_source(source, destination) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "copy without recursion" usebundle => file_copy_from_local_source_recursion("${source}", "${destination}", "0"); + "copy without recursion" usebundle => file_copy_from_local_source_recursion("${source}", "${path}", "0"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Copying ${destination} from local ${source}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Copying ${path} from local ${source}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_copy_from_local_source_recursion.cf b/tree/30_generic_methods/file_copy_from_local_source_recursion.cf index 46291b3d7..ee298b3be 100644 --- a/tree/30_generic_methods/file_copy_from_local_source_recursion.cf +++ b/tree/30_generic_methods/file_copy_from_local_source_recursion.cf @@ -22,17 +22,19 @@ # @description Ensure that a file or directory is copied from a local source # # @parameter source Source file (absolute path on the target node) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) # @parameter recursion Recursion depth to enforce for this path (0, 1, 2, ..., inf) +# +# @parameter_name path destination # # @class_prefix file_copy_from_local_source -# @class_parameter destination +# @class_parameter path -bundle agent file_copy_from_local_source_recursion(source, destination, recursion) +bundle agent file_copy_from_local_source_recursion(source, path, recursion) { vars: - "old_class_prefix" string => canonify("file_copy_from_local_source_${destination}"); - "args" slist => { "${source}", "${destination}", "${recursion}" }; + "old_class_prefix" string => canonify("file_copy_from_local_source_${path}"); + "args" slist => { "${source}", "${path}", "${recursion}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_copy_from_local_source_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -40,7 +42,7 @@ bundle agent file_copy_from_local_source_recursion(source, destination, recursio "full_inner_class_prefix" string => canonify("file_from_local_source_${report_param}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); - "canonified_file" string => canonify("${destination}"); + "canonified_path" string => canonify("${path}"); classes: @@ -49,13 +51,13 @@ bundle agent file_copy_from_local_source_recursion(source, destination, recursio methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => file_from_local_source_recursion("${source}", "${destination}", "${recursion}"); + "action" usebundle => file_from_local_source_recursion("${source}", "${path}", "${recursion}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_from_local_source_${canonified_file}", "${old_class_prefix}"), - ifvarclass => "file_from_local_source_${canonified_file}_reached"; + "class copy" usebundle => _classes_copy("file_from_local_source_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "file_from_local_source_${canonified_path}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Copying ${destination} from local ${source}, recursion level ${recursion}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Copying ${path} from local ${source}, recursion level ${recursion}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_copy_from_local_source_with_check.cf b/tree/30_generic_methods/file_copy_from_local_source_with_check.cf index 2ad9e30b1..391f86952 100644 --- a/tree/30_generic_methods/file_copy_from_local_source_with_check.cf +++ b/tree/30_generic_methods/file_copy_from_local_source_with_check.cf @@ -23,21 +23,23 @@ # @description Ensure that a file or directory is copied from a local source if a check command succeeds # @documentation This method is a conditional file copy. # -# @parameter source Source file (absolute path on the target node) -# @parameter destination Destination file (absolute path on the target node) +# @parameter source Source file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) # @parameter check_command Command to run, it will get the source path as argument -# @parameter rc_ok Return codes to be considered as valid, separated by a comma (default is 0) -# @parameter_constraint rc_ok "allow_empty_string" : true +# @parameter rc_ok Return codes to be considered as valid, separated by a comma (default is 0) +# @parameter_constraint rc_ok "allow_empty_string" : true +# +# @parameter_name path destination # # @class_prefix file_copy_from_local_source_with_check -# @class_parameter destination +# @class_parameter path -bundle agent file_copy_from_local_source_with_check(source, destination, check_command, rc_ok) +bundle agent file_copy_from_local_source_with_check(source, path, check_command, rc_ok) { vars: - "old_class_prefix" string => canonify("file_copy_from_local_source_with_check_${destination}"); + "old_class_prefix" string => canonify("file_copy_from_local_source_with_check_${path}"); - "args" slist => { "${source}", "${destination}", "${check_command}", "${rc_ok}" }; + "args" slist => { "${source}", "${path}", "${check_command}", "${rc_ok}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_copy_from_local_source_with_check_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -45,7 +47,7 @@ bundle agent file_copy_from_local_source_with_check(source, destination, check_c "full_inner_class_prefix" string => canonify("file_from_local_source_with_check_${report_param}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); - "canonified_file" string => canonify("${destination}"); + "canonified_path" string => canonify("${path}"); classes: @@ -54,14 +56,14 @@ bundle agent file_copy_from_local_source_with_check(source, destination, check_c methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => file_from_local_source_with_check("${source}", "${destination}", "${check_command}", "${rc_ok}"); + "action" usebundle => file_from_local_source_with_check("${source}", "${path}", "${check_command}", "${rc_ok}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_from_local_source_with_check_${canonified_file}", "${old_class_prefix}"), - ifvarclass => "file_from_local_source_with_check_${canonified_file}_reached"; + "class copy" usebundle => _classes_copy("file_from_local_source_with_check_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "file_from_local_source_with_check_${canonified_path}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Copying ${destination} from local ${source} with check", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Copying ${path} from local ${source} with check", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_copy_from_remote_source.cf b/tree/30_generic_methods/file_copy_from_remote_source.cf index f649264d4..a03ae33f5 100644 --- a/tree/30_generic_methods/file_copy_from_remote_source.cf +++ b/tree/30_generic_methods/file_copy_from_remote_source.cf @@ -34,17 +34,19 @@ # ``` # # @parameter source Source file (absolute path on the policy server) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) +# +# @parameter_name path destination # # @class_prefix file_copy_from_remote_source -# @class_parameter destination +# @class_parameter path -bundle agent file_copy_from_remote_source(source, destination) +bundle agent file_copy_from_remote_source(source, path) { vars: - "old_class_prefix" string => canonify("file_copy_from_remote_source_${destination}"); + "old_class_prefix" string => canonify("file_copy_from_remote_source_${path}"); - "args" slist => { "${source}", "${destination}" }; + "args" slist => { "${source}", "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_copy_from_remote_source_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -60,12 +62,12 @@ bundle agent file_copy_from_remote_source(source, destination) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "copy without recursion" usebundle => file_copy_from_remote_source_recursion("${source}", "${destination}", "inf"); + "copy without recursion" usebundle => file_copy_from_remote_source_recursion("${source}", "${path}", "inf"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Copying ${destination} from remote ${source}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Copying ${path} from remote ${source}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_copy_from_remote_source_recursion.cf b/tree/30_generic_methods/file_copy_from_remote_source_recursion.cf index 5bd6a3cd3..2d69a959e 100644 --- a/tree/30_generic_methods/file_copy_from_remote_source_recursion.cf +++ b/tree/30_generic_methods/file_copy_from_remote_source_recursion.cf @@ -30,17 +30,19 @@ # ``` # # @parameter source Source file (absolute path on the policy server) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) # @parameter recursion Recursion depth to enforce for this path (0, 1, 2, ..., inf) +# +# @parameter_name path destination # # @class_prefix file_copy_from_remote_source -# @class_parameter destination +# @class_parameter path -bundle agent file_copy_from_remote_source_recursion(source, destination, recursion) +bundle agent file_copy_from_remote_source_recursion(source, path, recursion) { vars: - "old_class_prefix" string => canonify("file_copy_from_remote_source_${destination}"); - "args" slist => { "${source}", "${destination}", "${recursion}" }; + "old_class_prefix" string => canonify("file_copy_from_remote_source_${path}"); + "args" slist => { "${source}", "${path}", "${recursion}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_copy_from_remote_source_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -48,7 +50,7 @@ bundle agent file_copy_from_remote_source_recursion(source, destination, recursi "full_inner_class_prefix" string => canonify("file_from_remote_source_${report_param}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); - "canonified_file" string => canonify("${destination}"); + "canonified_path" string => canonify("${path}"); classes: @@ -57,14 +59,14 @@ bundle agent file_copy_from_remote_source_recursion(source, destination, recursi methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => file_from_remote_source_recursion("${source}", "${destination}", "${recursion}"); + "action" usebundle => file_from_remote_source_recursion("${source}", "${path}", "${recursion}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_from_remote_source_${canonified_file}", "${old_class_prefix}"), - ifvarclass => "file_from_remote_source_${canonified_file}_reached"; + "class copy" usebundle => _classes_copy("file_from_remote_source_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "file_from_remote_source_${canonified_path}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Copying ${destination} from remote ${source}, recursion level ${recursion}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Copying ${path} from remote ${source}, recursion level ${recursion}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_create.cf b/tree/30_generic_methods/file_create.cf index f70c909a5..db853fa80 100644 --- a/tree/30_generic_methods/file_create.cf +++ b/tree/30_generic_methods/file_create.cf @@ -21,17 +21,19 @@ # @deprecated Use [file_present](#_file_present) instead. # @description Create a file if it doesn't exist # -# @parameter target File to create (absolute path on the target node) +# @parameter path File to create (absolute path on the target node) +# +# @parameter_name path target # # @class_prefix file_create -# @class_parameter target +# @class_parameter path -bundle agent file_create(target) +bundle agent file_create(path) { vars: - "old_class_prefix" string => canonify("file_create_${target}"); + "old_class_prefix" string => canonify("file_create_${path}"); - "args" slist => { "${target}" }; + "args" slist => { "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_create_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -40,7 +42,7 @@ bundle agent file_create(target) "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); - "canonified_file" string => canonify("${target}"); + "canonified_path" string => canonify("${path}"); @@ -50,13 +52,13 @@ bundle agent file_create(target) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => file_present("${target}"); + "action" usebundle => file_present("${path}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_present_${canonified_file}", "${old_class_prefix}"), - ifvarclass => "file_present_${canonified_file}_reached"; + "class copy" usebundle => _classes_copy("file_present_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "file_present_${canonified_path}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Presence of file ${target}", "${target}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Presence of file ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_create_symlink.cf b/tree/30_generic_methods/file_create_symlink.cf index 340761b1b..2914ad4ee 100644 --- a/tree/30_generic_methods/file_create_symlink.cf +++ b/tree/30_generic_methods/file_create_symlink.cf @@ -22,18 +22,20 @@ # @description Create a symlink at a destination path and pointing to a source target except if a file or directory already exists. # # @parameter source Source file (absolute path on the target node) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) +# +# @parameter_name path destination # # @class_prefix file_create_symlink -# @class_parameter destination +# @class_parameter path -bundle agent file_create_symlink(source, destination) +bundle agent file_create_symlink(source, path) { vars: - "old_class_prefix" string => canonify("file_create_symlink_${destination}"); + "old_class_prefix" string => canonify("file_create_symlink_${path}"); - "args" slist => { "${source}", "${destination}" }; + "args" slist => { "${source}", "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_create_symlink_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -49,12 +51,12 @@ bundle agent file_create_symlink(source, destination) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "create without enforce" usebundle => file_create_symlink_enforce("${source}", "${destination}", "false"); + "create without enforce" usebundle => file_create_symlink_enforce("${source}", "${path}", "false"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Symlink ${destination} targeting ${source} (without overwrite)", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Symlink ${path} targeting ${source} (without overwrite)", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_create_symlink_enforce.cf b/tree/30_generic_methods/file_create_symlink_enforce.cf index cd064b7c5..9250cec3f 100644 --- a/tree/30_generic_methods/file_create_symlink_enforce.cf +++ b/tree/30_generic_methods/file_create_symlink_enforce.cf @@ -22,18 +22,20 @@ # @description Create a symlink at a destination path and pointing to a source target. This is also possible to enforce its creation # # @parameter source Source file (absolute path on the target node) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) # @parameter enforce Force symlink if file already exist (true or false) +# +# @parameter_name path destination # # @class_prefix file_create_symlink -# @class_parameter destination +# @class_parameter path -bundle agent file_create_symlink_enforce(source, destination, enforce) +bundle agent file_create_symlink_enforce(source, path, enforce) { vars: - "old_class_prefix" string => canonify("file_create_symlink_${destination}"); + "old_class_prefix" string => canonify("file_create_symlink_${path}"); - "args" slist => { "${source}", "${destination}", "${enforce}" }; + "args" slist => { "${source}", "${path}", "${enforce}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_create_symlink_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -41,7 +43,7 @@ bundle agent file_create_symlink_enforce(source, destination, enforce) "full_inner_class_prefix" string => canonify("file_symlink_present_${report_param}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); - "canonified_file" string => canonify("${destination}"); + "canonified_path" string => canonify("${path}"); classes: @@ -50,13 +52,13 @@ bundle agent file_create_symlink_enforce(source, destination, enforce) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => file_symlink_present_option("${source}", "${destination}", "${enforce}"); + "action" usebundle => file_symlink_present_option("${source}", "${path}", "${enforce}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_symlink_present_${canonified_file}", "${old_class_prefix}"), - ifvarclass => "file_symlink_present_${canonified_file}_reached"; + "class copy" usebundle => _classes_copy("file_symlink_present_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "file_symlink_present_${canonified_path}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Symlink ${destination} targeting ${source}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Symlink ${path} targeting ${source}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_create_symlink_force.cf b/tree/30_generic_methods/file_create_symlink_force.cf index 265ef2bf5..414e7a732 100644 --- a/tree/30_generic_methods/file_create_symlink_force.cf +++ b/tree/30_generic_methods/file_create_symlink_force.cf @@ -22,17 +22,19 @@ # @description Create a symlink at a destination path and pointing to a source target even if a file or directory already exists. # # @parameter source Source file (absolute path on the target node) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) +# +# @parameter_name path destination # # @class_prefix file_create_symlink -# @class_parameter destination +# @class_parameter path -bundle agent file_create_symlink_force(source, destination) +bundle agent file_create_symlink_force(source, path) { vars: - "old_class_prefix" string => canonify("file_create_symlink_${destination}"); + "old_class_prefix" string => canonify("file_create_symlink_${path}"); - "args" slist => { "${source}", "${destination}" }; + "args" slist => { "${source}", "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_create_symlink_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -47,12 +49,12 @@ bundle agent file_create_symlink_force(source, destination) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "create with enforce" usebundle => file_create_symlink_enforce("${source}", "${destination}", "true"); + "create with enforce" usebundle => file_create_symlink_enforce("${source}", "${path}", "true"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Symlink ${destination} targeting ${source} with forced overwrite", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Symlink ${path} targeting ${source} with forced overwrite", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_download.cf b/tree/30_generic_methods/file_download.cf index fa5c3746a..b5a603a7e 100644 --- a/tree/30_generic_methods/file_download.cf +++ b/tree/30_generic_methods/file_download.cf @@ -26,23 +26,25 @@ # It tries `curl` first, and `wget` as fallback. # # @parameter source URL to download from -# @parameter destination File destination (absolute path on the target node) +# @parameter path File destination (absolute path on the target node) +# +# @parameter_name path destination # # @class_prefix file_download -# @class_parameter destination +# @class_parameter path -bundle agent file_download(source, destination) +bundle agent file_download(source, path) { vars: any:: - "canonified_destination" string => canonify("${destination}"); + "canonified_path" string => canonify("${path}"); - "old_class_prefix" string => "file_download_${canonified_destination}"; + "old_class_prefix" string => "file_download_${canonified_path}"; - "args" slist => { "${source}", "${destination}" }; + "args" slist => { "${source}", "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_download_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -57,14 +59,14 @@ bundle agent file_download(source, destination) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => file_from_http_server("${source}", "${destination}"); + "action" usebundle => file_from_http_server("${source}", "${path}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_from_http_server_${canonified_destination}", "${old_class_prefix}"), - ifvarclass => "file_from_http_server_${canonified_destination}_reached"; + "class copy" usebundle => _classes_copy("file_from_http_server_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "file_from_http_server_${canonified_path}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Download ${source} into ${destination}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Download ${source} into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_enforce_content.cf b/tree/30_generic_methods/file_enforce_content.cf index c9d87c7d3..5208b085e 100644 --- a/tree/30_generic_methods/file_enforce_content.cf +++ b/tree/30_generic_methods/file_enforce_content.cf @@ -21,19 +21,21 @@ # @deprecated Use [file_content](#_file_content) instead. # @description Enforce the content of a file # -# @parameter file File name to edit (absolute path on the target node) -# @parameter lines Line(s) to add in the file - if lines is a list, please use @{lines} to pass the iterator rather than iterating over each values -# @parameter enforce Enforce the file to contain only line(s) defined (true or false) +# @parameter path File name to edit (absolute path on the target node) +# @parameter lines Line(s) to add in the file - if lines is a list, please use @{lines} to pass the iterator rather than iterating over each values +# @parameter enforce Enforce the file to contain only line(s) defined (true or false) +# +# @parameter_name path file # # @class_prefix file_ensure_lines_present -# @class_parameter file +# @class_parameter path -bundle agent file_enforce_content(file, lines, enforce) +bundle agent file_enforce_content(path, lines, enforce) { vars: - "canonified_file" string => canonify("${file}"); + "canonified_path" string => canonify("${path}"); - "old_class_prefix" string => canonify("file_ensure_lines_present_${file}"); + "old_class_prefix" string => canonify("file_ensure_lines_present_${path}"); # We need to detect if lines is an iterator or a scalar !pass1:: @@ -45,10 +47,10 @@ bundle agent file_enforce_content(file, lines, enforce) "length_list" int => "0"; pass1.!islist:: - "args" slist => { "${file}", "${lines}", "${enforce}" }; + "args" slist => { "${path}", "${lines}", "${enforce}" }; pass1.islist:: - "args" slist => { "${file}", "@{lines}", "${enforce}" }; + "args" slist => { "${path}", "@{lines}", "${enforce}" }; pass1:: "report_param" string => join("_", args); @@ -71,17 +73,17 @@ bundle agent file_enforce_content(file, lines, enforce) "disable_reporting_${class_prefix}" usebundle => disable_reporting; !islist.pass2:: - "action" usebundle => file_content("${file}", "${lines}", "${enforce}"); + "action" usebundle => file_content("${path}", "${lines}", "${enforce}"); islist.pass2:: - "action" usebundle => file_content("${file}", "@{lines}", "${enforce}"); + "action" usebundle => file_content("${path}", "@{lines}", "${enforce}"); pass2:: "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_lines_present_${canonified_file}", "${old_class_prefix}"), - ifvarclass => "file_lines_present_${canonified_file}_reached"; + "class copy" usebundle => _classes_copy("file_lines_present_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "file_lines_present_${canonified_path}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Insert content into ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Insert content into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_ensure_block_in_section.cf b/tree/30_generic_methods/file_ensure_block_in_section.cf index 04d7af79f..fb1bd8036 100644 --- a/tree/30_generic_methods/file_ensure_block_in_section.cf +++ b/tree/30_generic_methods/file_ensure_block_in_section.cf @@ -21,20 +21,22 @@ # @deprecated Use [file_block_present_in_section](#_file_block_present_in_section) instead. # @description Ensure that a section contains exactly a text block # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter section_start Start of the section # @parameter section_end End of the section # @parameter block Block representing the content of the section # +# @parameter_name path file +# # @class_prefix file_ensure_block_in_section -# @class_parameter file +# @class_parameter path -bundle agent file_ensure_block_in_section(file, section_start, section_end, block) +bundle agent file_ensure_block_in_section(path, section_start, section_end, block) { vars: - "old_class_prefix" string => canonify("file_ensure_block_in_section_${file}"); + "old_class_prefix" string => canonify("file_ensure_block_in_section_${path}"); - "args" slist => { "${file}", "${section_start}", "${section_end}", "${block}" }; + "args" slist => { "${path}", "${section_start}", "${section_end}", "${block}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_ensure_block_in_section_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -42,7 +44,7 @@ bundle agent file_ensure_block_in_section(file, section_start, section_end, bloc "full_inner_class_prefix" string => canonify("file_block_present_in_section_${report_param}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); - "canonified_file" string => canonify("${file}"); + "canonified_path" string => canonify("${path}"); classes: @@ -51,13 +53,13 @@ bundle agent file_ensure_block_in_section(file, section_start, section_end, bloc methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => file_block_present_in_section("${file}", "${section_start}", "${section_end}", "${block}"); + "action" usebundle => file_block_present_in_section("${path}", "${section_start}", "${section_end}", "${block}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_block_present_in_section_${canonified_file}", "${old_class_prefix}"), - ifvarclass => "file_block_present_in_section_${canonified_file}_reached"; + "class copy" usebundle => _classes_copy("file_block_present_in_section_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "file_block_present_in_section_${canonified_path}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Insert text block into ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Insert text block into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_ensure_block_present.cf b/tree/30_generic_methods/file_ensure_block_present.cf index d02fec45f..63674ffd8 100644 --- a/tree/30_generic_methods/file_ensure_block_present.cf +++ b/tree/30_generic_methods/file_ensure_block_present.cf @@ -21,18 +21,20 @@ # @deprecated Use [file_block_present](#_file_block_present) instead. # @description Ensure that a text block is present in a specific location # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter block Block(s) to add in the file # +# @parameter_name path file +# # @class_prefix file_ensure_block_present -# @class_parameter file +# @class_parameter path -bundle agent file_ensure_block_present(file, block) +bundle agent file_ensure_block_present(path, block) { vars: - "old_class_prefix" string => canonify("file_ensure_block_present_${file}"); + "old_class_prefix" string => canonify("file_ensure_block_present_${path}"); - "args" slist => { "${file}", "${block}" }; + "args" slist => { "${path}", "${block}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_ensure_block_present_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -40,7 +42,7 @@ bundle agent file_ensure_block_present(file, block) "full_inner_class_prefix" string => canonify("file_block_present_${report_param}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); - "canonified_file" string => canonify("${file}"); + "canonified_path" string => canonify("${path}"); classes: @@ -49,13 +51,13 @@ bundle agent file_ensure_block_present(file, block) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => file_block_present("${file}", "${block}"); + "action" usebundle => file_block_present("${path}", "${block}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_block_present_${canonified_file}", "${old_class_prefix}"), - ifvarclass => "file_block_present_${canonified_file}_reached"; + "class copy" usebundle => _classes_copy("file_block_present_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "file_block_present_${canonified_path}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Insert text block into ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Insert text block into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_ensure_key_value.cf b/tree/30_generic_methods/file_ensure_key_value.cf index 524e0d26d..8f953b250 100644 --- a/tree/30_generic_methods/file_ensure_key_value.cf +++ b/tree/30_generic_methods/file_ensure_key_value.cf @@ -23,17 +23,19 @@ # @documentation Edit (or create) the file, and ensure it contains an entry key -> value with arbitrary separator between the key and its value. # If the key is already present, the method will change the value associated with this key. # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter key Key to define # @parameter value Value to define # @parameter separator Separator between key and value, for example "=" or " " (without the quotes) # @parameter_constraint separator "allow_whitespace_string" : true # +# @parameter_name path file +# # @class_prefix file_ensure_key_value -# @class_parameter file +# @class_parameter path -bundle agent file_ensure_key_value(file, key, value, separator) +bundle agent file_ensure_key_value(path, key, value, separator) { methods: - "action" usebundle => file_ensure_key_value_option("${file}", "${key}", "${value}", "${separator}", "lax"); + "action" usebundle => file_ensure_key_value_option("${path}", "${key}", "${value}", "${separator}", "lax"); } diff --git a/tree/30_generic_methods/file_ensure_key_value_option.cf b/tree/30_generic_methods/file_ensure_key_value_option.cf index 3e9b70d55..9d08b024c 100644 --- a/tree/30_generic_methods/file_ensure_key_value_option.cf +++ b/tree/30_generic_methods/file_ensure_key_value_option.cf @@ -23,7 +23,7 @@ # @documentation Edit (or create) the file, and ensure it contains an entry key -> value with arbitrary separator between the key and its value. # If the key is already present, the method will change the value associated with this key. # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter key Key to define # @parameter value Value to define # @parameter option Option for the spacing around the separator: strict, which prevent spacing (space or tabs) around separators, or lax which accepts any number of spaces around separators @@ -31,14 +31,16 @@ # @parameter_constraint separator "allow_whitespace_string" : true # @parameter_constraint option "select" : [ "strict", "lax" ] # +# @parameter_name path file +# # @class_prefix file_ensure_key_value -# @class_parameter file +# @class_parameter path -bundle agent file_ensure_key_value_option(file, key, value, separator, option) +bundle agent file_ensure_key_value_option(path, key, value, separator, option) { vars: - "old_class_prefix" string => canonify("file_ensure_key_value_${file}"); - "args" slist => { "${file}", "${key}", "${value}","${separator}", "${option}" }; + "old_class_prefix" string => canonify("file_ensure_key_value_${path}"); + "args" slist => { "${path}", "${key}", "${value}","${separator}", "${option}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_ensure_key_value_${report_param}"); @@ -52,12 +54,12 @@ bundle agent file_ensure_key_value_option(file, key, value, separator, option) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => file_key_value_present_option("${file}", "${key}", "${value}","${separator}", "${option}"); + "action" usebundle => file_key_value_present_option("${path}", "${key}", "${value}","${separator}", "${option}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "class copy" usebundle => _classes_copy("${inner_class_prefix}", "${old_class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Ensure line in format key${separator}value in ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Ensure line in format key${separator}value in ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_ensure_key_value_parameter_in_list.cf b/tree/30_generic_methods/file_ensure_key_value_parameter_in_list.cf index 9d48dc635..4aa2b81e7 100644 --- a/tree/30_generic_methods/file_ensure_key_value_parameter_in_list.cf +++ b/tree/30_generic_methods/file_ensure_key_value_parameter_in_list.cf @@ -39,7 +39,7 @@ # file_ensure_key_value_parameter_in_list("/etc/default/grub", "GRUB_CMDLINE", "=", "dom0_max_vcpus=32", " ", "\"", "\""); # ``` # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter key Full key name # @parameter key_value_separator character used to separate key and value in a key-value line # @parameter parameter String representing the sub-value to ensure is present in the list of parameters that form the value part of that line @@ -51,15 +51,17 @@ # @parameter_constraint leading_char_separator "allow_empty_string" : true # @parameter_constraint closing_char_separator "allow_empty_string" : true # +# @parameter_name path file +# # @class_prefix file_ensure_key_value_parameter_in_list -# @class_parameter file +# @class_parameter path -bundle agent file_ensure_key_value_parameter_in_list(file, key, key_value_separator, parameter, parameter_separator, leading_char_separator, closing_char_separator) +bundle agent file_ensure_key_value_parameter_in_list(path, key, key_value_separator, parameter, parameter_separator, leading_char_separator, closing_char_separator) { vars: - "old_class_prefix" string => canonify("file_ensure_key_value_parameter_in_list_${file}"); + "old_class_prefix" string => canonify("file_ensure_key_value_parameter_in_list_${path}"); - "args" slist => { "${file}", "${key}", "${key_value_separator}", "${parameter}", "${parameter_separator}", "${leading_char_separator}", "${closing_char_separator}" }; + "args" slist => { "${path}", "${key}", "${key_value_separator}", "${parameter}", "${parameter_separator}", "${leading_char_separator}", "${closing_char_separator}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_ensure_key_value_parameter_in_list_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -68,7 +70,7 @@ bundle agent file_ensure_key_value_parameter_in_list(file, key, key_value_separa "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); - "canonified_file" string => canonify("${file}"); + "canonified_path" string => canonify("${path}"); classes: @@ -77,13 +79,13 @@ bundle agent file_ensure_key_value_parameter_in_list(file, key, key_value_separa methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => file_key_value_parameter_present_in_list("${file}", "${key}", "${key_value_separator}", "${parameter_regex}", "${parameter_separator}", "${leading_char_separator}", "${closing_char_separator}"); + "action" usebundle => file_key_value_parameter_present_in_list("${path}", "${key}", "${key_value_separator}", "${parameter_regex}", "${parameter_separator}", "${leading_char_separator}", "${closing_char_separator}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_key_value_parameter_present_in_list_${canonified_file}", "${old_class_prefix}"), - ifvarclass => "file_key_value_parameter_present_in_list_${canonified_file}_reached"; + "class copy" usebundle => _classes_copy("file_key_value_parameter_present_in_list_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "file_key_value_parameter_present_in_list_${canonified_path}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Ensure parameters in line ${key}${key_value_separator} values in ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Ensure parameters in line ${key}${key_value_separator} values in ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_ensure_key_value_parameter_not_in_list.cf b/tree/30_generic_methods/file_ensure_key_value_parameter_not_in_list.cf index f98c44930..e371ace76 100644 --- a/tree/30_generic_methods/file_ensure_key_value_parameter_not_in_list.cf +++ b/tree/30_generic_methods/file_ensure_key_value_parameter_not_in_list.cf @@ -38,7 +38,7 @@ # file_ensure_key_value_parameter_not_in_list("/etc/default/grub", "GRUB_CMDLINE", "=", "dom0_max_vcpus=32", " ", "\"", "\""); # ``` # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter key Full key name # @parameter key_value_separator character used to separate key and value in a key-value line # @parameter parameter_regex Regular expression matching the sub-value to ensure is not present in the list of parameters that form the value part of that line @@ -50,15 +50,17 @@ # @parameter_constraint leading_char_separator "allow_empty_string" : true # @parameter_constraint closing_char_separator "allow_empty_string" : true # +# @parameter_name path file +# # @class_prefix file_ensure_key_value_parameter_not_in_list -# @class_parameter file +# @class_parameter path -bundle agent file_ensure_key_value_parameter_not_in_list(file, key, key_value_separator, parameter_regex, parameter_separator, leading_char_separator, closing_char_separator) +bundle agent file_ensure_key_value_parameter_not_in_list(path, key, key_value_separator, parameter_regex, parameter_separator, leading_char_separator, closing_char_separator) { vars: - "old_class_prefix" string => canonify("file_ensure_key_value_parameter_not_in_list_${file}"); + "old_class_prefix" string => canonify("file_ensure_key_value_parameter_not_in_list_${path}"); - "args" slist => { "${file}", "${key}", "${key_value_separator}", "${parameter_regex}", "${parameter_separator}", "${leading_char_separator}", "${closing_char_separator}" }; + "args" slist => { "${path}", "${key}", "${key_value_separator}", "${parameter_regex}", "${parameter_separator}", "${leading_char_separator}", "${closing_char_separator}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_ensure_key_value_parameter_not_in_list_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -67,7 +69,7 @@ bundle agent file_ensure_key_value_parameter_not_in_list(file, key, key_value_se "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); - "canonified_file" string => canonify("${file}"); + "canonified_path" string => canonify("${path}"); classes: @@ -76,12 +78,12 @@ bundle agent file_ensure_key_value_parameter_not_in_list(file, key, key_value_se methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => file_key_value_parameter_absent_in_list("${file}", "${key}", "${key_value_separator}", "${parameter_regex}", "${parameter_separator}", "${leading_char_separator}", "${closing_char_separator}"); + "action" usebundle => file_key_value_parameter_absent_in_list("${path}", "${key}", "${key_value_separator}", "${parameter_regex}", "${parameter_separator}", "${leading_char_separator}", "${closing_char_separator}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_key_value_parameter_absent_in_list_${canonified_file}", "${old_class_prefix}"), - ifvarclass => "file_key_value_parameter_absent_in_list_${canonified_file}_reached"; + "class copy" usebundle => _classes_copy("file_key_value_parameter_absent_in_list_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "file_key_value_parameter_absent_in_list_${canonified_path}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Ensure parameter not in line ${key}${key_value_separator} values in ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Ensure parameter not in line ${key}${key_value_separator} values in ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_ensure_key_value_present_in_ini_section.cf b/tree/30_generic_methods/file_ensure_key_value_present_in_ini_section.cf index 12e3081da..191c2e0be 100644 --- a/tree/30_generic_methods/file_ensure_key_value_present_in_ini_section.cf +++ b/tree/30_generic_methods/file_ensure_key_value_present_in_ini_section.cf @@ -21,20 +21,22 @@ # @deprecated Use [file_key_value_present_in_ini_section](#_file_key_value_present_in_ini_section) instead. # @description Ensure that a key-value pair is present in a section in a specific location. The objective of this method is to handle INI-style files. # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter section Name of the INI-style section under which the line should be added or modified (not including the [] brackets) # @parameter name Name of the key to add or edit # @parameter value Value of the key to add or edit # +# @parameter_name path file +# # @class_prefix file_ensure_key_value_present_in_ini_section -# @class_parameter file +# @class_parameter path -bundle agent file_ensure_key_value_present_in_ini_section(file, section, name, value) +bundle agent file_ensure_key_value_present_in_ini_section(path, section, name, value) { vars: - "old_class_prefix" string => canonify("file_ensure_key_value_present_in_ini_section_${file}"); + "old_class_prefix" string => canonify("file_ensure_key_value_present_in_ini_section_${path}"); - "args" slist => { "${file}", "${section}", "${name}", "${value}" }; + "args" slist => { "${path}", "${section}", "${name}", "${value}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_ensure_key_value_present_in_ini_section_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -42,7 +44,7 @@ bundle agent file_ensure_key_value_present_in_ini_section(file, section, name, v "full_inner_class_prefix" string => canonify("file_key_value_present_in_ini_section_${report_param}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); - "canonified_file" string => canonify("${file}"); + "canonified_path" string => canonify("${path}"); classes: "should_report" expression => "${report_data.should_report}"; @@ -50,14 +52,14 @@ bundle agent file_ensure_key_value_present_in_ini_section(file, section, name, v methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => file_key_value_present_in_ini_section("${file}", "${section}", "${name}", "${value}"); + "action" usebundle => file_key_value_present_in_ini_section("${path}", "${section}", "${name}", "${value}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_key_value_present_in_ini_section_${canonified_file}", "${old_class_prefix}"), - ifvarclass => "file_key_value_present_in_ini_section_${canonified_file}_reached"; + "class copy" usebundle => _classes_copy("file_key_value_present_in_ini_section_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "file_key_value_present_in_ini_section_${canonified_path}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Set value for key in section ${section} into ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Set value for key in section ${section} into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_ensure_keys_values.cf b/tree/30_generic_methods/file_ensure_keys_values.cf index 341899183..afc1973ba 100644 --- a/tree/30_generic_methods/file_ensure_keys_values.cf +++ b/tree/30_generic_methods/file_ensure_keys_values.cf @@ -73,20 +73,22 @@ # key2 = value2 # ``` # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter keys Name of the dict structure (without "${}") containing the keys (keys of the dict), and values to define (values of the dict) # @parameter separator Separator between key and value, for example "=" or " " (without the quotes) # @parameter_constraint separator "allow_whitespace_string" : true # +# @parameter_name path file +# # @class_prefix file_ensure_keys_values -# @class_parameter file +# @class_parameter path -bundle agent file_ensure_keys_values(file, keys, separator) +bundle agent file_ensure_keys_values(path, keys, separator) { vars: - "old_class_prefix" string => canonify("file_ensure_keys_values_${file}"); + "old_class_prefix" string => canonify("file_ensure_keys_values_${path}"); - "args" slist => { "${file}", "${keys}", "${separator}" }; + "args" slist => { "${path}", "${keys}", "${separator}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_ensure_keys_values_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -95,7 +97,7 @@ bundle agent file_ensure_keys_values(file, keys, separator) "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); - "canonified_file" string => canonify("${file}"); + "canonified_path" string => canonify("${path}"); classes: @@ -104,13 +106,13 @@ bundle agent file_ensure_keys_values(file, keys, separator) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => file_keys_values_present("${file}", "${keys}", "${separator}"); + "action" usebundle => file_keys_values_present("${path}", "${keys}", "${separator}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_keys_values_present_${canonified_file}", "${old_class_prefix}"), - ifvarclass => "file_keys_values_present_${canonified_file}_reached"; + "class copy" usebundle => _classes_copy("file_keys_values_present_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "file_keys_values_present_${canonified_path}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Ensure lines in format key${separator}values into ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Ensure lines in format key${separator}values into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_ensure_line_present_in_ini_section.cf b/tree/30_generic_methods/file_ensure_line_present_in_ini_section.cf index eb51ffc9e..2d04fa85d 100644 --- a/tree/30_generic_methods/file_ensure_line_present_in_ini_section.cf +++ b/tree/30_generic_methods/file_ensure_line_present_in_ini_section.cf @@ -21,19 +21,21 @@ # @deprecated Use [file_line_present_in_ini_section](#_file_line_present_in_ini_section) instead. # @description Ensure that a line is present in a section in a specific location. The objective of this method is to handle INI-style files. # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter section Name of the INI-style section under which lines should be added (not including the [] brackets) # @parameter line Line to ensure is present inside the section # +# @parameter_name path file +# # @class_prefix file_ensure_line_present_in_ini_section -# @class_parameter file +# @class_parameter path -bundle agent file_ensure_line_present_in_ini_section(file, section, line) +bundle agent file_ensure_line_present_in_ini_section(path, section, line) { vars: - "old_class_prefix" string => canonify("file_ensure_line_present_in_ini_section_${file}"); + "old_class_prefix" string => canonify("file_ensure_line_present_in_ini_section_${path}"); - "args" slist => { "${file}", "${section}", "${line}" }; + "args" slist => { "${path}", "${section}", "${line}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_ensure_line_present_in_ini_section_${report_param}"); @@ -42,7 +44,7 @@ bundle agent file_ensure_line_present_in_ini_section(file, section, line) "full_inner_class_prefix" string => canonify("file_line_present_in_ini_section_${report_param}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); - "canonified_file" string => canonify("${file}"); + "canonified_path" string => canonify("${path}"); classes: @@ -51,13 +53,13 @@ bundle agent file_ensure_line_present_in_ini_section(file, section, line) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => file_line_present_in_ini_section("${file}", "${section}", "${line}"); + "action" usebundle => file_line_present_in_ini_section("${path}", "${section}", "${line}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_line_present_in_ini_section_${canonified_file}", "${old_class_prefix}"), - ifvarclass => "file_line_present_in_ini_section_${canonified_file}_reached"; + "class copy" usebundle => _classes_copy("file_line_present_in_ini_section_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "file_line_present_in_ini_section_${canonified_path}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Insert line(s) into ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Insert line(s) into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_ensure_line_present_in_xml_tag.cf b/tree/30_generic_methods/file_ensure_line_present_in_xml_tag.cf index cd73d85f1..05331aba2 100644 --- a/tree/30_generic_methods/file_ensure_line_present_in_xml_tag.cf +++ b/tree/30_generic_methods/file_ensure_line_present_in_xml_tag.cf @@ -21,18 +21,20 @@ # @deprecated Use [file_line_present_in_xml_tag](#_file_line_present_in_xml_tag) instead. # @description Ensure that a line is present in a tag in a specific location. The objective of this method is to handle XML-style files. Note that if the tag is not present in the file, it won't be added, and the edition will fail. # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter tag Name of the XML tag under which lines should be added (not including the <> brackets) # @parameter line Line to ensure is present inside the section # +# @parameter_name path file +# # @class_prefix file_ensure_line_present_in_xml_tag -# @class_parameter file +# @class_parameter path -bundle agent file_ensure_line_present_in_xml_tag(file, tag, line) +bundle agent file_ensure_line_present_in_xml_tag(path, tag, line) { vars: - "old_class_prefix" string => canonify("file_ensure_line_present_in_xml_tag_${file}"); - "args" slist => { "${file}", "${tag}", "${line}" }; + "old_class_prefix" string => canonify("file_ensure_line_present_in_xml_tag_${path}"); + "args" slist => { "${path}", "${tag}", "${line}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_ensure_line_present_in_xml_tag_${report_param}"); @@ -41,7 +43,7 @@ bundle agent file_ensure_line_present_in_xml_tag(file, tag, line) "full_inner_class_prefix" string => canonify("file_line_present_in_xml_tag_${report_param}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); - "canonified_file" string => canonify("${file}"); + "canonified_path" string => canonify("${path}"); @@ -51,13 +53,13 @@ bundle agent file_ensure_line_present_in_xml_tag(file, tag, line) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => file_line_present_in_xml_tag("${file}", "${tag}", "${line}"); + "action" usebundle => file_line_present_in_xml_tag("${path}", "${tag}", "${line}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_line_present_in_xml_tag_${canonified_file}", "${old_class_prefix}"), - ifvarclass => "file_line_present_in_xml_tag_${canonified_file}_reached"; + "class copy" usebundle => _classes_copy("file_line_present_in_xml_tag_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "file_line_present_in_xml_tag_${canonified_path}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Insert line(s) into ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Insert line(s) into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_ensure_lines_absent.cf b/tree/30_generic_methods/file_ensure_lines_absent.cf index 9d2596a79..72d97267d 100644 --- a/tree/30_generic_methods/file_ensure_lines_absent.cf +++ b/tree/30_generic_methods/file_ensure_lines_absent.cf @@ -21,18 +21,20 @@ # @deprecated Use [file_lines_absent](#_file_lines_absent) instead. # @description Ensure that a line is absent in a specific location # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter lines Line(s) to remove in the file # +# @parameter_name path file +# # @class_prefix file_ensure_lines_absent -# @class_parameter file +# @class_parameter path -bundle agent file_ensure_lines_absent(file, lines) +bundle agent file_ensure_lines_absent(path, lines) { vars: - "old_class_prefix" string => canonify("file_ensure_lines_absent_${file}"); + "old_class_prefix" string => canonify("file_ensure_lines_absent_${path}"); - "args" slist => { "${file}", "${lines}" }; + "args" slist => { "${path}", "${lines}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_ensure_lines_absent_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -40,7 +42,7 @@ bundle agent file_ensure_lines_absent(file, lines) "full_inner_class_prefix" string => canonify("file_lines_absent_${report_param}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); - "canonified_file" string => canonify("${file}"); + "canonified_path" string => canonify("${path}"); classes: @@ -49,14 +51,14 @@ bundle agent file_ensure_lines_absent(file, lines) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => file_lines_absent("${file}", "${lines}"); + "action" usebundle => file_lines_absent("${path}", "${lines}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_lines_absent_${canonified_file}", "${old_class_prefix}"), - ifvarclass => "file_lines_absent_${canonified_file}_reached"; + "class copy" usebundle => _classes_copy("file_lines_absent_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "file_lines_absent_${canonified_path}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Ensure line(s) absent from ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Ensure line(s) absent from ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_ensure_lines_present.cf b/tree/30_generic_methods/file_ensure_lines_present.cf index 8f65bc661..1f2081faa 100644 --- a/tree/30_generic_methods/file_ensure_lines_present.cf +++ b/tree/30_generic_methods/file_ensure_lines_present.cf @@ -21,18 +21,20 @@ # @deprecated Use [file_lines_present](#_file_lines_present) instead. # @description Ensure that one or more lines are present in a file # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter lines Line(s) to add in the file +# +# @parameter_name path file # # @class_prefix file_ensure_lines_present -# @class_parameter file +# @class_parameter path -bundle agent file_ensure_lines_present(file, lines) +bundle agent file_ensure_lines_present(path, lines) { vars: - "old_class_prefix" string => canonify("file_ensure_lines_present_${file}"); + "old_class_prefix" string => canonify("file_ensure_lines_present_${path}"); - "args" slist => { "${file}", "${lines}" }; + "args" slist => { "${path}", "${lines}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_ensure_lines_present_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -48,12 +50,12 @@ bundle agent file_ensure_lines_present(file, lines) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "enforce lines content" usebundle => file_enforce_content("${file}", "${lines}", "false"); + "enforce lines content" usebundle => file_enforce_content("${path}", "${lines}", "false"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Append content if needed into ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Append content if needed into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_from_http_server.cf b/tree/30_generic_methods/file_from_http_server.cf index f6e76c448..9a13e0f66 100644 --- a/tree/30_generic_methods/file_from_http_server.cf +++ b/tree/30_generic_methods/file_from_http_server.cf @@ -26,31 +26,33 @@ # It tries `curl` first, and `wget` as fallback. # # @parameter source URL to download from -# @parameter destination File destination (absolute path on the target node) +# @parameter path File destination (absolute path on the target node) +# +# @parameter_name path destination # # @class_prefix file_from_http_server -# @class_parameter destination +# @class_parameter path -bundle agent file_from_http_server(source, destination) +bundle agent file_from_http_server(source, path) { vars: _ncf_path_exists_curl:: - "action_command" string => "${ncf_paths.path[curl]} -f -s -L -o ${destination} ${source}"; + "action_command" string => "${ncf_paths.path[curl]} -f -s -L -o ${path} ${source}"; !_ncf_path_exists_curl._stdlib_path_exists_wget:: - "action_command" string => "${paths.path[wget]} -O ${destination} ${source}"; + "action_command" string => "${paths.path[wget]} -O ${path} ${source}"; any:: - "canonified_destination" string => canonify("${destination}"); + "canonified_path" string => canonify("${path}"); "canonified_action_command" string => canonify("${action_command}"); - "old_class_prefix" string => "file_from_http_server_${canonified_destination}"; - "args" slist => { "${source}", "${destination}" }; + "old_class_prefix" string => "file_from_http_server_${canonified_path}"; + "args" slist => { "${source}", "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_from_http_server_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -58,7 +60,7 @@ bundle agent file_from_http_server(source, destination) classes: - "file_exists" expression => fileexists("${destination}"); + "file_exists" expression => fileexists("${path}"); "should_report" expression => "${report_data.should_report}"; @@ -80,14 +82,14 @@ bundle agent file_from_http_server(source, destination) "new result classes" usebundle => _classes_copy("command_execution_${canonified_action_command}", "${class_prefix}"); - "report" usebundle => _log_v3("Download ${source} into ${destination}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}), + "report" usebundle => _log_v3("Download ${source} into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}), ifvarclass => "${class_prefix}_reached"; !_ncf_path_exists_curl.!_stdlib_path_exists_wget.!file_exists:: "force_failure_class" usebundle => _classes_failure("${old_class_prefix}"); "new result classes" usebundle => _classes_failure("${class_prefix}"); - "report" usebundle => _log_v3("Unable to download ${source}: neither wget or curl are installed", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Unable to download ${source}: neither wget or curl are installed", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); file_exists:: @@ -95,7 +97,7 @@ bundle agent file_from_http_server(source, destination) ifvarclass => "!command_execution_${canonified_action_command}_repaired"; "new result classes" usebundle => _classes_success("${class_prefix}"), ifvarclass => "!${class_prefix}_action_repaired"; - "report" usebundle => _log_v3("File ${destination} already downloaded", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}), + "report" usebundle => _log_v3("File ${path} already downloaded", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}), ifvarclass => "!command_execution_${canonified_action_command}_repaired"; } diff --git a/tree/30_generic_methods/file_from_local_source.cf b/tree/30_generic_methods/file_from_local_source.cf index 399398feb..3e0e59103 100644 --- a/tree/30_generic_methods/file_from_local_source.cf +++ b/tree/30_generic_methods/file_from_local_source.cf @@ -23,17 +23,19 @@ # source, use the *File from local source recursion* method. # # @parameter source Source file (absolute path on the target node) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) +# +# @parameter_name path destination # # @class_prefix file_from_local_source -# @class_parameter destination +# @class_parameter path -bundle agent file_from_local_source(source, destination) +bundle agent file_from_local_source(source, path) { vars: - "old_class_prefix" string => canonify("file_from_local_source_${destination}"); + "old_class_prefix" string => canonify("file_from_local_source_${path}"); - "args" slist => { "${source}", "${destination}" }; + "args" slist => { "${source}", "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_from_local_source_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -47,11 +49,11 @@ bundle agent file_from_local_source(source, destination) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "copy without recursion" usebundle => file_from_local_source_recursion("${source}", "${destination}", "0"); + "copy without recursion" usebundle => file_from_local_source_recursion("${source}", "${path}", "0"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Copying ${destination} from local ${source}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Copying ${path} from local ${source}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_from_local_source_recursion.cf b/tree/30_generic_methods/file_from_local_source_recursion.cf index a7f8de164..f9334eff4 100644 --- a/tree/30_generic_methods/file_from_local_source_recursion.cf +++ b/tree/30_generic_methods/file_from_local_source_recursion.cf @@ -26,17 +26,19 @@ # * *1,2,3,...* will force the maximal level of recursion to copy # # @parameter source Source file (absolute path on the target node) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) # @parameter recursion Recursion depth to enforce for this path (0, 1, 2, ..., inf) # +# @parameter_name path destination +# # @class_prefix file_from_local_source -# @class_parameter destination +# @class_parameter path -bundle agent file_from_local_source_recursion(source, destination, recursion) +bundle agent file_from_local_source_recursion(source, path, recursion) { vars: - "old_class_prefix" string => canonify("file_from_local_source_${destination}"); - "args" slist => { "${source}", "${destination}", "${recursion}" }; + "old_class_prefix" string => canonify("file_from_local_source_${path}"); + "args" slist => { "${source}", "${path}", "${recursion}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_from_local_source_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -46,7 +48,7 @@ bundle agent file_from_local_source_recursion(source, destination, recursion) # so we need to detect if we want to copy a folder or a file # If we check if it is a file, the class will always be true # event if was in fact a directory. Then, we test if it is a dir. - "is_dir_copy" expression => isdir("${destination}"); + "is_dir_copy" expression => isdir("${path}"); # We won't be able to know if it is really a directory # or not before the first iteration "iteration_2" expression => "iteration_1"; @@ -54,12 +56,12 @@ bundle agent file_from_local_source_recursion(source, destination, recursion) files: !is_dir_copy:: - "${destination}" + "${path}" copy_from => ncf_local_cp_method("${source}", "digest"), classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); is_dir_copy:: - "${destination}" + "${path}" copy_from => ncf_local_cp_method("${source}", "digest"), depth_search => recurse("${recursion}"), classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); @@ -69,9 +71,9 @@ bundle agent file_from_local_source_recursion(source, destination, recursion) # directory (to apply recursion) or a file iteration_2.!is_dir_copy:: "report" - usebundle => _log_v3("Copying ${destination} from ${source}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Copying ${path} from ${source}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); iteration_2.is_dir_copy:: "report" - usebundle => _log_v3("Copying ${destination} from local ${source}, recursion level ${recursion}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Copying ${path} from local ${source}, recursion level ${recursion}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_from_local_source_with_check.cf b/tree/30_generic_methods/file_from_local_source_with_check.cf index e021bd18e..57c13ed33 100644 --- a/tree/30_generic_methods/file_from_local_source_with_check.cf +++ b/tree/30_generic_methods/file_from_local_source_with_check.cf @@ -39,28 +39,30 @@ # * If not, it will return an error # # @parameter source Source file (absolute path on the target node) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) # @parameter check_command Command to run, it will get the source path as argument # @parameter rc_ok Return codes to be considered as valid, separated by a comma (default is 0) # @parameter_constraint rc_ok "allow_empty_string" : true +# +# @parameter_name path destination # # @class_prefix file_from_local_source_with_check -# @class_parameter destination +# @class_parameter path -bundle agent file_from_local_source_with_check(source, destination, check_command, rc_ok) +bundle agent file_from_local_source_with_check(source, path, check_command, rc_ok) { vars: - "old_class_prefix" string => canonify("file_from_local_source_with_check_${destination}"); + "old_class_prefix" string => canonify("file_from_local_source_with_check_${path}"); - "args" slist => { "${source}", "${destination}", "${check_command}", "${rc_ok}"}; + "args" slist => { "${source}", "${path}", "${check_command}", "${rc_ok}"}; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_from_local_source_with_check_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "canonified_file" string => canonify("${destination}"); + "canonified_path" string => canonify("${path}"); pass1:: - "full_inner_class_file_copy_prefix" string => canonify("file_from_local_source_${source}_${destination}"); + "full_inner_class_file_copy_prefix" string => canonify("file_from_local_source_${source}_${path}"); "inner_class_file_copy_prefix" string => string_head("${full_inner_class_file_copy_prefix}", "1000"); "full_inner_class_condition_prefix" string => canonify("condition_from_command_${old_class_prefix}_check_${check_command} \"${source}\"_${rc_ok}_999"); @@ -75,9 +77,9 @@ bundle agent file_from_local_source_with_check(source, destination, check_comman classes: agent:: - "destination_exists" expression => fileexists("${destination}"); + "destination_exists" expression => fileexists("${path}"); # We might need to copy if destination file exists and diff is not 0, or there's no destination file - "copy_needed" not => returnszero("${paths.path[diff]} \"${source}\" \"${destination}\"", "useshell"), + "copy_needed" not => returnszero("${paths.path[diff]} \"${source}\" \"${path}\"", "useshell"), ifvarclass => "destination_exists"; "copy_needed" not => "destination_exists"; @@ -93,9 +95,9 @@ bundle agent file_from_local_source_with_check(source, destination, check_comman pass2:: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "check" usebundle => condition_from_command("file_from_local_source_with_check_${canonified_file}_check", "${check_command} \"${source}\"", "${rc_ok}", "999"), + "check" usebundle => condition_from_command("file_from_local_source_with_check_${canonified_path}_check", "${check_command} \"${source}\"", "${rc_ok}", "999"), ifvarclass => "copy_needed"; - "copy" usebundle => file_from_local_source("${source}", "${destination}"), + "copy" usebundle => file_from_local_source("${source}", "${path}"), ifvarclass => "${inner_class_condition_prefix}_kept"; # the condition from command true is equivalent to inner_class_prefix_kept "reenable_reporting_${class_prefix}" @@ -107,7 +109,7 @@ bundle agent file_from_local_source_with_check(source, destination, check_comman ifvarclass => "!copy_needed"; - # here we are not using file_from_local_source_with_check_${canonified_file}_check_false as we want to allow any return code + # here we are not using file_from_local_source_with_check_${canonified_path}_check_false as we want to allow any return code # which is different from rc_ok as failure. "result" usebundle => _classes_failure("${old_class_prefix}"), ifvarclass => "${inner_class_condition_prefix}_error"; @@ -121,8 +123,8 @@ bundle agent file_from_local_source_with_check(source, destination, check_comman ifvarclass => "${inner_class_condition_prefix}_kept"; - "report" usebundle => _log_v3("Copying ${destination} from local ${source} with check", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}), + "report" usebundle => _log_v3("Copying ${path} from local ${source} with check", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}), ifvarclass => "!${inner_class_condition_prefix}_failed"; - "report" usebundle => _log_v3("Copying ${destination} from local ${source} failed at check command", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}), + "report" usebundle => _log_v3("Copying ${path} from local ${source} failed at check command", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}), ifvarclass => "${inner_class_condition_prefix}_failed"; } diff --git a/tree/30_generic_methods/file_from_remote_source.cf b/tree/30_generic_methods/file_from_remote_source.cf index 4b9b5ff76..e5e402eca 100644 --- a/tree/30_generic_methods/file_from_remote_source.cf +++ b/tree/30_generic_methods/file_from_remote_source.cf @@ -31,17 +31,19 @@ # ``` # # @parameter source Source file (absolute path on the policy server) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) +# +# @parameter_name path destination # # @class_prefix file_from_remote_source -# @class_parameter destination +# @class_parameter path -bundle agent file_from_remote_source(source, destination) +bundle agent file_from_remote_source(source, path) { vars: - "old_class_prefix" string => canonify("file_from_remote_source_${destination}"); + "old_class_prefix" string => canonify("file_from_remote_source_${path}"); - "args" slist => { "${source}", "${destination}" }; + "args" slist => { "${source}", "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_from_remote_source_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -56,11 +58,11 @@ bundle agent file_from_remote_source(source, destination) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "copy without recursion" usebundle => file_from_remote_source_recursion("${source}", "${destination}", "0"); + "copy without recursion" usebundle => file_from_remote_source_recursion("${source}", "${path}", "0"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Copying ${destination} from ${source}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Copying ${path} from ${source}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_from_remote_source_recursion.cf b/tree/30_generic_methods/file_from_remote_source_recursion.cf index 98a350163..692eeb513 100644 --- a/tree/30_generic_methods/file_from_remote_source_recursion.cf +++ b/tree/30_generic_methods/file_from_remote_source_recursion.cf @@ -27,17 +27,19 @@ # ``` # # @parameter source Source file (absolute path on the policy server) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) # @parameter recursion Recursion depth to enforce for this path (0, 1, 2, ..., inf) +# +# @parameter_name path destination # # @class_prefix file_from_remote_source -# @class_parameter destination +# @class_parameter path -bundle agent file_from_remote_source_recursion(source, destination, recursion) +bundle agent file_from_remote_source_recursion(source, path, recursion) { vars: - "old_class_prefix" string => canonify("file_from_remote_source_${destination}"); - "args" slist => { "${source}", "${destination}", "${recursion}" }; + "old_class_prefix" string => canonify("file_from_remote_source_${path}"); + "args" slist => { "${source}", "${path}", "${recursion}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_from_remote_source_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -47,7 +49,7 @@ bundle agent file_from_remote_source_recursion(source, destination, recursion) # so we need to detect if we want to copy a folder or a file # If we check if it is a file, the class will always be true # event if was in fact a directory. Then, we test if it is a dir. - "is_dir_copy" expression => isdir("${destination}"); + "is_dir_copy" expression => isdir("${path}"); # We won't be able to know if it is really a directory # or not before the first iteration "iteration_2" expression => "iteration_1"; @@ -56,12 +58,12 @@ bundle agent file_from_remote_source_recursion(source, destination, recursion) files: !is_dir_copy:: - "${destination}" + "${path}" copy_from => ncf_remote_cp_method("${source}", "${sys.policy_hub}", "digest"), classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); is_dir_copy:: - "${destination}" + "${path}" copy_from => ncf_remote_cp_method("${source}", "${sys.policy_hub}", "digest"), depth_search => recurse("${recursion}"), classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); @@ -77,9 +79,9 @@ bundle agent file_from_remote_source_recursion(source, destination, recursion) # directory (to apply recursion) or a file iteration_2.!is_dir_copy:: "report" - usebundle => _log_v3("Copying file ${destination} from ${source}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Copying file ${path} from ${source}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); iteration_2.is_dir_copy:: "report" - usebundle => _log_v3("Copying ${destination} from ${source}, recursion level ${recursion}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Copying ${path} from ${source}, recursion level ${recursion}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_from_shared_folder.cf b/tree/30_generic_methods/file_from_shared_folder.cf index 963ec6e56..3d8210297 100644 --- a/tree/30_generic_methods/file_from_shared_folder.cf +++ b/tree/30_generic_methods/file_from_shared_folder.cf @@ -26,23 +26,26 @@ # # # @parameter source Source file (path, relative to /var/rudder/configuration-repository/shared-files) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) # @parameter hash_type Hash algorithm used to check if file is updated (sha256, sha512). Only used on Windows, ignored on Unix. default is sha256 # # keep md5 and sha1 to support old generic methods, also add a default so you don't have to enter a value on linux, md5/sha1 should go to default # @parameter_constraint hash_type "select" : [ "", "sha256", "sha512", "md5", "sha1" ] # @parameter_constraint hash_type "allow_empty_string" : true +# +# @parameter_name path destination +# # @class_prefix file_from_shared_folder -# @class_parameter destination +# @class_parameter path -bundle agent file_from_shared_folder(source, destination, hash_type) +bundle agent file_from_shared_folder(source, path, hash_type) { vars: - "canonified_destination" string => canonify("${destination}"); + "canonified_path" string => canonify("${path}"); - "old_class_prefix" string => "file_from_shared_folder_${canonified_destination}"; + "old_class_prefix" string => "file_from_shared_folder_${canonified_path}"; - "args" slist => { "/var/rudder/configuration-repository/shared-files/${source}", "${destination}", "${hash_type}" }; - "inner_args" slist => { "/var/rudder/configuration-repository/shared-files/${source}", "${destination}" }; + "args" slist => { "/var/rudder/configuration-repository/shared-files/${source}", "${path}", "${hash_type}" }; + "inner_args" slist => { "/var/rudder/configuration-repository/shared-files/${source}", "${path}" }; "report_param" string => join("_", args); "inner_report_param" string => join("_", inner_args); "full_class_prefix" string => canonify("file_from_shared_folder_${report_param}"); @@ -57,13 +60,13 @@ bundle agent file_from_shared_folder(source, destination, hash_type) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "copy without recursion" usebundle => file_copy_from_remote_source_recursion("/var/rudder/configuration-repository/shared-files/${source}", "${destination}", "inf"); + "copy without recursion" usebundle => file_copy_from_remote_source_recursion("/var/rudder/configuration-repository/shared-files/${source}", "${path}", "inf"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_copy_from_remote_source_${canonified_destination}", "${old_class_prefix}"); + "class copy" usebundle => _classes_copy("file_copy_from_remote_source_${canonified_path}", "${old_class_prefix}"); "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Copying ${destination} from ${source}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Copying ${path} from ${source}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_from_string_mustache.cf b/tree/30_generic_methods/file_from_string_mustache.cf index 7c6c3509b..a23a01243 100644 --- a/tree/30_generic_methods/file_from_string_mustache.cf +++ b/tree/30_generic_methods/file_from_string_mustache.cf @@ -22,17 +22,19 @@ # Complete mustache documentation is available in the *file\_from\_template\_mustache* method documentation. # # @parameter template String containing a template to be expanded -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node +# +# @parameter_name path destination # # @class_prefix file_from_string_mustache -# @class_parameter destination -# This bundle will define a condition file_from_string_mustache_${destination}_{kept,repaired,not_ok,ok,reached} +# @class_parameter path +# This bundle will define a condition file_from_string_mustache_${path}_{kept,repaired,not_ok,ok,reached} -bundle agent file_from_string_mustache(template, destination) +bundle agent file_from_string_mustache(template, path) { vars: - "old_class_prefix" string => canonify("file_from_string_mustache_${destination}"); - "args" slist => { "${template}", "${destination}" }; + "old_class_prefix" string => canonify("file_from_string_mustache_${path}"); + "args" slist => { "${template}", "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_from_string_mustache_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -43,7 +45,7 @@ bundle agent file_from_string_mustache(template, destination) "content_not_updated" expression => strcmp("${content}", "EMPTY_RUDDER_TEMPLATE"); files: - "${destination}" + "${path}" create => "true", edit_line => insert_lines("${content}"), edit_defaults => ncf_empty_select("true"), @@ -57,5 +59,5 @@ bundle agent file_from_string_mustache(template, destination) "error if the content is not properly updated" usebundle => _classes_failure("${class_prefix}"); any:: - "report" usebundle => _log_v3("Build file ${destination} from string template", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Build file ${path} from string template", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_from_template.cf b/tree/30_generic_methods/file_from_template.cf index e0c11ed01..34f2d0e9d 100644 --- a/tree/30_generic_methods/file_from_template.cf +++ b/tree/30_generic_methods/file_from_template.cf @@ -25,16 +25,18 @@ # templates usage. # # @parameter source_template Source file containing a template to be expanded (absolute path on the target node) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) +# +# @parameter_name path destination # # @class_prefix file_from_template -# @class_parameter destination +# @class_parameter path -bundle agent file_from_template(source_template, destination) +bundle agent file_from_template(source_template, path) { vars: - "old_class_prefix" string => canonify("file_from_template_${destination}"); - "args" slist => { "${source_template}", "${destination}" }; + "old_class_prefix" string => canonify("file_from_template_${path}"); + "args" slist => { "${source_template}", "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_from_template_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -44,7 +46,7 @@ bundle agent file_from_template(source_template, destination) "template_exists" expression => fileexists("${source_template}"); files: - "${destination}" + "${path}" create => "true", edit_template => "${source_template}", edit_defaults => ncf_empty_select("true"), @@ -60,6 +62,6 @@ bundle agent file_from_template(source_template, destination) any:: "sanitize" usebundle => _classes_sanitize("${old_class_prefix}"); "sanitize" usebundle => _classes_sanitize("${class_prefix}"); - "report" usebundle => _log_v3("Build file ${destination} from template ${source_template}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Build file ${path} from template ${source_template}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_from_template_jinja2.cf b/tree/30_generic_methods/file_from_template_jinja2.cf index 5ca06e115..0c5a75076 100644 --- a/tree/30_generic_methods/file_from_template_jinja2.cf +++ b/tree/30_generic_methods/file_from_template_jinja2.cf @@ -223,19 +223,21 @@ # ``` # # @parameter source_template Source file containing a template to be expanded (absolute path on the target node) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) +# +# @parameter_name path destination # # @class_prefix file_from_template -# @class_parameter destination +# @class_parameter path -bundle agent file_from_template_jinja2(source_template, destination) +bundle agent file_from_template_jinja2(source_template, path) { vars: - "old_class_prefix" string => canonify("file_from_template_${destination}"); + "old_class_prefix" string => canonify("file_from_template_${path}"); - "args" slist => { "${source_template}", "${destination}" }; + "args" slist => { "${source_template}", "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_from_template_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -243,11 +245,11 @@ bundle agent file_from_template_jinja2(source_template, destination) "jinja2_script" string => "${sys.workdir}/modules/templates/jinja2-templating.py"; "datastate_tpl" string => "${sys.workdir}/modules/templates/datastate.json.tpl"; "datastate_file" string => "${source_template}.datastate.${this.promiser_pid}.json"; - "destination_canon" string => canonify("${destination}"); + "destination_canon" string => canonify("${path}"); "destination_tmp" string => "${source_template}.${this.promiser_pid}.new"; - "full_inner_class_prefix" string => canonify("file_copy_from_local_source_${destination_tmp}_${destination}"); + "full_inner_class_prefix" string => canonify("file_copy_from_local_source_${destination_tmp}_${path}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); # Here we put the output into the errors variable. As the stdout is sent to a file, the output is only stderr, @@ -278,7 +280,7 @@ bundle agent file_from_template_jinja2(source_template, destination) "disable_reporting_${class_prefix}" usebundle => disable_reporting; # Use a file copy to avoid any file size limitations of CFEngine variables. pass2.templating_ok:: - "copy file" usebundle => file_copy_from_local_source("${destination_tmp}", "${destination}"); + "copy file" usebundle => file_copy_from_local_source("${destination_tmp}", "${path}"); pass2.templating_ok:: "copy classes" usebundle => _classes_copy("file_copy_from_local_source_${destination_canon}", "${old_class_prefix}"); "copy new classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); @@ -298,9 +300,9 @@ bundle agent file_from_template_jinja2(source_template, destination) "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "report" usebundle => _log_v3("Build file ${destination} from jinja2 template ${source_template}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Build file ${path} from jinja2 template ${source_template}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); # Report errors - "report" usebundle => log_rudder_mode("log_warn", "Jinja templating failed with the following error:${const.endl}${errors}", "${destination}", "${class_prefix}"), + "report" usebundle => log_rudder_mode("log_warn", "Jinja templating failed with the following error:${const.endl}${errors}", "${path}", "${class_prefix}"), ifvarclass => "state_dumped_${destination_canon}_ok.!templating_ok"; } diff --git a/tree/30_generic_methods/file_from_template_mustache.cf b/tree/30_generic_methods/file_from_template_mustache.cf index 7a1c2eddc..2a24d723f 100644 --- a/tree/30_generic_methods/file_from_template_mustache.cf +++ b/tree/30_generic_methods/file_from_template_mustache.cf @@ -184,24 +184,26 @@ # ``` # # @parameter source_template Source file containing a template to be expanded (absolute path on the target node) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) +# +# @parameter_name path destination # # @class_prefix file_from_template -# @class_parameter destination +# @class_parameter path -bundle agent file_from_template_mustache(source_template, destination) +bundle agent file_from_template_mustache(source_template, path) { vars: - "old_class_prefix" string => canonify("file_from_template_${destination}"); + "old_class_prefix" string => canonify("file_from_template_${path}"); - "args" slist => { "${source_template}", "${destination}" }; + "args" slist => { "${source_template}", "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_from_template_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); # file_from_template_type is called with mustache parameter - "full_inner_class_prefix" string => canonify("file_from_template_${source_template}_${destination}_mustache"); + "full_inner_class_prefix" string => canonify("file_from_template_${source_template}_${path}_mustache"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); @@ -211,11 +213,11 @@ bundle agent file_from_template_mustache(source_template, destination) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "file template mustache type" usebundle => file_from_template_type("${source_template}", "${destination}", "mustache"); + "file template mustache type" usebundle => file_from_template_type("${source_template}", "${path}", "mustache"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Build file ${destination} from mustache template ${source_template}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Build file ${path} from mustache template ${source_template}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_from_template_type.cf b/tree/30_generic_methods/file_from_template_type.cf index 3744197f8..76e847c08 100644 --- a/tree/30_generic_methods/file_from_template_type.cf +++ b/tree/30_generic_methods/file_from_template_type.cf @@ -97,24 +97,26 @@ # # # @parameter source_template Source file containing a template to be expanded (absolute path on the target node) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) # @parameter template_type Template type (cfengine, jinja2 or mustache) # +# @parameter_name path destination +# # @class_prefix file_from_template -# @class_parameter destination +# @class_parameter path -bundle agent file_from_template_type(source_template, destination, template_type) +bundle agent file_from_template_type(source_template, path, template_type) { vars: - "old_class_prefix" string => canonify("file_from_template_${destination}"); + "old_class_prefix" string => canonify("file_from_template_${path}"); - "args" slist => { "${source_template}", "${destination}", "${template_type}" }; + "args" slist => { "${source_template}", "${path}", "${template_type}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_from_template_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); # Only used in the jinja2 case - "full_inner_class_prefix" string => canonify("file_from_template_${source_template}_${destination}"); + "full_inner_class_prefix" string => canonify("file_from_template_${source_template}_${path}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); # allow to avoid resolving the jinja2 bundle when not using jinja2, because of the special requirements @@ -127,7 +129,7 @@ bundle agent file_from_template_type(source_template, destination, template_type "should_report" expression => "${report_data.should_report}"; files: - "${destination}" + "${path}" create => "true", edit_template => "${source_template}", template_method => "${template_type}", @@ -138,7 +140,7 @@ bundle agent file_from_template_type(source_template, destination, template_type methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; is_jinja2.template_exists:: - "template" usebundle => ${jinja2_bundle_name}("${source_template}", "${destination}"); + "template" usebundle => ${jinja2_bundle_name}("${source_template}", "${path}"); any:: "reenable_reporting_${class_prefix}" usebundle => enable_reporting, @@ -150,11 +152,11 @@ bundle agent file_from_template_type(source_template, destination, template_type is_jinja2.template_exists:: "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Build file ${destination} from ${template_type} template ${source_template}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Build file ${path} from ${template_type} template ${source_template}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); !(is_jinja2.template_exists):: "sanitize" usebundle => _classes_sanitize("${class_prefix}"); "sanitize" usebundle => _classes_sanitize("${old_class_prefix}"); - "report" usebundle => _log_v3("Build file ${destination} from ${template_type} type template ${source_template}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Build file ${path} from ${template_type} type template ${source_template}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_key_value_parameter_absent_in_list.cf b/tree/30_generic_methods/file_key_value_parameter_absent_in_list.cf index 2f27ff5ee..ba9096ea2 100644 --- a/tree/30_generic_methods/file_key_value_parameter_absent_in_list.cf +++ b/tree/30_generic_methods/file_key_value_parameter_absent_in_list.cf @@ -36,7 +36,7 @@ # file_ensure_key_value_parameter_not_in_list("/etc/default/grub", "GRUB_CMDLINE", "=", "dom0_max_vcpus=32", " ", "\"", "\""); # ``` # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter key Full key name # @parameter key_value_separator character used to separate key and value in a key-value line # @parameter parameter_regex Regular expression matching the sub-value to ensure is not present in the list of parameters that form the value part of that line @@ -48,14 +48,16 @@ # @parameter_constraint leading_char_separator "allow_empty_string" : true # @parameter_constraint closing_char_separator "allow_empty_string" : true # +# @parameter_name path file +# # @class_prefix file_key_value_parameter_absent_in_list -# @class_parameter file +# @class_parameter path -bundle agent file_key_value_parameter_absent_in_list(file, key, key_value_separator, parameter_regex, parameter_separator, leading_char_separator, closing_char_separator) +bundle agent file_key_value_parameter_absent_in_list(path, key, key_value_separator, parameter_regex, parameter_separator, leading_char_separator, closing_char_separator) { vars: - "old_class_prefix" string => canonify("file_key_value_parameter_absent_in_list_${file}"); - "args" slist => { "${file}", "${key}", "${key_value_separator}", "${parameter_regex}", "${parameter_separator}", "${leading_char_separator}", "${closing_char_separator}" }; + "old_class_prefix" string => canonify("file_key_value_parameter_absent_in_list_${path}"); + "args" slist => { "${path}", "${key}", "${key_value_separator}", "${parameter_regex}", "${parameter_separator}", "${leading_char_separator}", "${closing_char_separator}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_key_value_parameter_absent_in_list_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -74,13 +76,13 @@ bundle agent file_key_value_parameter_absent_in_list(file, key, key_value_separa "defined_enclosing" expression => "leading_char_defined.closing_char_defined"; defined_enclosing.!pass1:: - "line_with_parameter_present" expression => regline("^(${key}\s*${key_value_separator}\s*)${escaped_leading_char}.*(${parameter_separator})?${parameter_regex}(${parameter_separator})?.*(${escaped_closing_char})\s*$", "${file}"); + "line_with_parameter_present" expression => regline("^(${key}\s*${key_value_separator}\s*)${escaped_leading_char}.*(${parameter_separator})?${parameter_regex}(${parameter_separator})?.*(${escaped_closing_char})\s*$", "${path}"); !defined_enclosing.!invalid_enclosing.!pass1:: - "line_with_parameter_present" expression => regline("^(${key}\s*${key_value_separator}\s*).*(${parameter_separator})?${parameter_regex}(${parameter_separator})?.*$", "${file}"); + "line_with_parameter_present" expression => regline("^(${key}\s*${key_value_separator}\s*).*(${parameter_separator})?${parameter_regex}(${parameter_separator})?.*$", "${path}"); !pass1:: - "line_with_key_present" expression => regline("^(${key}\s*${key_value_separator}\s*).*$", "${file}"); + "line_with_key_present" expression => regline("^(${key}\s*${key_value_separator}\s*).*$", "${path}"); any:: "pass2" expression => "pass1"; @@ -88,12 +90,12 @@ bundle agent file_key_value_parameter_absent_in_list(file, key, key_value_separa files: line_with_parameter_present.!invalid_enclosing:: - "${file}" + "${path}" edit_line => ncf_remove_parameter_in_list("${key}", "${key_value_separator}", "${parameter_separator}", "${parameter_regex}", "${leading_char_separator}", "${closing_char_separator}"), edit_defaults => ncf_empty_select("false"), classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"), # This comment is necessary, see https://www.rudder-project.org/redmine/issues/10153 - comment => "Editing file ${file} to remove parameter ${leading_char_separator} ${parameter_regex} ${closing_char_separator} for key ${key}"; + comment => "Editing file ${path} to remove parameter ${leading_char_separator} ${parameter_regex} ${closing_char_separator} for key ${key}"; methods: pass2:: @@ -108,11 +110,11 @@ bundle agent file_key_value_parameter_absent_in_list(file, key, key_value_separa ifvarclass => "invalid_enclosing"; pass2.!invalid_enclosing.line_with_key_present:: - "report" usebundle => _log_v3("Ensure parameter is not in ${key}${key_value_separator} values in ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Ensure parameter is not in ${key}${key_value_separator} values in ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); pass2.!invalid_enclosing.!line_with_key_present:: - "report" usebundle => _log_v3("Non existing key ${key} with parameter value in ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Non existing key ${key} with parameter value in ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); pass2.invalid_enclosing:: - "report" usebundle => _log_v3("Ensure parameter is not in line ${key}${key_value_separator} values in ${file} must have either no enclosing character, or two, but not only one", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Ensure parameter is not in line ${key}${key_value_separator} values in ${path} must have either no enclosing character, or two, but not only one", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_key_value_parameter_present_in_list.cf b/tree/30_generic_methods/file_key_value_parameter_present_in_list.cf index 9aa508834..e4cdc75f5 100644 --- a/tree/30_generic_methods/file_key_value_parameter_present_in_list.cf +++ b/tree/30_generic_methods/file_key_value_parameter_present_in_list.cf @@ -37,7 +37,7 @@ # file_ensure_key_value_parameter_in_list("/etc/default/grub", "GRUB_CMDLINE", "=", "dom0_max_vcpus=32", " ", "\"", "\""); # ``` # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter key Full key name # @parameter key_value_separator character used to separate key and value in a key-value line # @parameter parameter String representing the sub-value to ensure is present in the list of parameters that form the value part of that line @@ -49,14 +49,16 @@ # @parameter_constraint leading_char_separator "allow_empty_string" : true # @parameter_constraint closing_char_separator "allow_empty_string" : true # +# @parameter_name path file +# # @class_prefix file_key_value_parameter_present_in_list -# @class_parameter file +# @class_parameter path -bundle agent file_key_value_parameter_present_in_list(file, key, key_value_separator, parameter, parameter_separator, leading_char_separator, closing_char_separator) +bundle agent file_key_value_parameter_present_in_list(path, key, key_value_separator, parameter, parameter_separator, leading_char_separator, closing_char_separator) { vars: - "old_class_prefix" string => canonify("file_key_value_parameter_present_in_list_${file}"); - "args" slist => { "${file}", "${key}", "${key_value_separator}", "${parameter}", "${parameter_separator}", "${leading_char_separator}", "${closing_char_separator}" }; + "old_class_prefix" string => canonify("file_key_value_parameter_present_in_list_${path}"); + "args" slist => { "${path}", "${key}", "${key_value_separator}", "${parameter}", "${parameter_separator}", "${leading_char_separator}", "${closing_char_separator}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_key_value_parameter_present_in_list_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -76,13 +78,13 @@ bundle agent file_key_value_parameter_present_in_list(file, key, key_value_separ "defined_enclosing" expression => "leading_char_defined.closing_char_defined"; defined_enclosing.!pass1:: - "line_with_parameter_present" expression => regline("^(${key}\s*${key_value_separator}\s*)${escaped_leading_char}.*(${parameter_separator})?${parameter}(${parameter_separator})?.*(${escaped_closing_char})\s*$", "${file}"); + "line_with_parameter_present" expression => regline("^(${key}\s*${key_value_separator}\s*)${escaped_leading_char}.*(${parameter_separator})?${parameter}(${parameter_separator})?.*(${escaped_closing_char})\s*$", "${path}"); !defined_enclosing.!invalid_enclosing.!pass1:: - "line_with_parameter_present" expression => regline("^(${key}\s*${key_value_separator}\s*).*(${parameter_separator})?${parameter}(${parameter_separator})?.*$", "${file}"); + "line_with_parameter_present" expression => regline("^(${key}\s*${key_value_separator}\s*).*(${parameter_separator})?${parameter}(${parameter_separator})?.*$", "${path}"); !pass1:: - "line_with_key_present" expression => regline("^(${key}\s*${key_value_separator}\s*).*$", "${file}"); + "line_with_key_present" expression => regline("^(${key}\s*${key_value_separator}\s*).*$", "${path}"); any:: "pass2" expression => "pass1"; @@ -90,28 +92,28 @@ bundle agent file_key_value_parameter_present_in_list(file, key, key_value_separ files: line_with_key_present.!line_with_parameter_present.!invalid_enclosing.!defined_enclosing:: - "${file}" + "${path}" edit_line => ncf_add_parameter_in_list("${key}", "${key_value_separator}", "${parameter_separator}", "${parameter}"), edit_defaults => ncf_empty_select("false"), classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"), # This comment is necessary, see https://www.rudder-project.org/redmine/issues/10153 - comment => "Editing file ${file} to set parameter ${parameter} for key ${key}"; + comment => "Editing file ${path} to set parameter ${parameter} for key ${key}"; line_with_key_present.!line_with_parameter_present.!invalid_enclosing.defined_enclosing:: - "${file}" + "${path}" edit_line => ncf_add_parameter_in_list_with_enclosing_chars("${key}", "${key_value_separator}", "${parameter_separator}", "${parameter}", "${leading_char_separator}", "${closing_char_separator}"), edit_defaults => ncf_empty_select("false"), classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"), # This comment is necessary, see https://www.rudder-project.org/redmine/issues/10153 - comment => "Editing file ${file} to set parameter ${leading_char_separator} ${parameter} ${closing_char_separator} for key ${key}"; + comment => "Editing file ${path} to set parameter ${leading_char_separator} ${parameter} ${closing_char_separator} for key ${key}"; !line_with_key_present.!invalid_enclosing:: - "${file}" + "${path}" edit_line => insert_lines("${key}${key_value_separator}${leading_char_separator}${parameter}${closing_char_separator}"), edit_defaults => ncf_empty_select("false"), classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"), # This comment is necessary, see https://www.rudder-project.org/redmine/issues/10153 - comment => "Adding into file ${file} key ${key} with value ${leading_char_separator} ${parameter} ${closing_char_separator}"; + comment => "Adding into file ${path} key ${key} with value ${leading_char_separator} ${parameter} ${closing_char_separator}"; methods: @@ -127,11 +129,11 @@ bundle agent file_key_value_parameter_present_in_list(file, key, key_value_separ ifvarclass => "invalid_enclosing"; pass2.!invalid_enclosing.!line_with_key_present:: - "report" usebundle => _log_v3("Ensure parameter in line ${key}${key_value_separator} values in ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Ensure parameter in line ${key}${key_value_separator} values in ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); pass2.!invalid_enclosing.line_with_key_present:: - "report" usebundle => _log_v3("Add key non existing ${key} with value parameter in ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Add key non existing ${key} with value parameter in ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); pass2.invalid_enclosing:: - "report" usebundle => _log_v3("Ensure parameter in line ${key}${key_value_separator} values in ${file} must have either no enclosing character, or two, but not only one", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Ensure parameter in line ${key}${key_value_separator} values in ${path} must have either no enclosing character, or two, but not only one", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_key_value_present.cf b/tree/30_generic_methods/file_key_value_present.cf index f39c5e1e2..7cc9ae6fb 100644 --- a/tree/30_generic_methods/file_key_value_present.cf +++ b/tree/30_generic_methods/file_key_value_present.cf @@ -21,17 +21,19 @@ # @documentation Edit (or create) the file, and ensure it contains an entry key -> value with arbitrary separator between the key and its value. # If the key is already present, the method will change the value associated with this key. # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter key Key to define # @parameter value Value to define # @parameter separator Separator between key and value, for example "=" or " " (without the quotes) # @parameter_constraint separator "allow_whitespace_string" : true # +# @parameter_name path file +# # @class_prefix file_key_value_present -# @class_parameter file +# @class_parameter path -bundle agent file_key_value_present(file, key, value, separator) +bundle agent file_key_value_present(path, key, value, separator) { methods: - "action" usebundle => file_key_value_present_option("${file}", "${key}", "${value}", "${separator}", "lax"); + "action" usebundle => file_key_value_present_option("${path}", "${key}", "${value}", "${separator}", "lax"); } diff --git a/tree/30_generic_methods/file_key_value_present_in_ini_section.cf b/tree/30_generic_methods/file_key_value_present_in_ini_section.cf index 3c8ae686b..0a720235a 100644 --- a/tree/30_generic_methods/file_key_value_present_in_ini_section.cf +++ b/tree/30_generic_methods/file_key_value_present_in_ini_section.cf @@ -19,19 +19,21 @@ # @name File key-value in INI section # @description Ensure that a key-value pair is present in a section in a specific location. The objective of this method is to handle INI-style files. # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter section Name of the INI-style section under which the line should be added or modified (not including the [] brackets) # @parameter name Name of the key to add or edit # @parameter value Value of the key to add or edit # +# @parameter_name path file +# # @class_prefix file_key_value_present_in_ini_section -# @class_parameter file +# @class_parameter path -bundle agent file_key_value_present_in_ini_section(file, section, name, value) +bundle agent file_key_value_present_in_ini_section(path, section, name, value) { vars: - "old_class_prefix" string => canonify("file_key_value_present_in_ini_section_${file}"); - "args" slist => { "${file}", "${section}", "${name}", "${value}" }; + "old_class_prefix" string => canonify("file_key_value_present_in_ini_section_${path}"); + "args" slist => { "${path}", "${section}", "${name}", "${value}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_key_value_present_in_ini_section_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -44,7 +46,7 @@ bundle agent file_key_value_present_in_ini_section(file, section, name, value) "file_present" expression => fileexists("${file}"); files: - "${file}" + "${path}" create => "true", edit_line => insert_lines("[${section}] "), @@ -54,11 +56,11 @@ bundle agent file_key_value_present_in_ini_section(file, section, name, value) edit_line => set_variable_values_ini("file_key_value_present_in_ini_section.content", "${section}"), edit_defaults => ncf_empty_select("false"), classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"), - comment => "Editing file ${file} to set ${name} = ${value} in section ${section}"; + comment => "Editing file ${path} to set ${name} = ${value} in section ${section}"; methods: "sanitize" usebundle => _classes_sanitize("${class_prefix}"); "sanitize" usebundle => _classes_sanitize("${old_class_prefix}"); - "report" usebundle => _log_v3("Set line key=value in section ${section} into ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Set line key=value in section ${section} into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_key_value_present_option.cf b/tree/30_generic_methods/file_key_value_present_option.cf index 2becd952c..a62a3efa7 100644 --- a/tree/30_generic_methods/file_key_value_present_option.cf +++ b/tree/30_generic_methods/file_key_value_present_option.cf @@ -21,7 +21,7 @@ # @documentation Edit (or create) the file, and ensure it contains an entry key -> value with arbitrary separator between the key and its value. # If the key is already present, the method will change the value associated with this key. # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter key Key to define # @parameter value Value to define # @parameter separator Separator between key and value, for example "=" or " " (without the quotes) @@ -29,14 +29,16 @@ # @parameter_constraint separator "allow_whitespace_string" : true # @parameter_constraint option "select" : [ "strict", "lax" ] # +# @parameter_name path file +# # @class_prefix file_key_value_present -# @class_parameter file +# @class_parameter path -bundle agent file_key_value_present_option(file, key, value, separator, option) +bundle agent file_key_value_present_option(path, key, value, separator, option) { vars: - "old_class_prefix" string => canonify("file_key_value_present_${file}"); - "args" slist => { "${file}", "${key}", "${value}","${separator}", "${option}" }; + "old_class_prefix" string => canonify("file_key_value_present_${path}"); + "args" slist => { "${path}", "${key}", "${value}","${separator}", "${option}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_key_value_present_${report_param}"); @@ -45,10 +47,10 @@ bundle agent file_key_value_present_option(file, key, value, separator, option) "keys[${key}]" string => "${value}"; pass1.strict_spacing:: - "report_message" string => "Ensure line in format key${separator}value in ${file}"; + "report_message" string => "Ensure line in format key${separator}value in ${path}"; pass1.!strict_spacing:: - "report_message" string => "Ensure line in format key ${separator} value in ${file}"; + "report_message" string => "Ensure line in format key ${separator} value in ${path}"; classes: "strict_spacing" expression => strcmp("option", "strict"); @@ -57,17 +59,17 @@ bundle agent file_key_value_present_option(file, key, value, separator, option) "pass1" expression => "any"; files: - "${file}" + "${path}" create => "true", edit_line => ncf_maintain_keys_values_option("file_key_value_present_option.keys", "${separator}", "${option}"), edit_defaults => ncf_empty_select("false"), classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"), # This comment is necessary, see https://www.rudder-project.org/redmine/issues/10153 - comment => "Editing file ${file} to set ${key}${separator}${value}"; + comment => "Editing file ${path} to set ${key}${separator}${value}"; methods: pass2:: "sanitize" usebundle => _classes_sanitize("${class_prefix}"); "sanitize" usebundle => _classes_sanitize("${old_class_prefix}"); - "report" usebundle => _log_v3("Ensure line in format key${separator}value in ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Ensure line in format key${separator}value in ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_keys_values_present.cf b/tree/30_generic_methods/file_keys_values_present.cf index cb42bf0ae..bb6ccac83 100644 --- a/tree/30_generic_methods/file_keys_values_present.cf +++ b/tree/30_generic_methods/file_keys_values_present.cf @@ -71,25 +71,27 @@ # key2 = value2 # ``` # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter keys Name of the dict structure (without "${}") containing the keys (keys of the dict), and values to define (values of the dict) # @parameter separator Separator between key and value, for example "=" or " " (without the quotes) # @parameter_constraint separator "allow_whitespace_string" : true # +# @parameter_name path file +# # @class_prefix file_keys_values_present -# @class_parameter file +# @class_parameter path -bundle agent file_keys_values_present(file, keys, separator) +bundle agent file_keys_values_present(path, keys, separator) { vars: - "old_class_prefix" string => canonify("file_keys_values_present_${file}"); - "args" slist => { "${file}", "${keys}", "${separator}" }; + "old_class_prefix" string => canonify("file_keys_values_present_${path}"); + "args" slist => { "${path}", "${keys}", "${separator}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_keys_values_present_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); files: - "${file}" + "${path}" create => "true", edit_line => ncf_maintain_keys_values("${keys}", "${separator}"), edit_defaults => ncf_empty_select("false"), @@ -98,5 +100,5 @@ bundle agent file_keys_values_present(file, keys, separator) methods: "sanitize" usebundle => _classes_sanitize("${class_prefix}"); "sanitize" usebundle => _classes_sanitize("${old_class_prefix}"); - "report" usebundle => _log_v3("Ensure lines in format key${separator}values into ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Ensure lines in format key${separator}values into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_line_present_in_ini_section.cf b/tree/30_generic_methods/file_line_present_in_ini_section.cf index 026a69ef1..86d7de7af 100644 --- a/tree/30_generic_methods/file_line_present_in_ini_section.cf +++ b/tree/30_generic_methods/file_line_present_in_ini_section.cf @@ -19,18 +19,20 @@ # @name File line in INI section # @description Ensure that a line is present in a section in a specific location. The objective of this method is to handle INI-style files. # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter section Name of the INI-style section under which lines should be added (not including the [] brackets) # @parameter line Line to ensure is present inside the section # +# @parameter_name path file +# # @class_prefix file_line_present_in_ini_section -# @class_parameter file +# @class_parameter path -bundle agent file_line_present_in_ini_section(file, section, line) +bundle agent file_line_present_in_ini_section(path, section, line) { vars: - "old_class_prefix" string => canonify("file_line_present_in_ini_section_${file}"); - "args" slist => { "${file}", "${section}", "${line}" }; + "old_class_prefix" string => canonify("file_line_present_in_ini_section_${path}"); + "args" slist => { "${path}", "${section}", "${line}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_line_present_in_ini_section_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -39,12 +41,12 @@ bundle agent file_line_present_in_ini_section(file, section, line) classes: # Check if the section exist: if not, a class will be raised to add it with a blank line. - "section_absent" not => regline("^\[${section}\]$","${file}"); + "section_absent" not => regline("^\[${section}\]$","${path}"); files: # If the section is not present in the file, firstly it will be added # with a blank line in order to be caught for the lines to add after it. - "${file}" + "${path}" create => "true", edit_line => ncf_insert_block("${section_and_blank_line}"), edit_defaults => ncf_empty_select("false"), @@ -52,7 +54,7 @@ bundle agent file_line_present_in_ini_section(file, section, line) comment => "Add section to file with a blank line"; # Add the missing lines after the section. - "${file}" + "${path}" create => "true", edit_line => ensure_line_in_ini_section("${section}", "${line}"), edit_defaults => ncf_empty_select("false"), @@ -61,5 +63,5 @@ bundle agent file_line_present_in_ini_section(file, section, line) methods: "sanitize" usebundle => _classes_sanitize("${class_prefix}"); "sanitize" usebundle => _classes_sanitize("${old_class_prefix}"); - "report" usebundle => _log_v3("Insert line(s) into ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Insert line(s) into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_line_present_in_xml_tag.cf b/tree/30_generic_methods/file_line_present_in_xml_tag.cf index b79467352..8b87d1f41 100644 --- a/tree/30_generic_methods/file_line_present_in_xml_tag.cf +++ b/tree/30_generic_methods/file_line_present_in_xml_tag.cf @@ -19,30 +19,32 @@ # @name File line in XML section # @description Ensure that a line is present in a tag in a specific location. The objective of this method is to handle XML-style files. Note that if the tag is not present in the file, it won't be added, and the edition will fail. # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter tag Name of the XML tag under which lines should be added (not including the <> brackets) # @parameter line Line to ensure is present inside the section # +# @parameter_name path file +# # @class_prefix file_line_present_in_xml_tag -# @class_parameter file +# @class_parameter path -bundle agent file_line_present_in_xml_tag(file, tag, line) +bundle agent file_line_present_in_xml_tag(path, tag, line) { vars: - "old_class_prefix" string => canonify("file_line_present_in_xml_tag_${file}"); - "args" slist => { "${file}", "${tag}", "${line}" }; + "old_class_prefix" string => canonify("file_line_present_in_xml_tag_${path}"); + "args" slist => { "${path}", "${tag}", "${line}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_line_present_in_xml_tag_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); classes: - "opening_tag_exists" expression => regline("\s*<${tag}>\s*", "${file}"); - "closing_tag_exists" expression => regline("\s*\s*", "${file}"); + "opening_tag_exists" expression => regline("\s*<${tag}>\s*", "${path}"); + "closing_tag_exists" expression => regline("\s*\s*", "${path}"); "tags_present" expression => "opening_tag_exists.closing_tag_exists"; files: tags_present:: - "${file}" + "${path}" edit_line => ensure_line_in_xml_tag("${tag}", "${line}"), edit_defaults => ncf_empty_select("false"), classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); @@ -55,5 +57,5 @@ bundle agent file_line_present_in_xml_tag(file, tag, line) any:: "sanitize" usebundle => _classes_sanitize("${class_prefix}"); "sanitize" usebundle => _classes_sanitize("${old_class_prefix}"); - "report" usebundle => _log_v3("Insert line(s) in xml tag into ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Insert line(s) in xml tag into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_lines_absent.cf b/tree/30_generic_methods/file_lines_absent.cf index 4feef288b..e58a5a099 100644 --- a/tree/30_generic_methods/file_lines_absent.cf +++ b/tree/30_generic_methods/file_lines_absent.cf @@ -19,27 +19,29 @@ # @name File lines absent # @description Ensure that a line is absent in a specific location # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter lines Line(s) to remove in the file # +# @parameter_name path file +# # @class_prefix file_lines_absent -# @class_parameter file +# @class_parameter path -bundle agent file_lines_absent(file, lines) +bundle agent file_lines_absent(path, lines) { vars: - "old_class_prefix" string => canonify("file_lines_absent_${file}"); - "args" slist => { "${file}", "${lines}" }; + "old_class_prefix" string => canonify("file_lines_absent_${path}"); + "args" slist => { "${path}", "${lines}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_lines_absent_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); classes: - "file_exists" expression => fileexists("${file}"); + "file_exists" expression => fileexists("${path}"); files: file_exists:: - "${file}" + "${path}" create => "false", edit_line => delete_lines_matching("${lines}"), edit_defaults => ncf_empty_select("false"), @@ -49,12 +51,12 @@ bundle agent file_lines_absent(file, lines) file_exists:: "sanitize" usebundle => _classes_sanitize("${class_prefix}"); "sanitize" usebundle => _classes_sanitize("${old_class_prefix}"); - "report" usebundle => _log_v3("Ensure line(s) '${lines}' absent from ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Ensure line(s) '${lines}' absent from ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); !file_exists:: "success" usebundle => _classes_success("${class_prefix}"); "success" usebundle => _classes_success("${old_class_prefix}"); - "report" usebundle => _log_v3("File ${file} does not exist - line(s) not present", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("File ${path} does not exist - line(s) not present", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_lines_present.cf b/tree/30_generic_methods/file_lines_present.cf index d09130f72..f0d09e5f9 100644 --- a/tree/30_generic_methods/file_lines_present.cf +++ b/tree/30_generic_methods/file_lines_present.cf @@ -19,18 +19,20 @@ # @name File lines present # @description Ensure that one or more lines are present in a file # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter lines Line(s) to add in the file +# +# @parameter_name path file # # @class_prefix file_lines_present -# @class_parameter file +# @class_parameter path -bundle agent file_lines_present(file, lines) +bundle agent file_lines_present(path, lines) { vars: - "old_class_prefix" string => canonify("file_lines_present_${file}"); + "old_class_prefix" string => canonify("file_lines_present_${path}"); - "args" slist => { "${file}", "${lines}" }; + "args" slist => { "${path}", "${lines}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_lines_present_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -44,11 +46,11 @@ bundle agent file_lines_present(file, lines) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "enforce lines content" usebundle => file_content("${file}", "${lines}", "false"); + "enforce lines content" usebundle => file_content("${path}", "${lines}", "false"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Append content ${lines} if needed into ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Append content ${lines} if needed into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_present.cf b/tree/30_generic_methods/file_present.cf index 726a8b23a..cd7ab85a8 100644 --- a/tree/30_generic_methods/file_present.cf +++ b/tree/30_generic_methods/file_present.cf @@ -19,25 +19,27 @@ # @name File present # @description Create a file if it doesn't exist # -# @parameter target File to create (absolute path on the target node) +# @parameter path File to create (absolute path on the target node) +# +# @parameter_name path target # # @class_prefix file_present -# @class_parameter target +# @class_parameter path -bundle agent file_present(target) +bundle agent file_present(path) { vars: - "old_class_prefix" string => canonify("file_present_${target}"); - "args" slist => { "${target}" }; + "old_class_prefix" string => canonify("file_present_${path}"); + "args" slist => { "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_present_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); files: - "${target}" + "${path}" create => "true", classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); methods: - "report" usebundle => _log_v3("Presence of file ${target}", "${target}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Presence of file ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_remove.cf b/tree/30_generic_methods/file_remove.cf index 5a3978d07..e3a0f59de 100644 --- a/tree/30_generic_methods/file_remove.cf +++ b/tree/30_generic_methods/file_remove.cf @@ -21,18 +21,20 @@ # @rename file_absent # @deprecated Use [file_absent](#_file_absent) instead. # -# @parameter target File to remove (absolute path on the target node) +# @parameter path File to remove (absolute path on the target node) +# +# @parameter_name path target # # @class_prefix file_remove -# @class_parameter target +# @class_parameter path -bundle agent file_remove(target) +bundle agent file_remove(path) { vars: - "canonified_target" string => canonify("${target}"); + "canonified_path" string => canonify("${path}"); - "old_class_prefix" string => canonify("file_remove_${target}"); - "args" slist => { "${target}" }; + "old_class_prefix" string => canonify("file_remove_${path}"); + "args" slist => { "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_remove_${report_param}"); @@ -49,13 +51,13 @@ bundle agent file_remove(target) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => file_absent("${target}"); + "action" usebundle => file_absent("${path}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("file_absent_${canonified_target}", "${old_class_prefix}"), - ifvarclass => "file_absent_${canonified_target}_reached"; + "class copy" usebundle => _classes_copy("file_absent_${canonified_path}", "${old_class_prefix}"), + ifvarclass => "file_absent_${canonified_path}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Remove file ${target}", "${target}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Remove file ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_replace_lines.cf b/tree/30_generic_methods/file_replace_lines.cf index ea13ad36b..8b32c1aa8 100644 --- a/tree/30_generic_methods/file_replace_lines.cf +++ b/tree/30_generic_methods/file_replace_lines.cf @@ -37,26 +37,28 @@ # file_replace_lines("/PATH_TO_MY_FILE/file", "(.*)", "my ${match.1} pattern") # ``` # -# @parameter file File name to edit (absolute path on the target node) +# @parameter path File name to edit (absolute path on the target node) # @parameter line Line to match in the file # @parameter replacement Line to add in the file as a replacement # +# @parameter_name path file +# # @class_prefix file_replace_lines -# @class_parameter file +# @class_parameter path -bundle agent file_replace_lines(file, line, replacement) +bundle agent file_replace_lines(path, line, replacement) { vars: pass1:: - "old_class_prefix" string => canonify("file_replace_lines_${file}"); + "old_class_prefix" string => canonify("file_replace_lines_${path}"); # If replacement contains ${match.x}, it would not evaluate to anything outside of file promises, so we # need to exclude it from class prefix pass1.replacement_non_eval:: - "args" slist => { "${file}", "${line}" }; + "args" slist => { "${path}", "${line}" }; pass1.!replacement_non_eval:: - "args" slist => { "${file}", "${line}", "${replacement}" }; + "args" slist => { "${path}", "${line}", "${replacement}" }; pass1:: "report_param" string => join("_", args); @@ -76,7 +78,7 @@ bundle agent file_replace_lines(file, line, replacement) files: pass2:: - "${file}" + "${path}" create => "false", edit_line => regex_replace("${line}", "${replacement}"), edit_defaults => ncf_empty_select("false"), @@ -86,5 +88,5 @@ bundle agent file_replace_lines(file, line, replacement) pass2:: "sanitize" usebundle => _classes_sanitize("${class_prefix}"); "sanitize" usebundle => _classes_sanitize("${old_class_prefix}"); - "report" usebundle => _log_v3("Replace lines with replacement into ${file}", "${file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Replace lines with replacement into ${path}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_report_content.cf b/tree/30_generic_methods/file_report_content.cf index e91d581f7..18a7ecaff 100644 --- a/tree/30_generic_methods/file_report_content.cf +++ b/tree/30_generic_methods/file_report_content.cf @@ -57,38 +57,40 @@ # file_report_content("/etc/hosts", "rudder", "3"); # ``` # -# @parameter target File to report content from +# @parameter path File to report content from # @parameter regex Regex to search in the file (empty for whole file) # @parameter_constraint regex "allow_empty_string" : true # @parameter context Number of context lines when matching regex (default is 0) # @parameter_constraint context "allow_empty_string" : true # @parameter_constraint context "regex" : "^\d*$" # +# @parameter_name path target +# # @class_prefix file_report_content -# @class_parameter target +# @class_parameter path -bundle agent file_report_content(target, regex, context) +bundle agent file_report_content(path, regex, context) { vars: !pass1:: # to avoid rewriting class prefix when setting default - "old_class_prefix" string => canonify("file_report_content_${target}"); - "args" slist => { "${target}", "${regex}", "${context}" }; + "old_class_prefix" string => canonify("file_report_content_${path}"); + "args" slist => { "${path}", "${regex}", "${context}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_report_content_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); pass1.file_exists:: - "content" string => readfile("${target}", "0"), + "content" string => readfile("${path}", "0"), if => "full_file"; - "content" string => execresult("${paths.path[grep]} -E \"${regex}\" -C${context} \"${target}\"", "useshell"), + "content" string => execresult("${paths.path[grep]} -E \"${regex}\" -C${context} \"${path}\"", "useshell"), if => "!full_file"; defaults: "context" string => "0", if_match_regex => ""; classes: - "file_exists" expression => fileexists("${target}"); + "file_exists" expression => fileexists("${path}"); "full_file" expression => strcmp("${regex}", ""); "pass2" expression => "pass1"; @@ -98,13 +100,13 @@ bundle agent file_report_content(target, regex, context) pass2.!file_exists:: "error" usebundle => _classes_failure("${old_class_prefix}"); "error" usebundle => _classes_failure("${class_prefix}"); - "report" usebundle => _log_v3("${target} does not exist", "${target}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("${path} does not exist", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); pass2.file_exists:: "success" usebundle => _classes_success("${old_class_prefix}"); "success" usebundle => _classes_success("${class_prefix}"); - "report" usebundle => _log_v3("${target} contains :${const.n}---${const.n}${content}---${const.n}file content report", "${target}", "${old_class_prefix}", "${class_prefix}", @{args}), + "report" usebundle => _log_v3("${path} contains :${const.n}---${const.n}${content}---${const.n}file content report", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}), if => "full_file"; - "report" usebundle => _log_v3("Searching for '${regex}' in ${target} gives:${const.n}---${const.n}${content}${const.n}---${const.n}file content report", "${target}", "${old_class_prefix}", "${class_prefix}", @{args}), + "report" usebundle => _log_v3("Searching for '${regex}' in ${path} gives:${const.n}---${const.n}${content}${const.n}---${const.n}file content report", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}), if => "!full_file"; } diff --git a/tree/30_generic_methods/file_report_content_head.cf b/tree/30_generic_methods/file_report_content_head.cf index f3084a6e0..59710d823 100644 --- a/tree/30_generic_methods/file_report_content_head.cf +++ b/tree/30_generic_methods/file_report_content_head.cf @@ -44,33 +44,35 @@ # file_report_content("/etc/hosts", "3"); # ``` # -# @parameter target File to report content from +# @parameter path File to report content from # @parameter limit Number of lines to report (default is 10) # @parameter_constraint limit "allow_empty_string" : true # @parameter_constraint limit "regex" : "^\d*$" # +# @parameter_name path target +# # @class_prefix file_report_content_head -# @class_parameter target +# @class_parameter path -bundle agent file_report_content_head(target, limit) +bundle agent file_report_content_head(path, limit) { vars: !pass1:: # to avoid rewriting class prefix when setting default - "old_class_prefix" string => canonify("file_report_content_head_${target}"); - "args" slist => { "${target}", "${limit}" }; + "old_class_prefix" string => canonify("file_report_content_head_${path}"); + "args" slist => { "${path}", "${limit}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_report_content_head_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); pass1.file_exists:: - "content" string => execresult("/usr/bin/head -n${limit} \"${target}\"", "useshell"); + "content" string => execresult("${ncf_paths.path[head]} -n${limit} \"${path}\"", "useshell"); defaults: "limit" string => "10", if_match_regex => ""; classes: - "file_exists" expression => fileexists("${target}"); + "file_exists" expression => fileexists("${path}"); "pass2" expression => "pass1"; "pass1" expression => "any"; @@ -79,10 +81,10 @@ bundle agent file_report_content_head(target, limit) pass2.!file_exists:: "error" usebundle => _classes_failure("${old_class_prefix}"); "error" usebundle => _classes_failure("${class_prefix}"); - "report" usebundle => _log_v3("${target} does not exist", "${target}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("${path} does not exist", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); pass2.file_exists:: "success" usebundle => _classes_success("${old_class_prefix}"); "success" usebundle => _classes_success("${class_prefix}"); - "report" usebundle => _log_v3("${limit} first lines of ${target}:${const.n}---${const.n}${content}---${const.n}file content report", "${target}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("${limit} first lines of ${path}:${const.n}---${const.n}${content}---${const.n}file content report", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_report_content_tail.cf b/tree/30_generic_methods/file_report_content_tail.cf index 37dff4cf3..ea15e4ed1 100644 --- a/tree/30_generic_methods/file_report_content_tail.cf +++ b/tree/30_generic_methods/file_report_content_tail.cf @@ -44,33 +44,35 @@ # file_report_content("/etc/hosts", "3"); # ``` # -# @parameter target File to report content from +# @parameter path File to report content from # @parameter limit Number of lines to report (default is 10) # @parameter_constraint limit "allow_empty_string" : true # @parameter_constraint limit "regex" : "^\d*$" # +# @parameter_name path target +# # @class_prefix file_report_content_tail -# @class_parameter target +# @class_parameter path -bundle agent file_report_content_tail(target, limit) +bundle agent file_report_content_tail(path, limit) { vars: !pass1:: # to avoid rewriting class prefix when setting default - "old_class_prefix" string => canonify("file_report_content_tail_${target}"); - "args" slist => { "${target}", "${limit}" }; + "old_class_prefix" string => canonify("file_report_content_tail_${path}"); + "args" slist => { "${path}", "${limit}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_report_content_tail_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); pass1.file_exists:: - "content" string => execresult("/usr/bin/tail -n${limit} \"${target}\"", "useshell"); + "content" string => execresult("${ncf_paths.path[tail]} -n${limit} \"${path}\"", "useshell"); defaults: "limit" string => "10", if_match_regex => ""; classes: - "file_exists" expression => fileexists("${target}"); + "file_exists" expression => fileexists("${path}"); "pass2" expression => "pass1"; "pass1" expression => "any"; @@ -79,10 +81,10 @@ bundle agent file_report_content_tail(target, limit) pass2.!file_exists:: "error" usebundle => _classes_failure("${old_class_prefix}"); "error" usebundle => _classes_failure("${class_prefix}"); - "report" usebundle => _log_v3("${target} does not exist", "${target}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("${path} does not exist", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); pass2.file_exists:: "success" usebundle => _classes_success("${old_class_prefix}"); "success" usebundle => _classes_success("${class_prefix}"); - "report" usebundle => _log_v3("${limit} last lines of ${target}:${const.n}---${const.n}${content}---${const.n}file content report", "${target}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("${limit} last lines of ${path}:${const.n}---${const.n}${content}---${const.n}file content report", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_symlink_present.cf b/tree/30_generic_methods/file_symlink_present.cf index 6722a6c00..74364d60a 100644 --- a/tree/30_generic_methods/file_symlink_present.cf +++ b/tree/30_generic_methods/file_symlink_present.cf @@ -20,17 +20,19 @@ # @description Create a symlink at a destination path and pointing to a source target except if a file or directory already exists. # # @parameter source Source file (absolute path on the target node) -# @parameter destination Destination file (absolute path on the target node) -# +# @parameter path Destination file (absolute path on the target node) +# +# @parameter_name path destination +# # @class_prefix file_symlink_present -# @class_parameter destination +# @class_parameter path -bundle agent file_symlink_present(source, destination) +bundle agent file_symlink_present(source, path) { vars: - "old_class_prefix" string => canonify("file_symlink_present_${destination}"); + "old_class_prefix" string => canonify("file_symlink_present_${path}"); - "args" slist => { "${source}", "${destination}" }; + "args" slist => { "${source}", "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_symlink_present_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -45,11 +47,11 @@ bundle agent file_symlink_present(source, destination) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "create without enforce" usebundle => file_symlink_present_option("${source}", "${destination}", "false"); + "create without enforce" usebundle => file_symlink_present_option("${source}", "${path}", "false"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Symlink ${destination} targeting ${source} (without overwrite)", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Symlink ${path} targeting ${source} (without overwrite)", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_symlink_present_force.cf b/tree/30_generic_methods/file_symlink_present_force.cf index 30e70f1b6..d6de36384 100644 --- a/tree/30_generic_methods/file_symlink_present_force.cf +++ b/tree/30_generic_methods/file_symlink_present_force.cf @@ -20,17 +20,19 @@ # @description Create a symlink at a destination path and pointing to a source target even if a file or directory already exists. # # @parameter source Source file (absolute path on the target node) -# @parameter destination Destination file (absolute path on the target node) -# +# @parameter path Destination file (absolute path on the target node) +# +# @parameter_name path destination +# # @class_prefix file_symlink_present -# @class_parameter destination +# @class_parameter path -bundle agent file_symlink_present_force(source, destination) +bundle agent file_symlink_present_force(source, path) { vars: - "old_class_prefix" string => canonify("file_symlink_present_${destination}"); + "old_class_prefix" string => canonify("file_symlink_present_${path}"); - "args" slist => { "${source}", "${destination}" }; + "args" slist => { "${source}", "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_symlink_present_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -45,11 +47,11 @@ bundle agent file_symlink_present_force(source, destination) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "create with enforce" usebundle => file_symlink_present_option("${source}", "${destination}", "true"); + "create with enforce" usebundle => file_symlink_present_option("${source}", "${path}", "true"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Symlink ${destination} targeting ${source} with forced overwrite", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Symlink ${path} targeting ${source} with forced overwrite", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_symlink_present_option.cf b/tree/30_generic_methods/file_symlink_present_option.cf index 7f819dc2b..7e51ab692 100644 --- a/tree/30_generic_methods/file_symlink_present_option.cf +++ b/tree/30_generic_methods/file_symlink_present_option.cf @@ -20,29 +20,31 @@ # @description Create a symlink at a destination path and pointing to a source target. This is also possible to enforce its creation # # @parameter source Source file (absolute path on the target node) -# @parameter destination Destination file (absolute path on the target node) +# @parameter path Destination file (absolute path on the target node) # @parameter enforce Force symlink if file already exist (true or false) -# +# +# @parameter_name path destination +# # @class_prefix file_symlink_present -# @class_parameter destination +# @class_parameter path -bundle agent file_symlink_present_option(source, destination, enforce) +bundle agent file_symlink_present_option(source, path, enforce) { vars: - "old_class_prefix" string => canonify("file_symlink_present_${destination}"); - "args" slist => { "${source}", "${destination}", "${enforce}" }; + "old_class_prefix" string => canonify("file_symlink_present_${path}"); + "args" slist => { "${source}", "${path}", "${enforce}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_symlink_present_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); files: # Symlink - "${destination}" + "${path}" link_from => ln_s("${source}"), move_obstructions => "${enforce}", classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"), - comment => "Create the ${destination} symlink pointing to ${source}"; + comment => "Create the ${path} symlink pointing to ${source}"; methods: - "report" usebundle => _log_v3("Symlink ${destination} targeting ${source}", "${destination}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Symlink ${path} targeting ${source}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/file_template_expand.cf b/tree/30_generic_methods/file_template_expand.cf index a3c76299b..6eb758967 100644 --- a/tree/30_generic_methods/file_template_expand.cf +++ b/tree/30_generic_methods/file_template_expand.cf @@ -22,25 +22,27 @@ # @description This is a bundle to expand a template in a specific location # # @parameter tml_file File name (with full path within the framework) of the template file -# @parameter target_file File name (with full path) where to expand the template +# @parameter path File name (with full path) where to expand the template # @parameter mode Mode of destination file # @parameter owner Owner of destination file # @parameter group Group of destination file # +# @parameter_name path target_file +# # @class_prefix file_template_expand -# @class_parameter target_file +# @class_parameter path -bundle agent file_template_expand(tml_file, target_file, mode, owner, group) +bundle agent file_template_expand(tml_file, path, mode, owner, group) { vars: - "old_class_prefix" string => canonify("file_template_expand_${target_file}"); - "args" slist => { "${tml_file}", "${target_file}", "${mode}", "${owner}", "${group}" }; + "old_class_prefix" string => canonify("file_template_expand_${path}"); + "args" slist => { "${tml_file}", "${path}", "${mode}", "${owner}", "${group}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("file_template_expand_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); files: - "${target_file}" + "${path}" create => "true", edit_template => "${sys.workdir}/inputs/${tml_file}", edit_defaults => ncf_empty_select("true"), @@ -50,5 +52,5 @@ bundle agent file_template_expand(tml_file, target_file, mode, owner, group) methods: "sanitize" usebundle => _classes_sanitize("${class_prefix}"); "sanitize" usebundle => _classes_sanitize("${old_class_prefix}"); - "report" usebundle => _log_v3("Expand template ${tml_file} into ${target_file} with perms ${mode}, ${owner}, ${group}", "${target_file}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Expand template ${tml_file} into ${path} with perms ${mode}, ${owner}, ${group}", "${path}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/http_request_check_status_headers.cf b/tree/30_generic_methods/http_request_check_status_headers.cf index a44165703..8e59abac4 100644 --- a/tree/30_generic_methods/http_request_check_status_headers.cf +++ b/tree/30_generic_methods/http_request_check_status_headers.cf @@ -55,7 +55,7 @@ bundle agent http_request_check_status_headers(method, url, expected_status, hea commands: "${ncf_paths.path[curl]}" - args => "-I -L -s -o /dev/null -w \"%{http_code}\" ${url} -X ${method} -H '${headers}' | /bin/grep -q ${expected_status}", + args => "-I -L -s -o /dev/null -w \"%{http_code}\" ${url} -X ${method} -H '${headers}' | ${paths.path[grep]} -q ${expected_status}", contain => in_shell, # We don't define repaired class, as we only query and expect, so using 999 to avoid using this feature classes => classes_generic_return_single_code_two("${old_class_prefix}", "${class_prefix}", "0", "999", "1"); diff --git a/tree/30_generic_methods/kernel_module_configuration.cf b/tree/30_generic_methods/kernel_module_configuration.cf index 0f47a50a0..c4e27052a 100644 --- a/tree/30_generic_methods/kernel_module_configuration.cf +++ b/tree/30_generic_methods/kernel_module_configuration.cf @@ -41,7 +41,7 @@ # #### Example: # # To pass options to a broadcom module -# * `module_name` = b43 +# * `name` = b43 # * `configuration` = options b43 nohwcrypt=1 qos=0 # # Will produce the resulting block in /etc/modprobe.d/managed\_by\_rudder.conf: @@ -51,29 +51,31 @@ # ### b43 end section # ``` # -# @parameter module_name Complete name of the kernel module, as seen by lsmod or listed in /proc/modules +# @parameter name Complete name of the kernel module, as seen by lsmod or listed in /proc/modules # @parameter configuration Complete configuration block to put in /etc/modprobe.d/ # # @parameter_constraint configuration "regex" : "^(alias|blacklist|install|options|remove|softdeps) +.*$" # +# @parameter_name name module_name +# # @class_prefix kernel_module_configuration -# @class_parameter module_name +# @class_parameter name -bundle agent kernel_module_configuration(module_name, configuration) +bundle agent kernel_module_configuration(name, configuration) { vars: "modprobe_dir" string => "/etc/modprobe.d"; - "canonified_module_name" string => canonify("${module_name}"); + "canonified_module_name" string => canonify("${name}"); - "old_class_prefix" string => canonify("kernel_module_configuration_${module_name}"); - "args" slist => { "${module_name}", "${configuration}" }; + "old_class_prefix" string => canonify("kernel_module_configuration_${name}"); + "args" slist => { "${name}", "${configuration}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("kernel_module_configuration_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); "conf_file" string => "${modprobe_dir}/managed_by_rudder.conf"; - "start_section" string => "### ${module_name} start section"; - "end_section" string => "### ${module_name} end section"; + "start_section" string => "### ${name} start section"; + "end_section" string => "### ${name} end section"; "inner_args" slist => { "${conf_file}", "${start_section}", "${end_section}", "${configuration}" }; "report_inner_param" string => join("_", inner_args); "inner_class_prefix" string => string_head(canonify("file_block_present_in_section_${report_inner_param}"), "1000"); @@ -96,6 +98,6 @@ bundle agent kernel_module_configuration(module_name, configuration) pass3:: "result_classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); "old_result_classes" usebundle => _classes_copy("${inner_class_prefix}", "${old_class_prefix}"); - "report" usebundle => _log_v3("Check that the kernel module ${module_name} configuration is correct", "${module_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Check that the kernel module ${name} configuration is correct", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/kernel_module_enabled_at_boot.cf b/tree/30_generic_methods/kernel_module_enabled_at_boot.cf index a48b5cafb..9d76150b4 100644 --- a/tree/30_generic_methods/kernel_module_enabled_at_boot.cf +++ b/tree/30_generic_methods/kernel_module_enabled_at_boot.cf @@ -33,25 +33,27 @@ # If you want to force the module to be loaded, use instead the method `kernel_module_loaded`. # If you want to configure the module, use instead the method `kernel_module_configuration`. # -# @parameter module_name Complete name of the kernel module, as seen by lsmod or listed in /proc/modules +# @parameter name Complete name of the kernel module, as seen by lsmod or listed in /proc/modules +# +# @parameter_name name module_name # # @class_prefix kernel_module_enabled_at_boot -# @class_parameter module_name +# @class_parameter name -bundle agent kernel_module_enabled_at_boot(module_name) +bundle agent kernel_module_enabled_at_boot(name) { vars: systemd:: "module_dir" string => "/etc/modules-load.d"; any:: - "old_class_prefix" string => canonify("kernel_module_enabled_at_boot_${module_name}"); - "args" slist => { "${module_name}" }; + "old_class_prefix" string => canonify("kernel_module_enabled_at_boot_${name}"); + "args" slist => { "${name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("kernel_module_enabled_at_boot_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "inner_args" slist => { "${module_dir}/enabled_by_rudder.conf", "${module_name}" }; + "inner_args" slist => { "${module_dir}/enabled_by_rudder.conf", "${name}" }; "report_inner_param" string => join("_", inner_args); "inner_class_prefix" string => string_head(canonify("file_ensure_lines_present_${report_inner_param}"), "1000"); @@ -65,17 +67,17 @@ bundle agent kernel_module_enabled_at_boot(module_name) methods: pass1.!pass2.systemd:: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "edit_modprobe_config_${class_prefix}" usebundle => file_ensure_lines_present("${module_dir}/enabled_by_rudder.conf", "${module_name}"); + "edit_modprobe_config_${class_prefix}" usebundle => file_ensure_lines_present("${module_dir}/enabled_by_rudder.conf", "${name}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; pass3.!systemd:: "unsupported" usebundle => _classes_failure("${class_prefix}"); "unsupported" usebundle => _classes_failure("${old_class_prefix}"); - "report" usebundle => _log_v3("This method is not supported on non-systemd systems", "${module_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("This method is not supported on non-systemd systems", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); pass3.systemd:: "result_classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); "old_result_classes" usebundle => _classes_copy("${inner_class_prefix}", "${old_class_prefix}"); - "report" usebundle => _log_v3("Ensure that kernel module ${module_name} is enabled on the system", "${module_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Ensure that kernel module ${name} is enabled on the system", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/kernel_module_loaded.cf b/tree/30_generic_methods/kernel_module_loaded.cf index 5991c4ca0..65b2c4dd2 100644 --- a/tree/30_generic_methods/kernel_module_loaded.cf +++ b/tree/30_generic_methods/kernel_module_loaded.cf @@ -21,18 +21,19 @@ # @documentation Ensure that a given kernel module is loaded on the system. # If the module is not loaded, it will try to load it via modprobe. # -# @parameter module_name Complete name of the kernel module, as seen by lsmod or listed in /proc/modules +# @parameter name Complete name of the kernel module, as seen by lsmod or listed in /proc/modules +# +# @parameter_name name module_name # # @class_prefix kernel_module_loaded -# @class_parameter module_name - +# @class_parameter name -bundle agent kernel_module_loaded(module_name) +bundle agent kernel_module_loaded(name) { vars: - "canonified_module_name" string => canonify("${module_name}"); - "old_class_prefix" string => canonify("kernel_module_loaded_${module_name}"); - "args" slist => { "${module_name}" }; + "canonified_module_name" string => canonify("${name}"); + "old_class_prefix" string => canonify("kernel_module_loaded_${name}"); + "args" slist => { "${name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("kernel_module_loaded_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -43,29 +44,29 @@ bundle agent kernel_module_loaded(module_name) "pass1" expression => "any"; pass1.!pass2:: - "module_loaded_init_${canonified_module_name}" expression => returnszero("/sbin/lsmod | cut -d ' ' -f 1 | grep -q ^${module_name}$ #Initial check for loading ${module_name}", "useshell"); + "module_loaded_init_${canonified_module_name}" expression => returnszero("/sbin/lsmod | cut -d ' ' -f 1 | ${paths.path[grep]} -q ^${name}$ #Initial check for loading ${name}", "useshell"); pass1.!pass2.!(global_dry_run|dry_run):: - "module_unloading_${canonified_module_name}" expression => returnszero("/sbin/modprobe ${module_name}", "useshell"), + "module_unloading_${canonified_module_name}" expression => returnszero("/sbin/modprobe ${name}", "useshell"), ifvarclass => "!module_loaded_init_${canonified_module_name}"; pass3:: - "module_loaded_final_${canonified_module_name}" expression => returnszero("/sbin/lsmod | cut -d ' ' -f 1 | grep -q ^${module_name}$ #Final check for loading ${module_name}", "useshell"); + "module_loaded_final_${canonified_module_name}" expression => returnszero("/sbin/lsmod | cut -d ' ' -f 1 | ${paths.path[grep]} -q ^${name}$ #Final check for loading ${name}", "useshell"); methods: pass3:: "failure" usebundle => _classes_failure("${old_class_prefix}"), - ifvarclass => "!module_loaded_final_${module_name}"; + ifvarclass => "!module_loaded_final_${name}"; "failure" usebundle => _classes_failure("${class_prefix}"), - ifvarclass => "!module_loaded_final_${module_name}"; + ifvarclass => "!module_loaded_final_${name}"; "repaired" usebundle => _classes_repaired("${old_class_prefix}"), - ifvarclass => "!module_loaded_init_${canonified_module_name}.module_loaded_final_${module_name}"; + ifvarclass => "!module_loaded_init_${canonified_module_name}.module_loaded_final_${name}"; "repaired" usebundle => _classes_repaired("${class_prefix}"), - ifvarclass => "!module_loaded_init_${canonified_module_name}.module_loaded_final_${module_name}"; + ifvarclass => "!module_loaded_init_${canonified_module_name}.module_loaded_final_${name}"; "success" usebundle => _classes_success("${old_class_prefix}"), - ifvarclass => "module_loaded_init_${canonified_module_name}.module_loaded_final_${module_name}"; + ifvarclass => "module_loaded_init_${canonified_module_name}.module_loaded_final_${name}"; "success" usebundle => _classes_success("${class_prefix}"), - ifvarclass => "module_loaded_init_${canonified_module_name}.module_loaded_final_${module_name}"; + ifvarclass => "module_loaded_init_${canonified_module_name}.module_loaded_final_${name}"; - "report" usebundle => _log_v3("Check that the kernel module ${module_name} is loaded on the system", "${module_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Check that the kernel module ${name} is loaded on the system", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/kernel_module_not_loaded.cf b/tree/30_generic_methods/kernel_module_not_loaded.cf index d2af4e157..1f8e3777e 100644 --- a/tree/30_generic_methods/kernel_module_not_loaded.cf +++ b/tree/30_generic_methods/kernel_module_not_loaded.cf @@ -21,18 +21,20 @@ # @documentation Ensure that a given kernel module is not loaded on the system. # If the module is loaded, it will try to unload it using modprobe. # -# @parameter module_name Complete name of the kernel module, as seen by lsmod or listed in /proc/modules +# @parameter name Complete name of the kernel module, as seen by lsmod or listed in /proc/modules +# +# @parameter_name name module_name # # @class_prefix kernel_module_not_loaded -# @class_parameter module_name +# @class_parameter name -bundle agent kernel_module_not_loaded(module_name) +bundle agent kernel_module_not_loaded(name) { vars: - "canonified_module_name" string => canonify("${module_name}"); - "old_class_prefix" string => canonify("kernel_module_not_loaded_${module_name}"); - "args" slist => { "${module_name}" }; + "canonified_module_name" string => canonify("${name}"); + "old_class_prefix" string => canonify("kernel_module_not_loaded_${name}"); + "args" slist => { "${name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("kernel_module_not_loaded_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -43,29 +45,29 @@ bundle agent kernel_module_not_loaded(module_name) "pass1" expression => "any"; pass1.!pass2:: - "module_not_loaded_init_${canonified_module_name}" not => returnszero("/sbin/lsmod | cut -d ' ' -f 1 | grep -q ^${module_name}$ #Initial check for unloading ${module_name}", "useshell"); + "module_not_loaded_init_${canonified_module_name}" not => returnszero("/sbin/lsmod | cut -d ' ' -f 1 | grep -q ^${name}$ #Initial check for unloading ${name}", "useshell"); pass1.!pass2.!(global_dry_run|dry_run):: - "module_unloading_${canonified_module_name}" expression => returnszero("/sbin/modprobe -r ${module_name}", "useshell"), + "module_unloading_${canonified_module_name}" expression => returnszero("/sbin/modprobe -r ${name}", "useshell"), ifvarclass => "!module_loaded_init_${canonified_module_name}"; pass3:: - "module_not_loaded_final_${canonified_module_name}" not => returnszero("/sbin/lsmod | cut -d ' ' -f 1 | grep -q ^${module_name}$ #Final check for unloading ${module_name}", "useshell"); + "module_not_loaded_final_${canonified_module_name}" not => returnszero("/sbin/lsmod | cut -d ' ' -f 1 | grep -q ^${name}$ #Final check for unloading ${name}", "useshell"); methods: pass3:: "failure" usebundle => _classes_failure("${old_class_prefix}"), - ifvarclass => "!module_not_loaded_final_${module_name}"; + ifvarclass => "!module_not_loaded_final_${name}"; "failure" usebundle => _classes_failure("${class_prefix}"), - ifvarclass => "!module_not_loaded_final_${module_name}"; + ifvarclass => "!module_not_loaded_final_${name}"; "repaired" usebundle => _classes_repaired("${old_class_prefix}"), - ifvarclass => "!module_not_loaded_init_${canonified_module_name}.module_not_loaded_final_${module_name}"; + ifvarclass => "!module_not_loaded_init_${canonified_module_name}.module_not_loaded_final_${name}"; "repaired" usebundle => _classes_repaired("${class_prefix}"), - ifvarclass => "!module_not_loaded_init_${canonified_module_name}.module_not_loaded_final_${module_name}"; + ifvarclass => "!module_not_loaded_init_${canonified_module_name}.module_not_loaded_final_${name}"; "success" usebundle => _classes_success("${old_class_prefix}"), - ifvarclass => "module_not_loaded_init_${canonified_module_name}.module_not_loaded_final_${module_name}"; + ifvarclass => "module_not_loaded_init_${canonified_module_name}.module_not_loaded_final_${name}"; "success" usebundle => _classes_success("${class_prefix}"), - ifvarclass => "module_not_loaded_init_${canonified_module_name}.module_not_loaded_final_${module_name}"; + ifvarclass => "module_not_loaded_init_${canonified_module_name}.module_not_loaded_final_${name}"; - "report" usebundle => _log_v3("Check that the kernel module ${module_name} is not loaded on the system", "${module_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Check that the kernel module ${name} is not loaded on the system", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/package_absent.cf b/tree/30_generic_methods/package_absent.cf index c60a6bbd8..1475e526b 100644 --- a/tree/30_generic_methods/package_absent.cf +++ b/tree/30_generic_methods/package_absent.cf @@ -24,9 +24,9 @@ # @parameter_constraint version "allow_empty_string" : true # @parameter architecture Architecture of the package, can be an architecture name or "default" (defaults to "default") # @parameter_constraint architecture "allow_empty_string" : true -# @parameter provider Package provider to use, can be "yum", "apt", "zypper", "zypper_pattern", "slackpkg", "pkg" or "default" for system default package manager (defaults to "default") +# @parameter provider Package provider to use, can be "yum", "apt", "zypper", "zypper_pattern", "slackpkg", "pkg", "ips", "nimclient" or "default" for system default package manager (defaults to "default") # @parameter_constraint provider "allow_empty_string" : true -# @parameter_constraint provider "select" : [ "", "default", "yum", "apt", "zypper", "zypper_pattern", "slackpkg", "pkg" ] +# @parameter_constraint provider "select" : [ "", "default", "yum", "apt", "zypper", "zypper_pattern", "slackpkg", "pkg", "ips", "nimclient" ] # # @class_prefix package_absent # @class_parameter name diff --git a/tree/30_generic_methods/package_check_installed.cf b/tree/30_generic_methods/package_check_installed.cf index 0fcc54885..63eb4aa87 100644 --- a/tree/30_generic_methods/package_check_installed.cf +++ b/tree/30_generic_methods/package_check_installed.cf @@ -22,39 +22,44 @@ # package is installed, or `package_check_installed_${file_name}_{not_ok, reached, not_kept, failed}` if # the package is not installed # -# @parameter package_name Name of the package to check +# @parameter name Name of the package to check +# +# @parameter_name name package_name # # @class_prefix package_check_installed -# @class_parameter package_name +# @class_parameter name -bundle agent package_check_installed(package_name) +bundle agent package_check_installed(name) { vars: - "old_class_prefix" string => canonify("package_check_installed_${package_name}"); - "args" slist => { "${package_name}" }; + "old_class_prefix" string => canonify("package_check_installed_${name}"); + "args" slist => { "${name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("package_check_installed_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("package_install_${package_name}____latest_verify_false"); + "inner_args" string => { "${name}", "any", "", "", "present", "" }; + "inner_report_param" string => join("_", inner_args); + "full_inner_class_prefix" string => canonify("ncf_package_${inner_report_param}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); classes: "should_report" expression => "${report_data.should_report}"; methods: - "disable_reporting_${class_prefix}" - usebundle => disable_reporting; + "disable_reporting" usebundle => disable_reporting; + "remove_dry_run_mode" usebundle => push_dry_run_mode("true"); + + "check install" usebundle => ncf_package("${name}", "any", "", "", "present", ""); - "check install with latest version" - usebundle => package_install_version_cmp_update("${package_name}", "==", "latest", "verify", "false"); + "restore dry-run" usebundle => pop_dry_run_mode(); + "reenable_reporting" usebundle => enable_reporting, + ifvarclass => "should_report"; - "reenable_reporting_${class_prefix}" usebundle => enable_reporting, - ifvarclass => "should_report"; - "copy old classes" usebundle => _classes_copy("${inner_class_prefix}", "${old_class_prefix}"); - "copy old classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); + "copy old classes" usebundle => _classes_copy("${inner_class_prefix}", "${old_class_prefix}"); + "copy classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); "report" - usebundle => _log_v3("Check that package ${package_name} is installed", "${package_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Check that package ${name} is installed", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/package_install.cf b/tree/30_generic_methods/package_install.cf index 4f3d00dd7..997ebd0b9 100644 --- a/tree/30_generic_methods/package_install.cf +++ b/tree/30_generic_methods/package_install.cf @@ -20,17 +20,19 @@ # @description Install or update a package in its latest version available # @deprecated Use [package_present](#_package_present) instead. # -# @parameter package_name Name of the package to install +# @parameter name Name of the package to install +# +# @parameter_name name package_name # # @class_prefix package_install -# @class_parameter package_name +# @class_parameter name -bundle agent package_install(package_name) +bundle agent package_install(name) { vars: - "old_class_prefix" string => canonify("package_install_${package_name}"); + "old_class_prefix" string => canonify("package_install_${name}"); - "args" slist => { "${package_name}" }; + "args" slist => { "${name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("package_install_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -44,11 +46,11 @@ bundle agent package_install(package_name) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "install latest" usebundle => package_install_version("${package_name}", "latest"); + "install latest" usebundle => package_install_version("${name}", "latest"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Install package ${package_name}", "${package_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Install package ${name}", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/package_install_version.cf b/tree/30_generic_methods/package_install_version.cf index d14a105b2..8ff12f41f 100644 --- a/tree/30_generic_methods/package_install_version.cf +++ b/tree/30_generic_methods/package_install_version.cf @@ -20,24 +20,26 @@ # @description Install or update a package in a specific version # @deprecated Use [package_present](#_package_present) instead. # -# @parameter package_name Name of the package to install +# @parameter name Name of the package to install # @parameter package_version Version of the package to install (can be "latest" to install it in its latest version) # +# @parameter_name name package_name +# # @class_prefix package_install -# @class_parameter package_name +# @class_parameter name -bundle agent package_install_version(package_name, package_version) +bundle agent package_install_version(name, package_version) { vars: - "old_class_prefix" string => canonify("package_install_${package_name}"); + "old_class_prefix" string => canonify("package_install_${name}"); - "args" slist => { "${package_name}", "${package_version}" }; + "args" slist => { "${name}", "${package_version}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("package_install_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - # call is to package_install_version_cmp("${package_name}", "==", "${package_version}", "add"); - "full_inner_class_prefix" string => canonify("package_install_${package_name}_==_${package_version}_add"); + # call is to package_install_version_cmp("${name}", "==", "${package_version}", "add"); + "full_inner_class_prefix" string => canonify("package_install_${name}_==_${package_version}_add"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); @@ -47,12 +49,12 @@ bundle agent package_install_version(package_name, package_version) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "install with version" usebundle => package_install_version_cmp("${package_name}", "==", "${package_version}", "add"); + "install with version" usebundle => package_install_version_cmp("${name}", "==", "${package_version}", "add"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Install package ${package_name} version ${package_version}", "${package_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Install package ${name} version ${package_version}", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/package_install_version_cmp.cf b/tree/30_generic_methods/package_install_version_cmp.cf index 5e7568738..314b731e5 100644 --- a/tree/30_generic_methods/package_install_version_cmp.cf +++ b/tree/30_generic_methods/package_install_version_cmp.cf @@ -25,26 +25,28 @@ # "any" usebundle => package_install_version_cmp("postgresql", ">=", "9.1", "verify"); # ``` # -# @parameter package_name Name of the package to install or verify +# @parameter name Name of the package to install or verify # @parameter version_comparator Comparator between installed version and defined version, can be ==,<=,>=,<,>,!= # @parameter package_version The version of the package to verify (can be "latest" for latest version) # @parameter action Action to perform, can be add, verify (defaults to verify) # @parameter_constraint version_comparator "select" : [ "==", "<=", ">=", "<", ">" , "!=" ] -# +# +# @parameter_name name package_name +# # @class_prefix package_install -# @class_parameter package_name +# @class_parameter name -bundle agent package_install_version_cmp(package_name, version_comparator, package_version, action) +bundle agent package_install_version_cmp(name, version_comparator, package_version, action) { vars: - "old_class_prefix" string => canonify("package_install_${package_name}"); + "old_class_prefix" string => canonify("package_install_${name}"); - "args" slist => { "${package_name}", "${version_comparator}", "${package_version}", "${action}" }; + "args" slist => { "${name}", "${version_comparator}", "${package_version}", "${action}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("package_install_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - # call is to package_install_version_cmp_update("${package_name}", "${version_comparator}", "${package_version}", "${action}", "true") + # call is to package_install_version_cmp_update("${name}", "${version_comparator}", "${package_version}", "${action}", "true") "full_inner_class_prefix" string => canonify("package_install_${report_param}_true"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); @@ -54,11 +56,11 @@ bundle agent package_install_version_cmp(package_name, version_comparator, packa methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "install or update" usebundle => package_install_version_cmp_update("${package_name}", "${version_comparator}", "${package_version}", "${action}", "true"); + "install or update" usebundle => package_install_version_cmp_update("${name}", "${version_comparator}", "${package_version}", "${action}", "true"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Install package ${package_name} version ${version_comparator} ${package_version}", "${package_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Install package ${name} version ${version_comparator} ${package_version}", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/package_install_version_cmp_update.cf b/tree/30_generic_methods/package_install_version_cmp_update.cf index 21fe07b85..94fe5fed1 100644 --- a/tree/30_generic_methods/package_install_version_cmp_update.cf +++ b/tree/30_generic_methods/package_install_version_cmp_update.cf @@ -25,25 +25,27 @@ # "any" usebundle => package_install_version_cmp_update("postgresql", ">=", "9.1", "verify", "false"); # ``` # -# @parameter package_name Name of the package to install or verify +# @parameter name Name of the package to install or verify # @parameter version_comparator Comparator between installed version and defined version, can be ==,<=,>=,<,>,!= # @parameter package_version The version of the package to verify (can be "latest" for latest version) # @parameter action Action to perform, can be add, verify (defaults to verify) # @parameter update_policy While verifying packages, check against latest version ("true") or just installed ("false") # @parameter_constraint version_comparator "select" : [ "==", "<=", ">=", "<", ">" , "!=" ] -# +# +# @parameter_name name package_name +# # @class_prefix package_install -# @class_parameter package_name +# @class_parameter name -bundle agent package_install_version_cmp_update(package_name, version_comparator, package_version, action, update_policy) +bundle agent package_install_version_cmp_update(name, version_comparator, package_version, action, update_policy) { vars: - "canonified_package_name" string => canonify("${package_name}"); - "old_class_prefix" string => "package_install_${canonified_package_name}"; + "canonified_name" string => canonify("${name}"); + "old_class_prefix" string => "package_install_${canonified_name}"; # don't rewrite the class prefix based on defaults !pass1:: - "args" slist => { "${package_name}", "${version_comparator}", "${package_version}", "${action}", "${update_policy}" }; + "args" slist => { "${name}", "${version_comparator}", "${package_version}", "${action}", "${update_policy}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("package_install_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -55,7 +57,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator "update_policy" string => "add", if_match_regex => "false"; classes: - "local_package" expression => regcmp("(http:|file:)?/.*", "${package_name}"); + "local_package" expression => regcmp("(http:|file:)?/.*", "${name}"); "version_not_specified" expression => strcmp("latest", "${package_version}"); "immediate" expression => strcmp("immediate", "${action}"); "warn" expression => strcmp("warn", "${action}"); @@ -68,7 +70,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator ## Debian support ## !version_not_specified.local_package.debian:: - "${package_name}" + "${name}" package_policy => "${update_policy}", package_version => "${package_version}", package_select => "${version_comparator}", @@ -78,7 +80,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator !version_not_specified.!local_package.debian:: - "${package_name}" + "${name}" package_policy => "${update_policy}", package_version => "${package_version}", package_select => "${version_comparator}", @@ -88,14 +90,14 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator version_not_specified.local_package.debian:: - "${package_name}" + "${name}" package_policy => "${update_policy}", package_method => debian_local_install, classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"), action => policy("${action}"); version_not_specified.!local_package.debian:: - "${package_name}" + "${name}" package_policy => "${update_policy}", package_method => apt_get, classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"), @@ -103,7 +105,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator ## RedHat support ## !version_not_specified.local_package.redhat:: - "${package_name}" + "${name}" package_policy => "${update_policy}", package_version => "${package_version}", package_select => "${version_comparator}", @@ -112,7 +114,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator action => policy("${action}"); !version_not_specified.!local_package.redhat:: - "${package_name}" + "${name}" package_policy => "${update_policy}", package_version => "${package_version}", package_select => "${version_comparator}", @@ -122,7 +124,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator version_not_specified.local_package.redhat:: - "${package_name}" + "${name}" package_policy => "${update_policy}", package_method => redhat_local_install, classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"), @@ -130,7 +132,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator version_not_specified.!local_package.redhat:: - "${package_name}" + "${name}" package_policy => "${update_policy}", package_method => yum_rpm_no_version, classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"), @@ -138,7 +140,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator ## SUSE support ## !version_not_specified.local_package.SuSE:: - "${package_name}" + "${name}" package_policy => "${update_policy}", package_version => "${package_version}", package_select => "${version_comparator}", @@ -147,7 +149,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator action => policy("${action}"); !version_not_specified.!local_package.SuSE:: - "${package_name}" + "${name}" package_policy => "${update_policy}", package_version => "${package_version}", package_select => "${version_comparator}", @@ -157,7 +159,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator version_not_specified.local_package.SuSE:: - "${package_name}" + "${name}" package_policy => "${update_policy}", package_method => ncf_generic, classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"), @@ -165,7 +167,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator version_not_specified.!local_package.SuSE:: - "${package_name}" + "${name}" package_policy => "${update_policy}", package_method => ncf_generic, classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"), @@ -173,18 +175,18 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator methods: (debian|redhat|SuSE).immediate.!update:: - "Reports" usebundle => _log_v3("Install package ${package_name}", "${package_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "Reports" usebundle => _log_v3("Install package ${name}", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); (debian|redhat|SuSE).immediate.update:: - "Reports" usebundle => _log_v3("Install or update package ${package_name} in version ${package_version}", "${package_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "Reports" usebundle => _log_v3("Install or update package ${name} in version ${package_version}", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); (debian|redhat|SuSE).!immediate.!version_not_specified:: - "Reports" usebundle => _log_v3("Verify that package ${package_name} is installed in version ${package_version}", "${package_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "Reports" usebundle => _log_v3("Verify that package ${name} is installed in version ${package_version}", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); (debian|redhat|SuSE).!immediate.version_not_specified.update:: - "Reports" usebundle => _log_v3("Verify that package ${package_name} is installed and up-to-date", "${package_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "Reports" usebundle => _log_v3("Verify that package ${name} is installed and up-to-date", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); (debian|redhat|SuSE).!immediate.version_not_specified.!update:: - "Reports" usebundle => _log_v3("Verify that package ${package_name} is installed", "${package_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "Reports" usebundle => _log_v3("Verify that package ${name} is installed", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); !(debian|redhat|SuSE):: "force failure class" usebundle => _classes_failure("${class_prefix}"); "force failure class" usebundle => _classes_failure("${old_class_prefix}"); - "report failure" usebundle => _log_v3("Install or update package ${package_name} - systems other than Debian-, Red Hat- and SuSE-like are not currently supported", "${package_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report failure" usebundle => _log_v3("Install or update package ${name} - systems other than Debian-, Red Hat- and SuSE-like are not currently supported", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/package_present.cf b/tree/30_generic_methods/package_present.cf index 373fe6643..1a93ca507 100644 --- a/tree/30_generic_methods/package_present.cf +++ b/tree/30_generic_methods/package_present.cf @@ -24,9 +24,9 @@ # @parameter_constraint version "allow_empty_string" : true # @parameter architecture Architecture of the package, can be an architecture name or "default" (defaults to "default") # @parameter_constraint architecture "allow_empty_string" : true -# @parameter provider Package provider to use, can be "yum", "apt", "zypper", "zypper_pattern", "slackpkg", "pkg" or "default" for system default package manager (defaults to "default") +# @parameter provider Package provider to use, can be "yum", "apt", "zypper", "zypper_pattern", "slackpkg", "pkg", "ips", "nimclient" or "default" for system default package manager (defaults to "default") # @parameter_constraint provider "allow_empty_string" : true -# @parameter_constraint provider "select" : [ "", "default", "yum", "apt", "zypper", "zypper_pattern", "slackpkg", "pkg" ] +# @parameter_constraint provider "select" : [ "", "default", "yum", "apt", "zypper", "zypper_pattern", "slackpkg", "pkg", "ips", "nimclient" ] # # @class_prefix package_present # @class_parameter name diff --git a/tree/30_generic_methods/package_remove.cf b/tree/30_generic_methods/package_remove.cf index e7c7cb2cb..904eee1bd 100644 --- a/tree/30_generic_methods/package_remove.cf +++ b/tree/30_generic_methods/package_remove.cf @@ -25,28 +25,30 @@ # "any" usebundle => package_remove("htop"); # ``` # -# @parameter package_name Name of the package to remove +# @parameter name Name of the package to remove +# +# @parameter_name name package_name # # @class_prefix package_remove -# @class_parameter package_name +# @class_parameter name -bundle agent package_remove(package_name) +bundle agent package_remove(name) { vars: - "canonified_package_name" string => canonify("${package_name}"); - "old_class_prefix" string => "package_remove_${canonified_package_name}"; - "args" slist => { "${package_name}" }; + "canonified_name" string => canonify("${name}"); + "old_class_prefix" string => "package_remove_${canonified_name}"; + "args" slist => { "${name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("package_remove_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); packages: - "${package_name}" + "${name}" package_policy => "delete", package_method => generic, classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); methods: - "placeholder" usebundle => _log_v3("Remove package ${package_name}", "${package_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "placeholder" usebundle => _log_v3("Remove package ${name}", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/package_state.cf b/tree/30_generic_methods/package_state.cf index fc5138fcb..c5a1e3bd9 100644 --- a/tree/30_generic_methods/package_state.cf +++ b/tree/30_generic_methods/package_state.cf @@ -93,6 +93,8 @@ # # Older implementations of zypper patterns may not be supported by this module. # +# This provider doesn't support installation from a file. +# # ##### slackpkg # # This package provider uses Slackware's `installpkg` and `upgradepkg` tools to manage @@ -101,6 +103,17 @@ # ##### pkg # # This package provider uses FreeBSD's *pkg* to manage packages on the system. +# This provider doesn't support installation from a file. +# +# #### ips +# +# This package provider uses Solaris's pkg command to manage packages from IPS repositories on the system. +# This provider doesn't support installation from a file. +# +# #### nimclient +# +# This package provider uses AIX's nim client to manage packages from nim +# This provider doesn't support installation from a file. # # #### Examples # @@ -125,9 +138,9 @@ # @parameter_constraint version "allow_empty_string" : true # @parameter architecture Architecture of the package, can be an architecture name or "default" (defaults to "default") # @parameter_constraint architecture "allow_empty_string" : true -# @parameter provider Package provider to use, can be "yum", "apt", "zypper", "zypper_pattern", "slackpkg", "pkg" or "default" for system default package manager (defaults to "default") +# @parameter provider Package provider to use, can be "yum", "apt", "zypper", "zypper_pattern", "slackpkg", "pkg", "ips", "nimclient" or "default" for system default package manager (defaults to "default") # @parameter_constraint provider "allow_empty_string" : true -# @parameter_constraint provider "select" : [ "", "default", "yum", "apt", "zypper", "zypper_pattern", "slackpkg", "pkg" ] +# @parameter_constraint provider "select" : [ "", "default", "yum", "apt", "zypper", "zypper_pattern", "slackpkg", "pkg", "ips", "nimclient" ] # @parameter state State of the package, can be "present" or "absent" (defaults to "present") # @parameter_constraint state "allow_empty_string" : true # @parameter_constraint state "select" : [ "", "present", "absent" ] diff --git a/tree/30_generic_methods/package_state_options.cf b/tree/30_generic_methods/package_state_options.cf index 70f2cab40..608d0bf65 100644 --- a/tree/30_generic_methods/package_state_options.cf +++ b/tree/30_generic_methods/package_state_options.cf @@ -25,9 +25,9 @@ # @parameter_constraint version "allow_empty_string" : true # @parameter architecture Architecture of the package, can be an architecture name or "default" (defaults to "default") # @parameter_constraint architecture "allow_empty_string" : true -# @parameter provider Package provider to use, can be "yum", "apt", "zypper", "zypper_pattern", "slackpkg", "pkg" or "default" for system default package manager (defaults to "default") +# @parameter provider Package provider to use, can be "yum", "apt", "zypper", "zypper_pattern", "slackpkg", "pkg", "ips", "nimclient" or "default" for system default package manager (defaults to "default") # @parameter_constraint provider "allow_empty_string" : true -# @parameter_constraint provider "select" : [ "", "default", "yum", "apt", "zypper", "zypper_pattern", "slackpkg", "pkg" ] +# @parameter_constraint provider "select" : [ "", "default", "yum", "apt", "zypper", "zypper_pattern", "slackpkg", "pkg", "ips", "nimclient" ] # @parameter state State of the package, can be "present" or "absent" (defaults to "present") # @parameter_constraint state "allow_empty_string" : true # @parameter_constraint state "select" : [ "", "present", "absent" ] diff --git a/tree/30_generic_methods/package_verify.cf b/tree/30_generic_methods/package_verify.cf index 480bb2eb0..1a5cb711c 100644 --- a/tree/30_generic_methods/package_verify.cf +++ b/tree/30_generic_methods/package_verify.cf @@ -19,16 +19,18 @@ # @name Package verify # @description Verify if a package is installed in its latest version available # -# @parameter package_name Name of the package to verify +# @parameter name Name of the package to verify +# +# @parameter_name name package_name # # @class_prefix package_install -# @class_parameter package_name +# @class_parameter name -bundle agent package_verify(package_name) +bundle agent package_verify(name) { vars: - "old_class_prefix" string => canonify("package_install_${package_name}"); - "args" slist => { "${package_name}" }; + "old_class_prefix" string => canonify("package_install_${name}"); + "args" slist => { "${name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("package_install_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -42,12 +44,12 @@ bundle agent package_verify(package_name) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "verify latest" usebundle => package_verify_version("${package_name}", "latest"); + "verify latest" usebundle => package_verify_version("${name}", "latest"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Verify that package ${package_name} is installed", "${package_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Verify that package ${name} is installed", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/package_verify_version.cf b/tree/30_generic_methods/package_verify_version.cf index 790a7e34a..d76681ab2 100644 --- a/tree/30_generic_methods/package_verify_version.cf +++ b/tree/30_generic_methods/package_verify_version.cf @@ -19,23 +19,26 @@ # @name Package verify version # @description Verify if a package is installed in a specific version # -# @parameter package_name Name of the package to verify -# @parameter package_version Version of the package to verify (can be "latest" for latest version) +# @parameter name Name of the package to verify +# @parameter version Version of the package to verify (can be "latest" for latest version) +# +# @parameter_name name package_name +# @parameter_name name package_version # # @class_prefix package_install -# @class_parameter package_name +# @class_parameter name -bundle agent package_verify_version(package_name, package_version) +bundle agent package_verify_version(name, version) { vars: - "old_class_prefix" string => canonify("package_install_${package_name}"); - "args" slist => { "${package_name}", "${package_version}" }; + "old_class_prefix" string => canonify("package_install_${name}"); + "args" slist => { "${name}", "${version}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("package_install_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - # call is to package_install_version_cmp("${package_name}", "==", "${package_version}", "verify"); - "full_inner_class_prefix" string => canonify("package_install_${package_name}_==_${package_version}_verify"); + # call is to package_install_version_cmp("${name}", "==", "${version}", "verify"); + "full_inner_class_prefix" string => canonify("package_install_${name}_==_${version}_verify"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); classes: @@ -44,11 +47,11 @@ bundle agent package_verify_version(package_name, package_version) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "package verify" usebundle => package_install_version_cmp("${package_name}", "==", "${package_version}", "verify"); + "package verify" usebundle => package_install_version_cmp("${name}", "==", "${version}", "verify"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Verify that package ${package_name} is installed in version ${package_version}", "${package_name}", "${old_class_prefix}", "", @{args}); + "report" usebundle => _log_v3("Verify that package ${name} is installed in version ${version}", "${name}", "${old_class_prefix}", "", @{args}); } diff --git a/tree/30_generic_methods/service_action.cf b/tree/30_generic_methods/service_action.cf index 45432f70e..2c0330e59 100644 --- a/tree/30_generic_methods/service_action.cf +++ b/tree/30_generic_methods/service_action.cf @@ -76,22 +76,24 @@ # service_restart("apache2"); # ``` # -# @parameter service_name Name of the service +# @parameter name Name of the service # @parameter action Action to trigger on the service (start, stop, restart, reload, ...) +# +# @parameter_name name service_name # # @class_prefix service_action -# @class_parameter service_name +# @class_parameter name -bundle agent service_action(service_name, action) +bundle agent service_action(name, action) { vars: - "canonified_service_name" string => canonify("${service_name}"); + "canonified_name" string => canonify("${name}"); "canonified_action" string => canonify("${action}"); - "old_class_prefix" string => "service_action_${canonified_service_name}"; + "old_class_prefix" string => "service_action_${canonified_name}"; - "args" slist => { "${service_name}", "${action}" }; + "args" slist => { "${name}", "${action}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("service_action_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -107,7 +109,7 @@ bundle agent service_action(service_name, action) "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => ncf_services("${service_name}", "${action}"); + "action" usebundle => ncf_services("${name}", "${action}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, @@ -117,5 +119,5 @@ bundle agent service_action(service_name, action) "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Run action ${action} on service ${service_name}", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Run action ${action} on service ${name}", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_check_disabled_at_boot.cf b/tree/30_generic_methods/service_check_disabled_at_boot.cf index 7723c4e8b..1c38fa332 100644 --- a/tree/30_generic_methods/service_check_disabled_at_boot.cf +++ b/tree/30_generic_methods/service_check_disabled_at_boot.cf @@ -19,20 +19,22 @@ # @name Service check disabled at boot # @description Check if a service is set to not start at boot using the appropriate method # -# @parameter service_name Service name (as recognized by systemd, init.d, etc...) +# @parameter name Service name (as recognized by systemd, init.d, etc...) # +# @parameter_name name service_name +# # @class_prefix service_check_disabled_at_boot -# @class_parameter service_name -# This bundle will define a condition service_check_disabled_at_boot_${service_name}_{kept,ok,not_ok,failed,reached} +# @class_parameter name +# This bundle will define a condition service_check_disabled_at_boot_${name}_{kept,ok,not_ok,failed,reached} -bundle agent service_check_disabled_at_boot(service_name) +bundle agent service_check_disabled_at_boot(name) { vars: - "canonified_service_name" string => canonify("${service_name}"); + "canonified_name" string => canonify("${name}"); - "old_class_prefix" string => "service_check_disabled_at_boot_${canonified_service_name}"; + "old_class_prefix" string => "service_check_disabled_at_boot_${canonified_name}"; - "args" slist => { "${service_name}" }; + "args" slist => { "${name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("service_check_disabled_at_boot_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -48,21 +50,21 @@ bundle agent service_check_disabled_at_boot(service_name) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "check_enabled" usebundle => ncf_services("${service_name}", "is-enabled"); + "check_enabled" usebundle => ncf_services("${name}", "is-enabled"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "success" usebundle => _classes_success("${old_class_prefix}"), - ifvarclass => "ncf_services_${canonified_service_name}_is_enabled_not_ok"; + ifvarclass => "ncf_services_${canonified_name}_is_enabled_not_ok"; "success" usebundle => _classes_success("${class_prefix}"), ifvarclass => "${inner_class_prefix}_not_ok"; "failure" usebundle => _classes_failure("${old_class_prefix}"), - ifvarclass => "ncf_services_${canonified_service_name}_is_enabled_ok"; + ifvarclass => "ncf_services_${canonified_name}_is_enabled_ok"; "failure" usebundle => _classes_failure("${class_prefix}"), ifvarclass => "${inner_class_prefix}_ok"; - "reports" usebundle => _log_v3("Check if service ${service_name} is disabled at boot", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "reports" usebundle => _log_v3("Check if service ${name} is disabled at boot", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_check_running.cf b/tree/30_generic_methods/service_check_running.cf index f8164f633..85fb6254d 100644 --- a/tree/30_generic_methods/service_check_running.cf +++ b/tree/30_generic_methods/service_check_running.cf @@ -19,19 +19,21 @@ # @name Service check running # @description Check if a service is running using the appropriate method # -# @parameter service_name Process name -# +# @parameter name Process name +# +# @parameter_name name service_name +# # @class_prefix service_check_running -# @class_parameter service_name +# @class_parameter name -bundle agent service_check_running(service_name) +bundle agent service_check_running(name) { vars: - "canonified_service_name" string => canonify("${service_name}"); + "canonified_name" string => canonify("${name}"); - "old_class_prefix" string => canonify("service_check_running_${service_name}"); + "old_class_prefix" string => canonify("service_check_running_${name}"); - "args" slist => { "${service_name}" }; + "args" slist => { "${name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("service_check_running_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -47,15 +49,15 @@ bundle agent service_check_running(service_name) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "check_active" usebundle => ncf_services("${service_name}", "is-active"); + "check_active" usebundle => ncf_services("${name}", "is-active"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("ncf_services_${canonified_service_name}_is_active", "${old_class_prefix}"), - ifvarclass => "ncf_services_${canonified_service_name}_is_active_reached"; + "class copy" usebundle => _classes_copy("ncf_services_${canonified_name}_is_active", "${old_class_prefix}"), + ifvarclass => "ncf_services_${canonified_name}_is_active_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Check if the service ${service_name} is started", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Check if the service ${name} is started", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_check_running_ps.cf b/tree/30_generic_methods/service_check_running_ps.cf index 97e0265e3..c15d7b8fb 100644 --- a/tree/30_generic_methods/service_check_running_ps.cf +++ b/tree/30_generic_methods/service_check_running_ps.cf @@ -19,19 +19,21 @@ # @name Service check running ps # @description Check if a service is running using ps # -# @parameter service_regex Regular expression used to select a process in ps output +# @parameter name Regular expression used to select a process in ps output +# +# @parameter_name name service_regex # # @class_prefix service_check_running -# @class_parameter service_regex +# @class_parameter name -bundle agent service_check_running_ps(service_regex) +bundle agent service_check_running_ps(name) { vars: - "canonified_service_regex" string => canonify("${service_regex}"); + "canonified_name" string => canonify("${name}"); - "old_class_prefix" string => canonify("service_check_running_${service_regex}"); + "old_class_prefix" string => canonify("service_check_running_${name}"); - "args" slist => { "${service_regex}" }; + "args" slist => { "${name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("service_check_running_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -48,17 +50,17 @@ bundle agent service_check_running_ps(service_regex) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "check_active" usebundle => ncf_services("${service_regex}", "is-active-process"); + "check_active" usebundle => ncf_services("${name}", "is-active-process"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("ncf_services_${canonified_service_regex}_is_active_process", "${old_class_prefix}"), - ifvarclass => "ncf_services_${canonified_service_regex}_is_active_process_reached"; + "class copy" usebundle => _classes_copy("ncf_services_${canonified_name}_is_active_process", "${old_class_prefix}"), + ifvarclass => "ncf_services_${canonified_name}_is_active_process_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; "report" - usebundle => _log_v3("Check if the service ${service_regex} is started using ps", "${service_regex}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Check if the service ${name} is started using ps", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_check_started_at_boot.cf b/tree/30_generic_methods/service_check_started_at_boot.cf index 157c6fb57..d2bd6fa43 100644 --- a/tree/30_generic_methods/service_check_started_at_boot.cf +++ b/tree/30_generic_methods/service_check_started_at_boot.cf @@ -19,20 +19,22 @@ # @name Service check started at boot # @description Check if a service is set to start at boot using the appropriate method # -# @parameter service_name Service name (as recognized by systemd, init.d, etc...) +# @parameter name Service name (as recognized by systemd, init.d, etc...) +# +# @parameter_name name service_name # # @class_prefix service_check_started_at_boot -# @class_parameter service_name -# This bundle will define a condition service_check_started_at_boot_${service_name}_{kept,ok,not_ok,failed,reached} +# @class_parameter name +# This bundle will define a condition service_check_started_at_boot_${name}_{kept,ok,not_ok,failed,reached} -bundle agent service_check_started_at_boot(service_name) +bundle agent service_check_started_at_boot(name) { vars: - "canonified_service_name" string => canonify("${service_name}"); + "canonified_name" string => canonify("${name}"); - "old_class_prefix" string => "service_check_started_at_boot_${canonified_service_name}"; + "old_class_prefix" string => "service_check_started_at_boot_${canonified_name}"; - "args" slist => { "${service_name}" }; + "args" slist => { "${name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("service_check_started_at_boot_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -48,15 +50,15 @@ bundle agent service_check_started_at_boot(service_name) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "check_enabled" usebundle => ncf_services("${service_name}", "is-enabled"); + "check_enabled" usebundle => ncf_services("${name}", "is-enabled"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("ncf_services_${canonified_service_name}_is_enabled", "${old_class_prefix}"), - ifvarclass => "ncf_services_${canonified_service_name}_is_enabled_reached"; + "class copy" usebundle => _classes_copy("ncf_services_${canonified_name}_is_enabled", "${old_class_prefix}"), + ifvarclass => "ncf_services_${canonified_name}_is_enabled_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "reports" usebundle => _log_v3("Check if service ${service_name} is started at boot", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "reports" usebundle => _log_v3("Check if service ${name} is started at boot", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_disabled.cf b/tree/30_generic_methods/service_disabled.cf index 40c7fed74..62b4a6026 100644 --- a/tree/30_generic_methods/service_disabled.cf +++ b/tree/30_generic_methods/service_disabled.cf @@ -19,22 +19,24 @@ # @name Service disabled at boot # @description Force a service not to be enabled at boot # -# @parameter service_name Service name (as recognized by systemd, init.d, etc...) +# @parameter name Service name (as recognized by systemd, init.d, etc...) +# +# @parameter_name name service_name # # @class_prefix service_disabled -# @class_parameter service_name +# @class_parameter name -bundle agent service_disabled(service_name) +bundle agent service_disabled(name) { vars: any:: - "canonified_service_name" string => canonify("${service_name}"); + "canonified_name" string => canonify("${name}"); - "old_class_prefix" string => "service_disabled_${canonified_service_name}"; + "old_class_prefix" string => "service_disabled_${canonified_name}"; - "args" slist => { "${service_name}" }; + "args" slist => { "${name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("service_disabled_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -51,23 +53,23 @@ bundle agent service_disabled(service_name) usebundle => disable_reporting; "disable_at_boot" - usebundle => service_check_disabled_at_boot("${service_name}"); + usebundle => service_check_disabled_at_boot("${name}"); "undefine_at_boot" - usebundle => ncf_services("${service_name}", "disable"), - ifvarclass => "service_check_disabled_at_boot_${canonified_service_name}_not_ok"; + usebundle => ncf_services("${name}", "disable"), + ifvarclass => "service_check_disabled_at_boot_${canonified_name}_not_ok"; "already undefined" usebundle => _classes_success("${old_class_prefix}"), - ifvarclass => "service_check_disabled_at_boot_${canonified_service_name}_ok"; + ifvarclass => "service_check_disabled_at_boot_${canonified_name}_ok"; "already undefined" usebundle => _classes_success("${class_prefix}"), - ifvarclass => "service_check_disabled_at_boot_${canonified_service_name}_ok"; + ifvarclass => "service_check_disabled_at_boot_${canonified_name}_ok"; "copy classes" - usebundle => _classes_copy("ncf_services_${canonified_service_name}_disable", "${old_class_prefix}"), - ifvarclass => "service_check_disabled_at_boot_${canonified_service_name}_not_ok"; + usebundle => _classes_copy("ncf_services_${canonified_name}_disable", "${old_class_prefix}"), + ifvarclass => "service_check_disabled_at_boot_${canonified_name}_not_ok"; "copy classes" usebundle => _classes_copy("${inner_class_prefix}_disable", "${class_prefix}"), @@ -77,6 +79,6 @@ bundle agent service_disabled(service_name) usebundle => enable_reporting, ifvarclass => "should_report"; "report" - usebundle => _log_v3("Ensure service ${service_name} is disabled at boot", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Ensure service ${name} is disabled at boot", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_enabled.cf b/tree/30_generic_methods/service_enabled.cf index e8350a405..3f88fb4fa 100644 --- a/tree/30_generic_methods/service_enabled.cf +++ b/tree/30_generic_methods/service_enabled.cf @@ -19,28 +19,30 @@ # @name Service enabled at boot # @description Force a service to be started at boot # -# @parameter service_name Service name (as recognized by systemd, init.d, Windows, SRC, SMF, etc...) +# @parameter name Service name (as recognized by systemd, init.d, Windows, SRC, SMF, etc...) +# +# @parameter_name name service_name # # @class_prefix service_enabled -# @class_parameter service_name +# @class_parameter name -bundle agent service_enabled(service_name) +bundle agent service_enabled(name) { vars: any:: - "canonified_service_name" string => canonify("${service_name}"); + "canonified_name" string => canonify("${name}"); - "old_class_prefix" string => "service_enabled_${canonified_service_name}"; + "old_class_prefix" string => "service_enabled_${canonified_name}"; - "args" slist => { "${service_name}" }; + "args" slist => { "${name}" }; - "full_class_prefix" string => canonify("service_enabled_${service_name}"); + "full_class_prefix" string => canonify("service_enabled_${name}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("service_check_started_at_boot_${service_name}"); + "full_inner_class_prefix" string => canonify("service_check_started_at_boot_${name}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); @@ -52,10 +54,10 @@ bundle agent service_enabled(service_name) "disable_reporting_${class_prefix}" usebundle => disable_reporting; "check_at_boot" - usebundle => service_check_started_at_boot("${service_name}"); + usebundle => service_check_started_at_boot("${name}"); "define_at_boot" - usebundle => ncf_services("${service_name}", "enable"), + usebundle => ncf_services("${name}", "enable"), ifvarclass => "${inner_class_prefix}_not_ok"; "already defined" @@ -67,17 +69,17 @@ bundle agent service_enabled(service_name) ifvarclass => "${inner_class_prefix}_ok"; "copy classes" - usebundle => _classes_copy("ncf_services_${canonified_service_name}_enable", "${old_class_prefix}"), + usebundle => _classes_copy("ncf_services_${canonified_name}_enable", "${old_class_prefix}"), ifvarclass => "${inner_class_prefix}_not_ok"; "copy classes" - usebundle => _classes_copy("ncf_services_${canonified_service_name}_enable", "${class_prefix}"), + usebundle => _classes_copy("ncf_services_${canonified_name}_enable", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_not_ok"; "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "report" - usebundle => _log_v3("Ensure service ${service_name} is started at boot", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Ensure service ${name} is started at boot", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_ensure_disabled_at_boot.cf b/tree/30_generic_methods/service_ensure_disabled_at_boot.cf index db19d2742..78236a4e0 100644 --- a/tree/30_generic_methods/service_ensure_disabled_at_boot.cf +++ b/tree/30_generic_methods/service_ensure_disabled_at_boot.cf @@ -21,22 +21,24 @@ # @deprecated Use [service_disabled_at_boot](#_service_disabled_at_boot) instead. # @description Force a service not to be enabled at boot # -# @parameter service_name Service name (as recognized by systemd, init.d, etc...) +# @parameter name Service name (as recognized by systemd, init.d, etc...) +# +# @parameter_name name service_name # # @class_prefix service_ensure_disabled_at_boot -# @class_parameter service_name +# @class_parameter name -bundle agent service_ensure_disabled_at_boot(service_name) +bundle agent service_ensure_disabled_at_boot(name) { vars: any:: - "canonified_service_name" string => canonify("${service_name}"); + "canonified_name" string => canonify("${name}"); - "old_class_prefix" string => "service_ensure_disabled_at_boot_${canonified_service_name}"; + "old_class_prefix" string => "service_ensure_disabled_at_boot_${canonified_name}"; - "args" slist => { "${service_name}" }; + "args" slist => { "${name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("service_ensure_disabled_at_boot_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -52,15 +54,15 @@ bundle agent service_ensure_disabled_at_boot(service_name) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => service_disabled("${service_name}"); + "action" usebundle => service_disabled("${name}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("service_disabled_${canonified_service_name}", "${old_class_prefix}"), - ifvarclass => "service_disabled_${canonified_service_name}_reached"; + "class copy" usebundle => _classes_copy("service_disabled_${canonified_name}", "${old_class_prefix}"), + ifvarclass => "service_disabled_${canonified_name}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; "report" - usebundle => _log_v3("Ensure service ${service_name} is disabled at boot", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Ensure service ${name} is disabled at boot", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_ensure_running.cf b/tree/30_generic_methods/service_ensure_running.cf index 8f9f1b6ee..e6f8fa6d9 100644 --- a/tree/30_generic_methods/service_ensure_running.cf +++ b/tree/30_generic_methods/service_ensure_running.cf @@ -21,19 +21,21 @@ # @rename service_started # @deprecated Use [service_started](#_service_started) instead. # -# @parameter service_name Service name (as recognized by systemd, init.d, etc...) +# @parameter name Service name (as recognized by systemd, init.d, etc...) # +# @parameter_name name service_name +# # @class_prefix service_ensure_running -# @class_parameter service_name +# @class_parameter name -bundle agent service_ensure_running(service_name) +bundle agent service_ensure_running(name) { vars: - "canonified_service_name" string => canonify("${service_name}"); + "canonified_name" string => canonify("${name}"); - "old_class_prefix" string => "service_ensure_running_${canonified_service_name}"; + "old_class_prefix" string => "service_ensure_running_${canonified_name}"; - "args" slist => { "${service_name}" }; + "args" slist => { "${name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("service_ensure_running_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -50,15 +52,15 @@ bundle agent service_ensure_running(service_name) "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => service_started("${service_name}"); + "action" usebundle => service_started("${name}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("service_started_${canonified_service_name}", "${old_class_prefix}"), - if => "service_started_${canonified_service_name}_reached"; + "class copy" usebundle => _classes_copy("service_started_${canonified_name}", "${old_class_prefix}"), + if => "service_started_${canonified_name}_reached"; "new classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), if => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Ensure that service ${service_name} is running", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Ensure that service ${name} is running", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_ensure_running_path.cf b/tree/30_generic_methods/service_ensure_running_path.cf index 4b5ac89da..750d7eb47 100644 --- a/tree/30_generic_methods/service_ensure_running_path.cf +++ b/tree/30_generic_methods/service_ensure_running_path.cf @@ -22,22 +22,25 @@ # @deprecated Use [service_started_path](#_service_started_path) instead. # -# @parameter service_name Service name (as recognized by systemd, init.d, Windows, etc...) -# @parameter service_path Service with its path, as in the output from 'ps' +# @parameter name Service name (as recognized by systemd, init.d, Windows, etc...) +# @parameter path Service with its path, as in the output from 'ps' +# +# @parameter_name name service_name +# @parameter_name path service_path # @class_prefix service_ensure_running -# @class_parameter service_name +# @class_parameter name -bundle agent service_ensure_running_path(service_name, service_path) +bundle agent service_ensure_running_path(name, path) { vars: - "canonified_service_name" string => canonify("${service_name}"); - "canonified_service_path" string => canonify("${service_path}"); + "canonified_name" string => canonify("${name}"); + "canonified_path" string => canonify("${path}"); - "old_class_prefix" string => "service_ensure_running_${canonified_service_name}"; + "old_class_prefix" string => "service_ensure_running_${canonified_name}"; - "args" slist => { "${service_name}", "${service_path}" }; + "args" slist => { "${name}", "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("service_ensure_running_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -52,7 +55,7 @@ bundle agent service_ensure_running_path(service_name, service_path) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => service_started_path("${service_name}", "${service_path}"); + "action" usebundle => service_started_path("${name}", "${path}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; @@ -62,7 +65,7 @@ bundle agent service_ensure_running_path(service_name, service_path) "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; "report" - usebundle => _log_v3("Ensure that service ${service_name} is running", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Ensure that service ${name} is running", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_ensure_started_at_boot.cf b/tree/30_generic_methods/service_ensure_started_at_boot.cf index 7f1fcce3a..e02689fb3 100644 --- a/tree/30_generic_methods/service_ensure_started_at_boot.cf +++ b/tree/30_generic_methods/service_ensure_started_at_boot.cf @@ -21,29 +21,31 @@ # @rename service_enabled # @deprecated Use [service_enabled](#_service_enabled) instead. # -# @parameter service_name Service name (as recognized by systemd, init.d, Windows, SRC, SMF, etc...) +# @parameter name Service name (as recognized by systemd, init.d, Windows, SRC, SMF, etc...) +# +# @parameter_name name service_name # # @class_prefix service_ensure_started_at_boot -# @class_parameter service_name +# @class_parameter name -bundle agent service_ensure_started_at_boot(service_name) +bundle agent service_ensure_started_at_boot(name) { vars: any:: - "canonified_service_name" string => canonify("${service_name}"); + "canonified_name" string => canonify("${name}"); - "old_class_prefix" string => "service_ensure_started_at_boot_${canonified_service_name}"; + "old_class_prefix" string => "service_ensure_started_at_boot_${canonified_name}"; - "full_class_prefix" string => canonify("service_ensure_started_at_boot_${service_name}"); + "full_class_prefix" string => canonify("service_ensure_started_at_boot_${name}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("service_enabled_${service_name}"); + "full_inner_class_prefix" string => canonify("service_enabled_${name}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); - "args" slist => { "${service_name}" }; + "args" slist => { "${name}" }; @@ -53,14 +55,14 @@ bundle agent service_ensure_started_at_boot(service_name) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => service_enabled("${service_name}"); + "action" usebundle => service_enabled("${name}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("service_enabled_${canonified_service_name}", "${old_class_prefix}"), - ifvarclass => "service_enabled_${canonified_service_name}_reached"; + "class copy" usebundle => _classes_copy("service_enabled_${canonified_name}", "${old_class_prefix}"), + ifvarclass => "service_enabled_${canonified_name}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Ensure service ${service_name} is started at boot", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Ensure service ${name} is started at boot", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_ensure_stopped.cf b/tree/30_generic_methods/service_ensure_stopped.cf index b99651d7c..c09e2c2f1 100644 --- a/tree/30_generic_methods/service_ensure_stopped.cf +++ b/tree/30_generic_methods/service_ensure_stopped.cf @@ -21,24 +21,26 @@ # @rename service_stopped # @deprecated Use [service_stopped](#_service_stopped) instead. # -# @parameter service_name Service +# @parameter name Service # +# @parameter_name name service_name +# # @class_prefix service_ensure_stopped -# @class_parameter service_name +# @class_parameter name -bundle agent service_ensure_stopped(service_name) +bundle agent service_ensure_stopped(name) { vars: - "canonified_service_name" string => canonify("${service_name}"); + "canonified_name" string => canonify("${name}"); - "old_class_prefix" string => "service_ensure_stopped_${canonified_service_name}"; + "old_class_prefix" string => "service_ensure_stopped_${canonified_name}"; "class_prefix" string => "${old_class_prefix}"; - "args" slist => { "${service_name}" }; + "args" slist => { "${name}" }; - "full_inner_class_prefix" string => canonify("service_stopped_${service_name}"); + "full_inner_class_prefix" string => canonify("service_stopped_${name}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); @@ -50,7 +52,7 @@ bundle agent service_ensure_stopped(service_name) "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => service_stopped("${service_name}"); + "action" usebundle => service_stopped("${name}"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; @@ -59,6 +61,6 @@ bundle agent service_ensure_stopped(service_name) "class copy" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; "report" - usebundle => _log_v3("Ensure that service ${service_name} is stopped", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Ensure that service ${name} is stopped", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_reload.cf b/tree/30_generic_methods/service_reload.cf index 99f073e18..c287f587c 100644 --- a/tree/30_generic_methods/service_reload.cf +++ b/tree/30_generic_methods/service_reload.cf @@ -21,26 +21,28 @@ # @action # @documentation See [service_action](#_service_action) for documentation. # -# @parameter service_name Name of the service +# @parameter name Name of the service # +# @parameter_name name service_name +# # @class_prefix service_reload -# @class_parameter service_name +# @class_parameter name -bundle agent service_reload(service_name) +bundle agent service_reload(name) { vars: - "canonified_service_name" string => canonify("${service_name}"); + "canonified_name" string => canonify("${name}"); - "old_class_prefix" string => "service_reload_${canonified_service_name}"; + "old_class_prefix" string => "service_reload_${canonified_name}"; - "args" slist => { "${service_name}" }; + "args" slist => { "${name}" }; - "full_class_prefix" string => canonify("service_reload_${service_name}"); + "full_class_prefix" string => canonify("service_reload_${name}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("service_action_${service_name}_reload"); + "full_inner_class_prefix" string => canonify("service_action_${name}_reload"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); classes: @@ -50,7 +52,7 @@ bundle agent service_reload(service_name) "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "reload" usebundle => service_action("${service_name}", "reload"); + "reload" usebundle => service_action("${name}", "reload"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, @@ -60,5 +62,5 @@ bundle agent service_reload(service_name) "class copy" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Reload service ${service_name}", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Reload service ${name}", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_restart.cf b/tree/30_generic_methods/service_restart.cf index b9ae6d027..9a4ed1f71 100644 --- a/tree/30_generic_methods/service_restart.cf +++ b/tree/30_generic_methods/service_restart.cf @@ -21,21 +21,23 @@ # @action # @documentation See [service_action](#_service_action) for documentation. # -# @parameter service_name Name of the service +# @parameter name Name of the service # +# @parameter_name name service_name +# # @class_prefix service_restart -# @class_parameter service_name +# @class_parameter name -bundle agent service_restart(service_name) +bundle agent service_restart(name) { vars: - "old_class_prefix" string => canonify("service_restart_${service_name}"); + "old_class_prefix" string => canonify("service_restart_${name}"); - "args" slist => { "${service_name}" }; - "full_class_prefix" string => canonify("service_restart_${service_name}"); + "args" slist => { "${name}" }; + "full_class_prefix" string => canonify("service_restart_${name}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("service_action_${service_name}_restart"); + "full_inner_class_prefix" string => canonify("service_action_${name}_restart"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); classes: @@ -44,7 +46,7 @@ bundle agent service_restart(service_name) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "restart always" usebundle => service_restart_if("${service_name}","any"); + "restart always" usebundle => service_restart_if("${name}","any"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, @@ -52,5 +54,5 @@ bundle agent service_restart(service_name) # old_class_prefix in service_restart_if is the same as in service_restart "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Restart service ${service_name}", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Restart service ${name}", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_restart_if.cf b/tree/30_generic_methods/service_restart_if.cf index 95bc76fc9..bec6e8718 100644 --- a/tree/30_generic_methods/service_restart_if.cf +++ b/tree/30_generic_methods/service_restart_if.cf @@ -21,27 +21,29 @@ # @deprecated Use [service_restart](#_service_restart) with a condition # @documentation See [service_action](#_service_action) for documentation. # -# @parameter service_name Name of the service +# @parameter name Name of the service # @parameter trigger_class class(es) which will trigger the restart of Service "(package_service_installed|service_conf_changed)" by example # +# @parameter_name name service_name +# # @class_prefix service_restart -# @class_parameter service_name +# @class_parameter name -bundle agent service_restart_if(service_name, trigger_class) +bundle agent service_restart_if(name, trigger_class) { vars: - "canonified_service_name" string => canonify("${service_name}"); + "canonified_name" string => canonify("${name}"); - "old_class_prefix" string => "service_restart_${canonified_service_name}"; + "old_class_prefix" string => "service_restart_${canonified_name}"; - "args" slist => { "${service_name}", "${trigger_class}" }; + "args" slist => { "${name}", "${trigger_class}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("service_restart_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("service_action_${service_name}_restart"); + "full_inner_class_prefix" string => canonify("service_action_${name}_restart"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); classes: @@ -59,7 +61,7 @@ bundle agent service_restart_if(service_name, trigger_class) # parenthesis used to negate all the classes ifvarclass => "!(${trigger_class})"; - "restart" usebundle => service_action("${service_name}", "restart"), + "restart" usebundle => service_action("${name}", "restart"), ifvarclass => "${trigger_class}"; "class copy" usebundle => _classes_copy("${inner_class_prefix}", "${old_class_prefix}"), @@ -72,5 +74,5 @@ bundle agent service_restart_if(service_name, trigger_class) usebundle => enable_reporting, ifvarclass => "should_report"; - "report" usebundle => _log_v3("Restart service ${canonified_service_name} if '${trigger_class}' condition defined", "${service_name}", "service_restart_${canonified_service_name}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Restart service ${canonified_name} if '${trigger_class}' condition defined", "${name}", "service_restart_${canonified_name}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_start.cf b/tree/30_generic_methods/service_start.cf index 3ac6972fa..b9831ad68 100644 --- a/tree/30_generic_methods/service_start.cf +++ b/tree/30_generic_methods/service_start.cf @@ -23,25 +23,27 @@ # Otherwise, simply call [service_started](#_service_started) # @documentation See [service_action](#_service_action) for documentation. # -# @parameter service_name Name of the service -# +# @parameter name Name of the service +# +# @parameter_name name service_name +# # @class_prefix service_start -# @class_parameter service_name +# @class_parameter name -bundle agent service_start(service_name) +bundle agent service_start(name) { vars: - "canonified_service_name" string => canonify("${service_name}"); + "canonified_name" string => canonify("${name}"); - "old_class_prefix" string => "service_start_${canonified_service_name}"; + "old_class_prefix" string => "service_start_${canonified_name}"; - "args" slist => { "${service_name}" }; + "args" slist => { "${name}" }; - "full_class_prefix" string => canonify("service_start_${service_name}"); + "full_class_prefix" string => canonify("service_start_${name}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("service_action_${service_name}_start"); + "full_inner_class_prefix" string => canonify("service_action_${name}_start"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); @@ -52,7 +54,7 @@ bundle agent service_start(service_name) "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "start" usebundle => service_action("${service_name}", "start"); + "start" usebundle => service_action("${name}", "start"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, @@ -62,6 +64,6 @@ bundle agent service_start(service_name) "class copy" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Start service ${service_name}", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Start service ${name}", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_started.cf b/tree/30_generic_methods/service_started.cf index 6f607b06f..e6d5b3762 100644 --- a/tree/30_generic_methods/service_started.cf +++ b/tree/30_generic_methods/service_started.cf @@ -19,24 +19,24 @@ # @name Service started # @description Ensure that a service is running using the appropriate method # -# @parameter service_name Service name (as recognized by systemd, init.d, etc...) -# +# @parameter name Service name (as recognized by systemd, init.d, etc...) +# +# @parameter_name name service_name +# # @class_prefix service_started -# @class_parameter service_name +# @class_parameter name -bundle agent service_started(service_name) +bundle agent service_started(name) { vars: - "canonified_service_name" string => canonify("${service_name}"); - - "old_class_prefix" string => "service_started_${canonified_service_name}"; + "old_class_prefix" string => canonify("service_started_${name}"); - "args" slist => { "${service_name}" }; + "args" slist => { "${name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("service_started_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("service_start_${report_param}"); + "full_inner_class_prefix" string => canonify("service_action_${report_param}_start"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); "full_inner_class_prefix_check" string => canonify("service_check_running_${report_param}"); @@ -48,19 +48,19 @@ bundle agent service_started(service_name) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - - "check_running" usebundle => service_check_running("${service_name}"); + + "check_running" usebundle => service_check_running("${name}"); "start if not running" - usebundle => service_start("${service_name}"), + usebundle => service_action("${name}", "start"), ifvarclass => "!${inner_class_prefix_check}_kept"; "class copy if not running" - usebundle => _classes_copy("service_start_${canonified_service_name}", "${old_class_prefix}"), + usebundle => _classes_copy("${full_inner_class_prefix}", "${old_class_prefix}"), ifvarclass => "!${inner_class_prefix_check}_kept"; "class copy if not running" - usebundle => _classes_copy("service_start_${canonified_service_name}", "${class_prefix}"), + usebundle => _classes_copy("${full_inner_class_prefix}", "${class_prefix}"), ifvarclass => "!${inner_class_prefix_check}_kept"; "class if running" @@ -70,12 +70,12 @@ bundle agent service_started(service_name) "class if running" usebundle => _classes_success("${old_class_prefix}"), ifvarclass => "${inner_class_prefix_check}_kept"; - - + + "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "report" - usebundle => _log_v3("Ensure that service ${service_name} is running", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Ensure that service ${name} is running", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_started_path.cf b/tree/30_generic_methods/service_started_path.cf index 45962281b..04d50a6e9 100644 --- a/tree/30_generic_methods/service_started_path.cf +++ b/tree/30_generic_methods/service_started_path.cf @@ -18,31 +18,31 @@ # @name Service started with service path # @description Ensure that a service is running using the appropriate method, specifying the path of the service in the ps output, or using Windows task manager -# -# @parameter service_name Service name (as recognized by systemd, init.d, Windows, etc...) -# @parameter service_path Service with its path, as in the output from 'ps' - +# +# @parameter name Service name (as recognized by systemd, init.d, Windows, etc...) +# @parameter path Service with its path, as in the output from 'ps' +# +# @parameter_name name service_name +# @parameter_name path service_path +# # @class_prefix service_started -# @class_parameter service_name +# @class_parameter name -bundle agent service_started_path(service_name, service_path) +bundle agent service_started_path(name, path) { vars: - "canonified_service_name" string => canonify("${service_name}"); - "canonified_service_path" string => canonify("${service_path}"); + "old_class_prefix" string => canonify("service_started_${name}"); - "old_class_prefix" string => "service_started_${canonified_service_name}"; - - "args" slist => { "${service_name}", "${service_path}" }; + "args" slist => { "${name}", "${path}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("service_started_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix_start" string => canonify("service_start_${service_name}"); + "full_inner_class_prefix_start" string => canonify("service_action_${name}_start"); "inner_class_prefix_start" string => string_head("${full_inner_class_prefix_start}", "1000"); - "full_inner_class_prefix_is_active" string => canonify("service_check_running_${service_path}"); + "full_inner_class_prefix_is_active" string => canonify("service_check_running_${path}"); "inner_class_prefix_is_active" string => string_head("${full_inner_class_prefix_is_active}", "1000"); classes: @@ -52,10 +52,10 @@ bundle agent service_started_path(service_name, service_path) "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "check running" usebundle => service_check_running_ps("${service_path}"); + "check running" usebundle => service_check_running_ps("${path}"); "start if not running" - usebundle => service_start("${service_name}"), + usebundle => service_action("${name}", "start"), ifvarclass => "!${inner_class_prefix_is_active}_kept"; "class copy if not running" @@ -69,16 +69,16 @@ bundle agent service_started_path(service_name, service_path) "class if running" usebundle => _classes_success("${class_prefix}"), ifvarclass => "${inner_class_prefix_is_active}_kept"; - + "class if running" usebundle => _classes_success("${old_class_prefix}"), ifvarclass => "${inner_class_prefix_is_active}_kept"; - + "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "report" - usebundle => _log_v3("Ensure that service ${service_name} is running", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Ensure that service ${name} is running", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_stop.cf b/tree/30_generic_methods/service_stop.cf index 23c756386..2d957f057 100644 --- a/tree/30_generic_methods/service_stop.cf +++ b/tree/30_generic_methods/service_stop.cf @@ -23,25 +23,27 @@ # Otherwise, simply call [service_stopped](#_service_stopped) # @documentation See [service_action](#_service_action) for documentation. # -# @parameter service_name Name of the service +# @parameter name Name of the service # +# @parameter_name name service_name +# # @class_prefix service_stop -# @class_parameter service_name +# @class_parameter name -bundle agent service_stop(service_name) +bundle agent service_stop(name) { vars: - "canonified_service_name" string => canonify("${service_name}"); + "canonified_name" string => canonify("${name}"); - "old_class_prefix" string => "service_stop_${canonified_service_name}"; + "old_class_prefix" string => "service_stop_${canonified_name}"; - "args" slist => { "${service_name}" }; + "args" slist => { "${name}" }; - "full_class_prefix" string => canonify("service_stop_${service_name}"); + "full_class_prefix" string => canonify("service_stop_${name}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("service_action_${service_name}_stop"); + "full_inner_class_prefix" string => canonify("service_action_${name}_stop"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); classes: @@ -51,7 +53,7 @@ bundle agent service_stop(service_name) "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "stop" usebundle => service_action("${service_name}", "stop"); + "stop" usebundle => service_action("${name}", "stop"); "reenable_reporting_${class_prefix}" usebundle => enable_reporting, @@ -61,6 +63,6 @@ bundle agent service_stop(service_name) "class copy" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Stop service ${service_name}", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Stop service ${name}", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/service_stopped.cf b/tree/30_generic_methods/service_stopped.cf index a41f11ccf..f0a214b8c 100644 --- a/tree/30_generic_methods/service_stopped.cf +++ b/tree/30_generic_methods/service_stopped.cf @@ -19,20 +19,20 @@ # @name Service stopped # @description Ensure that a service is stopped using the appropriate method # -# @parameter service_name Service -# +# @parameter name Service +# +# @parameter_name name service_name +# # @class_prefix service_stopped -# @class_parameter service_name +# @class_parameter name -bundle agent service_stopped(service_name) +bundle agent service_stopped(name) { vars: - "canonified_service_name" string => canonify("${service_name}"); + "old_class_prefix" string => canonify("service_stopped_${name}"); - "old_class_prefix" string => "service_stopped_${canonified_service_name}"; - - "args" slist => { "${service_name}" }; + "args" slist => { "${name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("service_stopped_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); @@ -40,7 +40,7 @@ bundle agent service_stopped(service_name) "full_inner_class_prefix_check" string => canonify("service_check_running_${report_param}"); "inner_class_prefix_check" string => string_head("${full_inner_class_prefix_check}", "1000"); - "full_inner_class_prefix_stop" string => canonify("service_stop_${report_param}"); + "full_inner_class_prefix_stop" string => canonify("service_action_${report_param}_stop"); "inner_class_prefix_stop" string => string_head("${full_inner_class_prefix_stop}", "1000"); classes: @@ -51,12 +51,12 @@ bundle agent service_stopped(service_name) usebundle => disable_reporting; "check running" - usebundle => service_check_running("${service_name}"); + usebundle => service_check_running("${name}"); # If service_check_running has detected a process, it will result in # a success, so we have to stop the process "stop if running" - usebundle => service_stop("${service_name}"), + usebundle => service_action("${name}", "stop"), ifvarclass => "${inner_class_prefix_check}_kept"; # If service_check_running has no detected any process, it will not result @@ -64,7 +64,7 @@ bundle agent service_stopped(service_name) "create success class" usebundle => _classes_success("${old_class_prefix}"), ifvarclass => "!${inner_class_prefix_check}_kept"; - + # If service_check_running has detected a process, the process will be # stopped and the result class should be the same as this promise. "class copy if running" @@ -79,6 +79,6 @@ bundle agent service_stopped(service_name) usebundle => enable_reporting, ifvarclass => "should_report"; "report" - usebundle => _log_v3("Ensure that service ${service_name} is stopped", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Ensure that service ${name} is stopped", "${name}", "${old_class_prefix}", "${class_prefix}", @{args}); } diff --git a/tree/30_generic_methods/user_group.cf b/tree/30_generic_methods/user_group.cf index ba7504cbb..e75fe596c 100644 --- a/tree/30_generic_methods/user_group.cf +++ b/tree/30_generic_methods/user_group.cf @@ -26,7 +26,7 @@ # # ##### Parameters # -# `user` : the user login +# `login` : the user login # `group_name`: secondary group name the user should belong to (non-exclusive) # # #### Examples @@ -39,38 +39,41 @@ # Note that it will make sure that user test is in group dev, but won't remove it # from other groups it may belong to # -# @parameter user User login +# @parameter login User login # @parameter group_name Secondary group name for the user +# +# @parameter_name login user +# # @class_prefix user_group -# @class_parameter user +# @class_parameter login -bundle agent user_group(user, group_name) { +bundle agent user_group(login, group_name) { vars: - "old_class_prefix" string => canonify("user_group_${user}"); + "old_class_prefix" string => canonify("user_group_${login}"); - "args" slist => { "${user}", "${group_name}" }; + "args" slist => { "${login}", "${group_name}" }; "report_param" string => join("_", args); "full_class_prefix" string => canonify("user_group_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "add_user_to_group_cmd" string => "${paths.usermod} -a -G ${group_name} ${user}"; + "add_user_to_group_cmd" string => "${paths.usermod} -a -G ${group_name} ${login}"; "full_inner_class_prefix" string => canonify("command_execution_${add_user_to_group_cmd}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); user_exists.group_exists:: - "groups_test" string => execresult("${ncf_paths.path[id]} -Gn ${user} # with ${group_name}", "useshell"); + "groups_test" string => execresult("${ncf_paths.path[id]} -Gn ${login} # with ${group_name}", "useshell"); "current_groups" slist => string_split("${groups_test}", " ", "999999"); # if we needed to change the group, check groups afterwards pass2.!within_group:: - "groups_test_post_change" string => execresult("${ncf_paths.path[id]} -Gn ${user} #post change with ${group_name}", "useshell"), + "groups_test_post_change" string => execresult("${ncf_paths.path[id]} -Gn ${login} #post change with ${group_name}", "useshell"), if => "${inner_class_prefix}_reached"; "current_groups_post_change" slist => string_split("${groups_test_post_change}", " ", "999999"), if => "${inner_class_prefix}_reached"; classes: - "user_exists" expression => userexists("${user}"); + "user_exists" expression => userexists("${login}"); "group_exists" expression => groupexists("${group_name}"); "should_report" expression => "${report_data.should_report}"; @@ -110,7 +113,7 @@ bundle agent user_group(user, group_name) { "error" usebundle => _classes_failure("${class_prefix}"); "report_failure" - usebundle => _log_v3("User ${user} or group ${group_name} don't exist,", "${user}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("User ${login} or group ${group_name} don't exist,", "${login}", "${old_class_prefix}", "${class_prefix}", @{args}); pass3.user_exists.group_exists.!within_group:: @@ -127,5 +130,5 @@ bundle agent user_group(user, group_name) { if => "!${inner_class_prefix}_error.group_corrected"; pass3.user_exists.group_exists:: "report" - usebundle => _log_v3("Secondary group ${group_name} for user ${user}", "${user}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Secondary group ${group_name} for user ${login}", "${login}", "${old_class_prefix}", "${class_prefix}", @{args}); }