Skip to content

Commit 5d12761

Browse files
authored
Merge pull request #1852 from olehermanse/ifvarclass
CFE-3472: Replaced ifvarclass with if in MPF
2 parents adfa613 + 317e665 commit 5d12761

31 files changed

Lines changed: 255 additions & 255 deletions

cfe_internal/core/watchdog/watchdog.cf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ bundle agent cfe_internal_core_watchdog(state)
4343
DEBUG|DEBUG_cfe_internal_core_watchdog::
4444
"DEBUG $(this.bundle): Watchdog '$(state)'";
4545
"DEBUG $(this.bundle): Invalid state '$(state)' only enabled|disabled allowed"
46-
ifvarclass => "invalid_state";
46+
if => "invalid_state";
4747

4848
!(use_cfe_internal_core_watchdog_cron_d|use_cfe_internal_core_watchdog_aix|use_cfe_internal_core_watchdog_windows)::
4949
"WARNING $(this.bundle): Currently only supports /etc/cron.d on systems that have pgrep in the the stdlib paths bundle, AIX and Windows hosts.";

cfe_internal/enterprise/CFE_hub_specific.cf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,17 +549,17 @@ bundle agent cfe_internal_enterprise_maintenance
549549

550550
"Enterprise Maintenance"
551551
usebundle => $(enterprise_maintenance_bundles),
552-
ifvarclass => isgreaterthan( $(enterprise_maintenance_bundle_count), 0 );
552+
if => isgreaterthan( $(enterprise_maintenance_bundle_count), 0 );
553553

554554
reports:
555555

556556
"DEBUG|DEBUG_$(this.bundle)"::
557557

558558
"DEBUG $(this.bundle): $(enterprise_maintenance_bundle_count) CFEngine Enterprise Maintenance Bundles"
559-
ifvarclass => isgreaterthan( $(enterprise_maintenance_bundle_count), 0 );
559+
if => isgreaterthan( $(enterprise_maintenance_bundle_count), 0 );
560560

561561
"DEBUG $(this.bundle): $(enterprise_maintenance_bundles) CFEngine Enterprise Maintenance Bundles"
562-
ifvarclass => isgreaterthan( $(enterprise_maintenance_bundle_count), 0 );
562+
if => isgreaterthan( $(enterprise_maintenance_bundle_count), 0 );
563563
}
564564

565565
bundle agent cfe_internal_refresh_inventory_view

cfe_internal/enterprise/file_change.cf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ bundle agent change_management
3636
"$(watch_files_report_diffs)" -> { "InfoSec" }
3737
changes => diff,
3838
handle => "change_management_files_watch_files_report_diffs",
39-
ifvarclass => fileexists( $(watch_files_report_diffs) ),
39+
if => fileexists( $(watch_files_report_diffs) ),
4040
comment => "Unplanned changes of these files may indicate a security
4141
breach.";
4242

4343
"$(watch_files_report_change)" -> { "InfoSec" }
4444
changes => detect_content_using("sha256"),
45-
ifvarclass => fileexists( $(watch_files_report_change) ),
45+
if => fileexists( $(watch_files_report_change) ),
4646
comment => "Unplanned changes of these files may indicate a security
4747
breach. (Diffs are not reported in case those with access
4848
to this report should not have access to shadow entries.)";

cfe_internal/enterprise/ha/ha_def.cf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ bundle common ha_def
2424

2525

2626
"replication_only_node[$(ips)]"
27-
string => "dummy", ifvarclass => strcmp("$(config[$(ips)][is_in_cluster])", "false");
27+
string => "dummy", if => strcmp("$(config[$(ips)][is_in_cluster])", "false");
2828

2929
"replication_only_nodes"
3030
slist => getindices("replication_only_node");

cfe_internal/enterprise/mission_portal.cf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ bundle agent mission_portal_apache_from_stage(config, staged_config)
111111

