File tree Expand file tree Collapse file tree
management/command-dispatcher Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3333 "subdirectory" : " reporting/client-initiated-reporting" ,
3434 "steps" : [" json def.json def.json" ]
3535 },
36+ "command-dispatcher" : {
37+ "description" : " Command dispatcher for running shell commands on schedule" ,
38+ "subdirectory" : " management/command-dispatcher" ,
39+ "steps" : [
40+ " copy main.cf services/cfbs/modules/command-dispatcher/main.cf" ,
41+ " policy_files services/cfbs/command-dispatcher/main.cf" ,
42+ " bundles command_dispatcher:main" ,
43+ " input ./input.json def.json"
44+ ],
45+ "input" : [
46+ {
47+ "type" : " list" ,
48+ "variable" : " commands_to_run" ,
49+ "namespace" : " command_dispatcher" ,
50+ "bundle" : " main" ,
51+ "label" : " Command" ,
52+ "subtype" : [
53+ {
54+ "key" : " command" ,
55+ "type" : " string" ,
56+ "label" : " Command" ,
57+ "question" : " Command to run"
58+ },
59+ {
60+ "key" : " condition" ,
61+ "type" : " string" ,
62+ "label" : " Condition" ,
63+ "question" : " Condition for when to run" ,
64+ "default" : " any"
65+ },
66+ {
67+ "key" : " ifelapsed" ,
68+ "type" : " string" ,
69+ "label" : " ifelapsed" ,
70+ "question" : " Number of minutes between promise assessments" ,
71+ "default" : " 5"
72+ }
73+ ],
74+ "while" : " Do you want to specify more commands to be run?"
75+ }
76+ ]
77+ },
3678 "conditional-installer" : {
3779 "description" : " Allows you to specify packages you want installed and conditions for where you want them installed, as well as a list of packages you generally want uninstalled." ,
3880 "subdirectory" : " security/conditional-installer" ,
Original file line number Diff line number Diff line change 1+ body file control
2+ {
3+ namespace => "command_dispatcher";
4+ }
5+ bundle agent main
6+ {
7+ classes:
8+ "enabled"
9+ expression => isvariable("commands_to_run");
10+ "run_$(i)"
11+ expression => "$(_condition[$(i)])";
12+
13+ vars:
14+ enabled::
15+ "i"
16+ slist => getindices(commands_to_run);
17+
18+ "_command[$(i)]"
19+ string => "$(commands_to_run[$(i)][command])",
20+ if => isvariable("commands_to_run[$(i)][command]");
21+
22+ "_condition[$(i)]"
23+ string => ifelse(
24+ not(strcmp("$(commands_to_run[$(i)][condition])", "")),
25+ "$(commands_to_run[$(i)][condition])",
26+ "any");
27+
28+ "_ifelapsed[$(i)]"
29+ string => ifelse(
30+ not(strcmp("$(commands_to_run[$(i)][ifelapsed])", "")),
31+ "$(commands_to_run[$(i)][ifelapsed])",
32+ "5");
33+
34+ reports:
35+ enabled::
36+ "Command [$(i)]: $(_command[$(i)]), condition: $(_condition[$(i)]), ifelapsed: $(_ifelapsed[$(i)])";
37+ !enabled::
38+ "Command-dispatcher: commands_to_run variable not found";
39+
40+ commands:
41+ enabled::
42+ "$(_command[$(i)])"
43+ if => "run_$(i)",
44+ action => ifelapsed("$(_ifelapsed[$(i)])"),
45+ contain => in_shell;
46+ }
47+ body contain in_shell
48+ {
49+ useshell => "true";
50+ exec_owner => "root";
51+ exec_timeout => "300";
52+ }
53+ body action ifelapsed(x)
54+ {
55+ ifelapsed => "$(x)";
56+ }
57+ body file control
58+ {
59+ namespace => "default";
60+ }
61+ bundle agent __main__
62+ {
63+ methods:
64+ "command_dispatcher:main";
65+ }
You can’t perform that action at this time.
0 commit comments