-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfailsafe.cf
194 lines (166 loc) · 5.8 KB
/
failsafe.cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
################################################################################
# THIS FILE REPRESENTS A FALL-BACK SOLUTION FOR THE PRIMARY FAILSAFE FILE.
# IF THE PRIMARY FAILSAFE/UPDATE LOSES FUNCTIONALITY DUE TO MODIFICATIONS MADE
# BY THE USER, CFENGINE WILL RECOVER BY USING THIS FALL-BACK BOOTSTRAPPED FILE.
# NEVER EDIT THIS FILE, YOU WILL HAVE TO LOG ON TO EVERY NODE MANAGED BY
# CFENGINE TO RECTIFY POTENTIAL ERRORS IF SOMETHING GOES WRONG.
################################################################################
body common control
{
bundlesequence => { "cfe_internal_update" };
nova_edition::
host_licenses_paid => "25";
}
################################################################################
body agent control
{
skipidentify => "true";
}
################################################################################
bundle agent cfe_internal_update
{
classes:
any::
"have_ppkeys"
expression => fileexists("$(sys.workdir)/ppkeys/localhost.pub"),
handle => "cfe_internal_bootstrap_update_classes_have_ppkeys";
"have_promises_cf"
expression => fileexists("$(sys.workdir)/inputs/promises.cf"),
handle => "cfe_internal_bootstrap_update_classes_have_promises_cf";
#
commands:
!have_ppkeys::
"$(sys.cf_key)"
handle => "cfe_internal_bootstrap_update_commands_generate_keys";
#
files:
!windows::
"$(sys.workdir)/inputs"
handle => "cfe_internal_bootstrap_update_files_sys_workdir_inputs_not_windows",
copy_from => u_scp("/var/cfengine/masterfiles"),
depth_search => u_recurse("inf"),
classes => success("got_policy");
windows::
"$(sys.workdir)\inputs"
handle => "cfe_internal_bootstrap_update_files_sys_workdir_inputs_windows",
copy_from => u_scp("/var/cfengine/masterfiles"),
depth_search => u_recurse("inf"),
classes => success("got_policy");
"$(sys.workdir)\bin-twin\."
handle => "cfe_internal_bootstrap_update_files_sys_workdir_bin_twin_windows",
comment => "Make sure we maintain a clone of the binaries and libraries for updating",
copy_from => u_cp("$(sys.workdir)\bin\."),
depth_search => u_recurse("1");
#
processes:
!windows.got_policy::
"cf-execd" restart_class => "start_exec",
handle => "cfe_internal_bootstrap_update_processes_start_cf_execd";
am_policy_hub.got_policy::
"cf-serverd" restart_class => "start_server",
handle => "cfe_internal_bootstrap_update_processes_start_cf_serverd";
#
commands:
start_exec.!windows::
"$(sys.cf_execd)"
handle => "cfe_internal_bootstrap_update_commands_check_sys_cf_execd_start",
classes => outcome("executor");
start_server::
"$(sys.cf_serverd)"
handle => "cfe_internal_bootstrap_update_commands_check_sys_cf_serverd_start",
action => ifwin_bg,
classes => outcome("server");
#
services:
windows.got_policy::
"CfengineNovaExec"
handle => "cfe_internal_bootstrap_update_services_windows_executor",
service_policy => "start",
service_method => bootstart,
classes => outcome("executor");
#
reports:
bootstrap_mode.am_policy_hub::
"This host assumes the role of policy distribution host",
handle => "cfe_internal_bootstrap_update_reports_assume_policy_hub";
bootstrap_mode.!am_policy_hub::
"This autonomous node assumes the role of voluntary client",
handle => "cfe_internal_bootstrap_update_reports_assume_voluntary_client";
got_policy::
" -> Updated local policy from policy server",
handle => "cfe_internal_bootstrap_update_reports_got_policy";
!got_policy.!have_promises_cf::
" !! Failed to pull policy from policy server",
handle => "cfe_internal_bootstrap_update_reports_did_not_get_policy";
server_ok::
" -> Started the server",
handle => "cfe_internal_bootstrap_update_reports_started_serverd";
am_policy_hub.!server_ok.!have_promises_cf::
" !! Failed to start the server",
handle => "cfe_internal_bootstrap_update_reports_failed_to_start_serverd";
executor_ok::
" -> Started the scheduler",
handle => "cfe_internal_bootstrap_update_reports_started_execd";
!executor_ok.!have_promises_cf::
" !! Did not start the scheduler",
handle => "cfe_internal_bootstrap_update_reports_failed_to_start_execd";
!executor_ok.have_promises_cf::
" -> You are running a hard-coded failsafe. Please use the following command instead.
- 3.0.0: $(sys.cf_agent) -f $(sys.workdir)/inputs/failsafe/failsafe.cf
- 3.0.1: $(sys.cf_agent) -f $(sys.workdir)/inputs/update.cf",
handle => "cfe_internal_bootstrap_update_reports_run_another_failsafe_instead";
}
############################################
body classes outcome(x)
{
promise_repaired => {"$(x)_ok"};
}
############################################
body classes success(x)
{
promise_repaired => {"$(x)"};
}
############################################
body perms u_p(p)
{
mode => "$(p)";
}
#############################################
body copy_from u_scp(from)
{
source => "$(from)";
compare => "digest";
trustkey => "true";
encrypt => "true";
verify => "true";
!am_policy_hub::
servers => { "$(sys.policy_hub)" };
}
############################################
body action u_background
{
background => "true";
}
############################################
body depth_search u_recurse(d)
{
depth => "$(d)";
exclude_dirs => { "\.svn", "\.git" };}
############################################
body service_method bootstart
{
service_autostart_policy => "boot_time";
}
############################################
body action ifwin_bg
{
windows::
background => "true";
}
############################################
body copy_from u_cp(from)
{
source => "$(from)";
compare => "digest";
copy_backup => "false";
}