112112
"$(config)"
113113
copy_from => local_dcp( $(staged_config) ),
114-
ifvarclass => returnszero("$(validate_config) > /dev/null 2>&1 ", "useshell"),
114+
if => returnszero("$(validate_config) > /dev/null 2>&1 ", "useshell"),
115115
classes => results("bundle", "mission_portal_apache_config"),
116116
comment => "We make sure that the deployed config is a copy of the staged
117117
config if the staged config passes a syntax check. We redirect
@@ -136,10 +136,10 @@ bundle agent mission_portal_apache_from_stage(config, staged_config)
136136
reports:
137137
DEBUG|DEBUG_mission_portal_apache_from_stage::
138138
"DEBUG $(this.bundle): '$(config)' should be a copy of '$(staged_config)' because it validates with '$(validate_config)'"
139-
ifvarclass => returnszero("$(validate_config) > /dev/null 2>&1 ", "useshell");
139+
if => returnszero("$(validate_config) > /dev/null 2>&1 ", "useshell");
140140

141141
"DEBUG $(this.bundle): '$(config)' should *not* be a copy of '$(staged_config)' because it failed to validate with '$(validate_config)'"
142-
ifvarclass => not(returnszero("$(validate_config) > /dev/null 2>&1 ", "useshell"));
142+
if => not(returnszero("$(validate_config) > /dev/null 2>&1 ", "useshell"));
143143
}
144144

145145
##################################################################
@@ -275,8 +275,8 @@ bundle agent cfe_enterprise_selfsigned_cert
275275
DEBUG|DEBUG_cfe_enterprise_selfsigned_cert::
276276

277277
"DEBUG $(this.bundle): Certificate Generation Requested"
278-
ifvarclass => "_cfe_enterprise_selfsigned_cert_regenerate_certificate";
278+
if => "_cfe_enterprise_selfsigned_cert_regenerate_certificate";
279279

280280
"DEBUG $(this.bundle): No Certificate Generation Requested"
281-
ifvarclass => "!_cfe_enterprise_selfsigned_cert_regenerate_certificate";
281+
if => "!_cfe_enterprise_selfsigned_cert_regenerate_certificate";
282282
}

cfe_internal/update/lib.cf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,26 +219,26 @@ bundle agent u_systemd_services(service,state)
219219
# conveniently, systemd states map to `services` states, except
220220
# for `enable`
221221

222-
"$(call_systemctl) -q start $(service)" ifvarclass => "action_start";
223-
"$(call_systemctl) -q stop $(service)" ifvarclass => "action_stop";
224-
"$(call_systemctl) -q reload $(service)" ifvarclass => "action_reload";
225-
"$(call_systemctl) -q restart $(service)" ifvarclass => "action_restart";
226-
"$(call_systemctl) -q enable $(service)" ifvarclass => "action_enable";
227-
"$(call_systemctl) -q disable $(service)" ifvarclass => "action_disable";
222+
"$(call_systemctl) -q start $(service)" if => "action_start";
223+
"$(call_systemctl) -q stop $(service)" if => "action_stop";
224+
"$(call_systemctl) -q reload $(service)" if => "action_reload";
225+
"$(call_systemctl) -q restart $(service)" if => "action_restart";
226+
"$(call_systemctl) -q enable $(service)" if => "action_enable";
227+
"$(call_systemctl) -q disable $(service)" if => "action_disable";
228228

229229
# Custom action for any of the non-standard systemd actions such a
230230
# status, try-restart, isolate, et al.
231-
"$(call_systemctl) $(state) $(service)" ifvarclass => "action_custom";
231+
"$(call_systemctl) $(state) $(service)" if => "action_custom";
232232

233233
reports:
234234
DEBUG|DEBUG_u_systemd_service::
235235
"DEBUG $(this.bundle): using systemd layer to $(state) $(service)";
236236

237237
"DEBUG $(this.bundle): Service $(service) unit file is not loaded; doing nothing"
238-
ifvarclass => "systemd.!service_loaded";
238+
if => "systemd.!service_loaded";
239239

