Skip to content

Commit f279782

Browse files
authored
Merge pull request #1790 from nickanderson/remove-policy-based-augments-parsing/master
Removed policy based parsing of def.json
2 parents ece1340 + 464d0b3 commit f279782

21 files changed

Lines changed: 3 additions & 160 deletions

controls/def.cf

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,15 @@
77
bundle common def
88
# @brief Common settings for the Masterfiles Policy Framework
99
{
10-
classes:
11-
"_workaround_CFE_2333" -> { "https://tracker.mender.io/browse/CFE-2333" }
12-
or => { "cfengine_3_7_3", "cfengine_3_8_1", "cfengine_3_8_2" };
13-
14-
# If the augments_file is parsed from C then we do not need ot do this work
15-
# from policy
16-
!(feature_def_json_preparse)|(_workaround_CFE_2333)::
17-
"have_augments_file" expression => fileexists($(augments_file)), scope => "bundle";
18-
"have_augments_classes" expression => isvariable("augments[classes]"), scope => "bundle";
19-
"have_augments_inputs" expression => isvariable("augments[inputs]"), scope => "bundle";
20-
21-
have_augments_classes.!(feature_def_json_preparse)|(_workaround_CFE_2333)::
22-
"$(augments_classes_data_keys)"
23-
expression => classmatch("$(augments[classes][$(augments_classes_data_keys)])"),
24-
meta => { "augments_class", "derived_from=$(augments_file)" };
25-
2610
vars:
2711

28-
!(feature_def_json_preparse)|(_workaround_CFE_2333)::
29-
"augments_file" string => "$(this.promise_dirname)/../../def.json";
30-
31-
"defvars" slist => variablesmatching("default:def\..*", "defvar");
32-
33-
have_augments_file.!feature_def_json_preparse|(_workaround_CFE_2333)::
34-
"augments" data => readjson($(augments_file), 100k), ifvarclass => "have_augments_file";
35-
36-
"augments_inputs" slist => getvalues("augments[inputs]");
37-
"override_vars" slist => getindices("augments[vars]");
38-
"override_data_$(override_vars)" data => mergedata("augments[vars][$(override_vars)]");
39-
"override_data_s_$(override_vars)" string => format("%S", "override_data_$(override_vars)");
40-
4112
any::
4213
"augments_inputs"
4314
slist => {},
4415
ifvarclass => not( isvariable( "augments_inputs" ) ),
4516
comment => "It's important that we define this list, even if it's empty
4617
or we get errors about the list being unresolved.";
4718

48-
have_augments_classes.!(feature_def_json_preparse)|(_workaround_CFE_2333)::
49-
"augments_classes_data" data => mergedata("augments[classes]");
50-
"augments_classes_data_keys" slist => getindices("augments_classes_data");
51-
52-
any::
53-
# Begin change
54-
5519
# Your domain name, for use in access control
5620
# Note: this default may be inaccurate!
5721
"domain"
@@ -75,14 +39,6 @@ bundle common def
7539

7640
# List here the IP masks that we grant access to on the server
7741

78-
# Only define here if we are not capable of parsing augments from C
79-
"acl"
80-
slist => getvalues("override_data_acl"),
81-
comment => "JSON-sourced: Define an acl for the machines to be granted accesses",
82-
handle => "common_def_json_vars_acl",
83-
ifvarclass => and(isvariable("override_data_acl"), "!feature_def_json_preparse"),
84-
meta => { "defvar" };
85-
8642
"acl"
8743
slist => {
8844
# Allow everything in my own domain.
@@ -110,13 +66,6 @@ bundle common def
11066
# Out of the hosts in allowconnects, trust new keys only from the
11167
# following ones. This is open by default for bootstrapping.
11268

113-
# Only define here if we are not capable of parsing augments from C
114-
"trustkeysfrom"
115-
slist => getvalues("override_data_trustkeysfrom"),
116-
comment => "JSON-sourced: define from which machines keys can be trusted",
117-
ifvarclass => and(isvariable("override_data_trustkeysfrom"), "!feature_def_json_preparse"),
118-
meta => { "defvar" };
119-
12069
"trustkeysfrom"
12170
slist => {
12271
# COMMENT THE NEXT LINE OUT AFTER ALL MACHINES HAVE BEEN BOOTSTRAPPED.
@@ -209,18 +158,6 @@ bundle common def
209158
# then get a regular list from using getvalues().
210159

211160
"tbse" data => mergedata( "def.control_common_bundlesequence_end" );
212-
213-
# Since we have @(def.bundlesequence_end) in body common control
214-
# bundlesequence we must have a list variable defined. It can be empty, but it
215-
# must be defined. If it is not defined the agent will error complaining
216-
# that '@(def.bundlesequence_end) is not a defined bundle.
217-
218-
# As noted in CFE-2460 getvalues behaviour varies between versions. 3.7.x
219-
# getvalues will return an empty list when run on a non existant data
220-
# container. On 3.9.1 it does not return an empty list.
221-
# So we initialize it as an empty list first to be safe.
222-
223-
"bundlesequence_end" slist => {};
224161
"bundlesequence_end" slist => getvalues( tbse );
225162

226163
"control_common_ignore_missing_bundles" -> { "CFE-2773" }
@@ -580,24 +517,6 @@ bundle common def
580517
"cfconsumer_in_enterprise" -> { "ENT-2797" }
581518
or => { "cfengine_3_7", "cfengine_3_8", "cfengine_3_9", "cfengine_3_10", "cfengine_3_11" };
582519

583-
reports:
584-
DEBUG|DEBUG_def::
585-
"DEBUG: $(this.bundle)";
586-
587-
"$(const.t) def.json was found at $(augments_file)"
588-
ifvarclass => fileexists( $(augments_file) );
589-
590-
"$(const.t) override request $(override_vars) to '$(override_data_s_$(override_vars))'; new value '$($(override_vars))'"
591-
ifvarclass => isvariable("override_data_$(override_vars)");
592-
593-
"$(const.t) defined class '$(augments_classes_data_keys)' because of classmatch('$(augments[classes][$(augments_classes_data_keys)])')"
594-
ifvarclass => "$(augments_classes_data_keys)";
595-
596-
"$(const.t) $(defvars) = $($(defvars))";
597-
"DEBUG $(this.bundle): Agent parsed augments_file"
598-
ifvarclass => "have_augments_file.feature_def_json_preparse";
599-
"DEBUG $(this.bundle): Policy parsed augments_file"
600-
ifvarclass => "have_augments_file.!feature_def_json_preparse";
601520
}
602521

603522
bundle common inventory_control

controls/update_def.cf.in

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,13 @@ bundle common update_def
22
# @brief Main default settings for update policy
33
{
44
classes:
5-
!feature_def_json_preparse::
6-
"have_augments_file" expression => fileexists($(augments_file)), scope => "bundle";
7-
"have_augments_classes" expression => isvariable("augments[classes]"), scope => "bundle";
8-
9-
have_augments_classes.!feature_def_json_preparse::
10-
"$(augments_classes_data_keys)"
11-
expression => classmatch("$(augments[classes][$(augments_classes_data_keys)])"),
12-
meta => { "augments_class", "derived_from=$(augments_file)" };
135
any::
146
"sys_policy_hub_port_exists" expression => isvariable("sys.policy_hub_port");
157
vars:
16-
"current_version" string => "@VERSION@";
17-
18-
!feature_def_json_preparse::
19-
"augments_file" string => "$(this.promise_dirname)/../../def.json";
20-
21-
"defvars" slist => variablesmatching("default:update_def\..*", "defvar");
22-
23-
have_augments_file.!feature_def_json_preparse::
24-
"augments" data => readjson($(augments_file), 100k), ifvarclass => "have_augments_file";
25-
26-
"override_vars" slist => getindices("augments[vars]");
27-
"override_data_$(override_vars)" data => mergedata("augments[vars][$(override_vars)]");
28-
"override_data_s_$(override_vars)" string => format("%S", "override_data_$(override_vars)");
29-
30-
have_augments_classes.!feature_def_json_preparse::
31-
"augments_classes_data" data => mergedata("augments[classes]");
32-
"augments_classes_data_keys" slist => getindices("augments_classes_data");
33-
348
any::
359

10+
"current_version" string => "@VERSION@";
11+
3612
# MPF Controls
3713

3814
# Because in some versions of cfengine bundlesequence in body common
@@ -63,18 +39,6 @@ bundle common update_def
6339
slist => { @(def.update_inputs) },
6440
ifvarclass => isvariable( "def.update_inputs" );
6541

66-
# Begin change
67-
68-
# When parsing the augments_file from policy, we set input_name_patterns
69-
# based on the data extracted from within policy
70-
"input_name_patterns"
71-
slist => getvalues("override_data_input_name_patterns"),
72-
comment => "JSON-sourced filename patterns to match when updating the policy
73-
(see update/update_policy.cf)",
74-
handle => "common_def_json_vars_input_name_patterns_without_feature_def_json_preparse",
75-
ifvarclass => and(isvariable("override_data_input_name_patterns"), "!feature_def_json_preparse"),
76-
meta => { "defvar" };
77-
7842
# Default the input name patterns, if we don't find it defined in def
7943
# (from the augments_file).
8044
"input_name_patterns"
@@ -95,7 +59,7 @@ bundle common update_def
9559
slist => { @(def.input_name_patterns) },
9660
comment => "Filename patterns to match when updating the policy
9761
(see update/update_policy.cf)",
98-
handle => "common_def_vars_input_name_patterns_from_def_with_feature_def_json_preparse",
62+
handle => "common_def_vars_input_name_patterns",
9963
ifvarclass => and( isvariable("def.input_name_patterns"),
10064
not(isvariable("input_name_patterns"))),
10165
meta => { "defvar" };
@@ -239,22 +203,4 @@ bundle common update_def
239203
"cfconsumer_in_enterprise" -> { "ENT-2797" }
240204
or => { "cfengine_3_7", "cfengine_3_8", "cfengine_3_9", "cfengine_3_10", "cfengine_3_11" };
241205

242-
reports:
243-
DEBUG|DEBUG_update_def::
244-
"DEBUG: $(this.bundle)";
245-
"$(const.t) override request $(override_vars) to '$(override_data_s_$(override_vars))'; new value '$($(override_vars))'"
246-
ifvarclass => isvariable("override_data_$(override_vars)");
247-
248-
"$(const.t) defined class role/byname $(extra_roles[byname][$(roles_byname_keys)]) because of classmatch('$(roles_byname_keys)')"
249-
ifvarclass => "$(extra_roles[byname][$(roles_byname_keys)])";
250-
251-
"$(const.t) defined class role/byrole $(roles_byrole_keys) because of classmatch('$(extra_roles[byrole][$(roles_byrole_keys)])')"
252-
ifvarclass => "$(roles_byrole_keys)";
253-
254-
"$(const.t) $(defvars) = $($(defvars))";
255-
"DEBUG $(this.bundle): Agent parsed augments_file"
256-
ifvarclass => "have_augments_file.feature_def_json_preparse";
257-
"DEBUG $(this.bundle): Policy parsed augments_file"
258-
ifvarclass => "have_augments_file.!feature_def_json_preparse";
259-
"DEBUG $(this.bundle): input_name_pattern = '$(input_name_patterns)'";
260206
}

lib/bundles.cf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
# the online docs
4040
#
4141

42-
# For CFEngine Core: 3.7.0 to 3.7.x
4342
# Bundles
4443

4544
###################################################

lib/cfe_internal_hub.cf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
# the online docs
4040
#
4141

42-
# For CFEngine Core: 3.7.0 to 3.7.x
43-
# Internal hub maintenance bundles, incompatible with 3.5.x
44-
4542
###################################################
4643
# If you find CFEngine useful, please consider #
4744
# purchasing a commercial version of the software.#

lib/cfengine_enterprise_hub_ha.cf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
# the online docs
4040
#
4141

42-
# For CFEngine Core: 3.7.0 to 3.7.x
43-
4442
#################################################
4543
# CFEngine Enterprise Hub HA policy inclusion
4644
#################################################

lib/commands.cf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
# the online docs
4040
#
4141

42-
# For CFEngine Core: 3.7.0 to 3.7.x
4342
# Commands bodies
4443

4544
###################################################

lib/common.cf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
# the online docs
4040
#
4141

42-
# For CFEngine Core: 3.7.0 to 3.7.x
4342
# Common bodies
4443

4544
###################################################

lib/databases.cf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
# the online docs
4040
#
4141

42-
# For CFEngine Core: 3.7.0 to 3.7.x
4342
# Databases bodies
4443

4544
###################################################

lib/edit_xml.cf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
# the online docs
4040
#
4141

42-
# For CFEngine Core: 3.7.0 to 3.7.x
4342
# edit_xml bundles
4443

4544
###################################################

lib/examples.cf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
# the online docs
4040
#
4141

42-
# For CFEngine Core: 3.7.0 to 3.7.x
4342
# Examples you may find useful
4443

4544
###################################################

0 commit comments

Comments
 (0)