Details
Description
Today I was doing a bit of archaeology. I had memory that hard classes could not be undefined but I could not find that mentioned in the docs under the language concepts reference about classes.
I set out to see for my self and I found indication that my memory is sound, you should not be able to undefine hard classes, but I also found that I could.
This policy exercises extracting the tags from a known hard class, cfengine which should always be defined then attempting to undefine it if the class try_to_undefine is set.
bundle agent __main__ { methods: "pudding"; } bundle agent pudding { vars: "cfengine_class_tags" slist => getclassmetatags( "cfengine" ); commands: try_to_undefine:: "/bin/true" classes => undefine( "cfengine" ); reports: "cfengine class tags: $(with)" with => join( ", ", cfengine_class_tags); } body classes undefine( class ) { cancel_kept => { $(class) }; cancel_repaired => { $(class) }; cancel_notkept => { $(class) }; }
When I run it without trying to undefine cfengine it works as expected.
# cf-agent --define dont_try_to_undefine --no-lock --log-level info --show-evaluated-classes=cfengine --file example.cf R: cfengine class tags: inventory, attribute_name=none, source=agent, hardclass Class name Meta tags cfengine inventory,attribute_name=none,source=agent,hardclass cfengine_3 inventory,attribute_name=none,source=agent,hardclass cfengine_3_18 inventory,attribute_name=none,source=agent,hardclass cfengine_3_18_0a inventory,attribute_name=none,source=agent,hardclass cfengine_3_18_0a_b248be4d0 inventory,attribute_name=none,source=agent,hardclass
However, unfortunately, the pudding didn't set. When I run the policy and try to undefine cfengine I get an error telling me I can't do that, but in the end, I can see that cfengine is indeed not defined at the end of the run per the --show-evaluated-classes output.
# cf-agent --define try_to_undefine --no-lock --log-level info --show-evaluated-classes=cfengine --file example.cf info: Executing 'no timeout' ... '/bin/true' error: You cannot cancel a reserved hard class 'cfengine' in post-condition classes info: Completed execution of '/bin/true' R: cfengine class tags: inventory, attribute_name=none, source=agent, hardclass Class name Meta tags cfengine_3 inventory,attribute_name=none,source=agent,hardclass cfengine_3_18 inventory,attribute_name=none,source=agent,hardclass cfengine_3_18_0a inventory,attribute_name=none,source=agent,hardclass cfengine_3_18_0a_b248be4d0 inventory,attribute_name=none,source=agent,hardclass
Attachments
Issue Links
1.
|
Document that Hard Classes can not be un-defined. |
|
Open | Unassigned |