240240
"DEBUG $(this.bundle): Could not find service: $(service)"
241-
ifvarclass => "systemd.service_notfound";
241+
if => "systemd.service_notfound";
242242
}
243243

244244
body perms u_mog(mode,user,group)

cfe_internal/update/update_bins.cf

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,21 @@ bundle agent cfe_internal_update_bins
9090
"novapkg" string => "CFEcfengine-nova",
9191
comment => "Name convention of Nova package on Solaris",
9292
handle => "cfe_internal_update_bins_vars_novapkg_solaris",
93-
ifvarclass => "nova_edition";
93+
if => "nova_edition";
9494

9595
aix.enterprise::
9696

9797
"novapkg" string => "cfengine.cfengine-nova",
9898
comment => "Name convention of Nova package on AIX",
9999
handle => "cfe_internal_update_bins_vars_novapkg_aix",
100-
ifvarclass => "nova_edition";
100+
if => "nova_edition";
101101

102102
!(solarisx86|solaris|aix).enterprise::
103103

104104
"novapkg" string => "cfengine-nova",
105105
comment => "Name convention of Nova package for all but not Solaris",
106106
handle => "cfe_internal_update_bins_vars_novapkg_not_solaris_aix",
107-
ifvarclass => "nova_edition";
107+
if => "nova_edition";
108108

109109
solaris.!sunos_i86pc.enterprise::
110110

@@ -162,7 +162,7 @@ bundle agent cfe_internal_update_bins
162162
package_architectures => { "$(pkgarch)" },
163163
package_version => "$(update_def.current_version)-1",
164164
package_method => u_generic( "$(local_software_dir)" ),
165-
ifvarclass => "nova_edition.have_software_dir",
165+
if => "nova_edition.have_software_dir",
166166
classes => u_if_else("bin_update_success", "bin_update_fail");
167167

168168
!am_policy_hub.(solaris|solarisx86).enterprise.trigger_upgrade.!bootstrap_mode::
@@ -175,7 +175,7 @@ bundle agent cfe_internal_update_bins
175175
package_architectures => { "$(pkgarch)" },
176176
package_version => "$(update_def.current_version)",
177177
package_method => u_generic( "$(local_software_dir)" ),
178-
ifvarclass => "nova_edition.have_software_dir",
178+
if => "nova_edition.have_software_dir",
179179
classes => u_if_else("bin_update_success", "bin_update_fail");
180180

181181
!am_policy_hub.windows.enterprise.trigger_upgrade.!bootstrap_mode::
@@ -188,7 +188,7 @@ bundle agent cfe_internal_update_bins
188188
package_architectures => { "$(pkgarch)" },
189189
package_version => "$(update_def.current_version)",
190190
package_method => u_generic( "$(local_software_dir)" ),
191-
ifvarclass => "nova_edition.have_software_dir",
191+
if => "nova_edition.have_software_dir",
192192
classes => u_if_else("bin_update_success", "bin_update_fail");
193193

194194
!am_policy_hub.aix.enterprise.trigger_upgrade.!bootstrap_mode::
@@ -201,7 +201,7 @@ bundle agent cfe_internal_update_bins
201201
package_architectures => { "$(pkgarch)" },
202202
package_version => "$(update_def.current_version).0",
203203
package_method => u_generic( "$(local_software_dir)" ),
204-
ifvarclass => "nova_edition.have_software_dir",
204+
if => "nova_edition.have_software_dir",
205205
classes => u_if_else("bin_update_success", "bin_update_fail");
206206

207207
#
@@ -236,13 +236,13 @@ bundle agent cfe_internal_update_bins
236236
edit_defaults => u_empty_no_backup,
237237
edit_line => u_admin_file,
238238
perms => u_m("0644"),
239-
ifvarclass => "solarisx86|solaris";
239+
if => "solarisx86|solaris";
240240

241241
"$(backup_script)"
242242
comment => "Create a backup script for cf-upgrade",
243243
handle => "cfe_internal_update_bins_files_backup_script",
244244
create => "true",
245-
ifvarclass => "!windows",
245+
if => "!windows",
246246
edit_defaults => u_empty_no_backup,
247247
edit_line => u_backup_script,
248248
perms => u_m("0755");
@@ -251,7 +251,7 @@ bundle agent cfe_internal_update_bins
251251
comment => "Create an install script for cf-upgrade",
252252
handle => "cfe_internal_update_bins_files_install_script",
253253
create => "true",
254-
ifvarclass => "!windows",
254+
if => "!windows",
255255
edit_defaults => u_empty_no_backup,
256256
edit_line => u_install_script,
257257
perms => u_m("0755");
@@ -280,7 +280,7 @@ bundle agent cfe_internal_update_bins
280280
reports:
281281
DEBUG|DEBUG_cfe_internal_update_bins::
282282
"DEBUG $(this.bundle): Evaluating binaries for upgrade using internal update mechanism"
283-
ifvarclass => "trigger_upgrade";
283+
if => "trigger_upgrade";
284284

285285
}
286286

cfe_internal/update/update_processes.cf

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,21 @@ bundle agent cfe_internal_update_processes
121121
comment => "CFE processes that should not be enabled",
122122
handle => "cfe_internal_update_processes_vars_agents_to_be_disabled",
123123
slist => { @(def.agents_to_be_disabled) },
124-
ifvarclass => isvariable( "def.agents_to_be_disabled" );
124+
if => isvariable( "def.agents_to_be_disabled" );
125125

126126
"agents_to_be_disabled"
127127
comment => "The default agents that should not be enabled.",
128128
handle => "cfe_internal_update_processes_vars_default_agents_to_be_disabled",
129129
slist => { },
130-
ifvarclass => not( isvariable("def.agents_to_be_disabled") );
130+
if => not( isvariable("def.agents_to_be_disabled") );
131131

132132
# An agent is disabled if there is a persistently defined disablement
133133
# class OR if the agent is found in a list of agents to be specifically
134134
# disabled.
135135

136136
"disabled[$(all_agents)]"
137137
string => "$(all_agents)",
138-
ifvarclass => or( canonify( "persistent_disable_$(all_agents)" ),
138+
if => or( canonify( "persistent_disable_$(all_agents)" ),
139139
some( "$(all_agents)", agents_to_be_disabled ));
140140

141141
systemd_supervised.policy_server.enterprise.hub_passive|(ha_replication_only_node.!failover_to_repliacation_node_enabled)::
@@ -193,7 +193,7 @@ bundle agent cfe_internal_update_processes
193193

194194
"CHECKING FOR PERSISTENTLY DISABLED CFE AGENTS"
195195
usebundle => disable_cfengine_agents($(all_agents)),
196-
ifvarclass => canonify("persistent_disable_$(all_agents)"),
196+
if => canonify("persistent_disable_$(all_agents)"),
197197
comment => "Call a bundle to disable CFEngine given processes if persistent_disable_x is set",
198198
handle => "cfe_internal_update_processes_methods_maybe_disabling_cfe_agents";
199199

@@ -254,7 +254,7 @@ bundle agent maintain_cfe_hub_process
254254
restart_class => "no_vacuumdb",
255255
comment => "Monitor vacuumdb process",
256256
handle => "cfe_internal_maintain_cfe_hub_process_processes_check_vacuumdb",
257-
ifvarclass => "nova|enterprise";
257+
if => "nova|enterprise";
258258

259259
am_policy_hub.cfredis_in_enterprise::
260260

@@ -263,27 +263,27 @@ bundle agent maintain_cfe_hub_process
263263
restart_class => "start_redis_server",
264264
comment => "Monitor redis-server process",
265265
handle => "cfe_internal_maintain_cfe_hub_process_processes_redis",
266-
ifvarclass => "nova|enterprise";
266+
if => "nova|enterprise";
267267

268268
am_policy_hub.cfconsumer_in_enterprise::
269269
"$(cfe_internal_process_knowledge.bindir)/cf-consumer" -> { "ENT-2797" }
270270
restart_class => "start_cf_consumer",
271271
comment => "Monitor cf-consumer process",
272272
handle => "cfe_internal_maintain_cfe_hub_process_processes_cf_consumer",
273-
ifvarclass => "(nova|enterprise).no_vacuumdb";
273+
if => "(nova|enterprise).no_vacuumdb";
274274

275275
am_policy_hub.!enable_cfengine_enterprise_hub_ha::
276276
"$(cfe_internal_process_knowledge.bindir)/postgres"
277277
restart_class => "start_postgres_server",
278278
comment => "Monitor postgres process",
279279
handle => "cfe_internal_maintain_cfe_hub_process_processes_postgres",
280-
ifvarclass => "nova|enterprise";
280+
if => "nova|enterprise";
281281

282282
am_policy_hub.!enable_cfengine_enterprise_hub_ha.files_ok.!windows|ha_run_hub_process::
283283
"cf-hub" restart_class => "start_hub",
284284
comment => "Monitor cf-hub process",
285285
handle => "cfe_internal_maintain_cfe_hub_process_processes_cf_hub",
286-
ifvarclass => and( "(nova|enterprise).no_vacuumdb",
286+
if => and( "(nova|enterprise).no_vacuumdb",
287287
"!persistent_disable_cf_hub" ); # Don't start it if it's persistently disabled
288288

289289
am_policy_hub.ha_kill_hub_process::
@@ -373,7 +373,7 @@ bundle agent disable_cfengine_agents(process)
373373
signals => { "term" },
374374
comment => "Terminate $(process)",
375375
handle => "cfe_internal_disable_cfengine_agents_processes_terminate_process",
376-
ifvarclass => "disable_$(cprocess)";
376+
if => "disable_$(cprocess)";
377377

378378
}
379379

@@ -410,7 +410,7 @@ bundle agent enable_cfengine_agents(process)
410410
restart_class => "restart_$(cprocess)",
411411
comment => "Create a class to restart a process",
412412
handle => "cfe_internal_enable_cfengine_agents_processes_restart_process",
413-
ifvarclass => "enable_$(cprocess)";
413+
if => "enable_$(cprocess)";
414414

415415
#
416416

@@ -422,21 +422,21 @@ bundle agent enable_cfengine_agents(process)
422422
comment => "Restart a process",
423423
handle => "cfe_internal_enable_cfengine_agents_commands_restart_process",
424424
classes => u_kept_successful_command,
425-
ifvarclass => and( "restart_$(cprocess)",
425+
if => and( "restart_$(cprocess)",
426426
isvariable( "sys.$(cprocess)" ) );
427427

428428
reports:
429429
"The process $(process) is persistently disabled. Run with '-Dclear_persistent_disable_$(cprocess)' to re-enable it."
430-
ifvarclass => and( "persistent_disable_$(cprocess)",
430+
if => and( "persistent_disable_$(cprocess)",
431431
isvariable( "sys.$(cprocess)" ));
432432

433433
"The process $(process) has been re-enabled. Run with '-Dset_persistent_disable_$(cprocess)' to disable it persistently again."
434-
ifvarclass => and( "clear_persistent_disable_$(cprocess)",
434+
if => and( "clear_persistent_disable_$(cprocess)",
435435
isvariable( "sys.$(cprocess)" )),
436436
classes => u_clear_always("persistent_disable_$(cprocess)");
437437

438438
"The process $(process) has been disabled persistently. Run with '-Dclear_persistent_disable_$(cprocess)' to re-enable it."
439-
ifvarclass => "set_persistent_disable_$(cprocess)",
439+
if => "set_persistent_disable_$(cprocess)",
440440
classes => u_always_forever("persistent_disable_$(cprocess)");
441441
}
442442

0 commit comments

Comments
 (0)