Replies: 5 comments 2 replies
-
|
This looks like a bug. I created a ticket in our bug tracker to follow up on this (see CFE-4643). Thanks for reporting it @eb4x |
Beta Was this translation helpful? Give feedback.
-
|
Humm, I don't recall ever having used defaults promises with slists. slists don't align well with if_match_regex. Which element would the regex match? would it iterate and try to match each element or would it join and match, would it short circut on first match? I haven't searched for it but I doubt we would find much if any prior art using defaults with slists. I suspect that slist being shown in the example is perhaps a bug. Beyond that, in general I avoid the use of defaults. I find them quite difficult to reason about and with. Rather than use defaults from within policy, I generally reccomend leveraging Augments. There you can set a value for a variable, and then in policy you can choose to keep that variable or override it. You will find many cases of if => isvariable() in def.cf in the MPF that use this methodology. |
Beta Was this translation helpful? Give feedback.
-
|
I'm new at cfengine, so I wouldn't know the ins and outs, and how or even if if_match_regex should be available if it's not a string object. My understanding from the documentation as written is that if you can't find something defined in the It got tedious writing guards to end up with the correct value during the calculations of which you should use. I still have a hard time understanding augments, when I read the documentation it's just too abstract for me to wrap my head around. Though it looks like a superpower if I could ever figure out how to use it properly. Right now I only dump this to {
"augments": [
"$(sys.workdir)/atoms.json"
],
"inputs": [
"services/myexample.cf"
],
"vars": {
"control_common_bundlesequence_end": [
"myexample"
]
}
}Would the way to augment |
Beta Was this translation helpful? Give feedback.
-
|
Ha, ok so I think I'm getting the picture, atleast somewhat. I added "augments": [
"$(sys.workdir)/atoms.json"
"$(sys.inputdir)/services/myexample.json"
],and {
"variables": {
"myexample.mystring": {
"value": "this is the augmented string"
},
"myexample.mylist": {
"value": [ "this", "is", "the", "augmented", "list" ]
}
}
}and these seem to act like what I'd expect defaults to do. It's not a great experience though, a separate file to read and figure out whether a default exists or just how error-prone it can be writing json and getting the "bundle.varname" syntax combo right. |
Beta Was this translation helpful? Give feedback.
-
|
Erik,
Maybe this blog can explain the usage of augments files and cfengine
*
https://cfengine.com/blog/2018/missing_ok-and-multiple-augments-in-3-12-0/
What I am also using is `ifelse`:
* https://docs.cfengine.com/docs/master/reference/functions/ifelse/
There is even whole framework for configuring services via mustache/json
files. It can be installed via cfbs:
* https://build.cfengine.com/modules/surf-cfengine-library/
* https://github.com/basvandervlies/cf_surfsara_lib
Regards
Bas
…On 06/03/2026 15:54, Erik Berg wrote:
Ha, ok so I think I'm getting the picture, atleast somewhat.
I added
"augments": [
"$(sys.workdir)/atoms.json"
"$(sys.inputdir)/services/myexample.json"
],
and
{
"variables": {
"myexample.mystring": {
"value":"this is the augmented string"
},
"myexample.mylist": {
"value": ["this","is","the","augmented","list" ]
}
}
}
and these seem to act like what I'd expect defaults to do. It's not a
great experience though, a separate file to read and figure out whether
a default exists or just how error-prone it can be writing json and
getting the "bundle.varname" syntax combo right.
—
Reply to this email directly, view it on GitHub <https://github.com/
cfengine/core#6050#discussioncomment-16024282>, or
unsubscribe <https://github.com/notifications/unsubscribe-auth/
AADJKB2S3NZM4G44NQOCT434PLRBBAVCNFSM6AAAAACWIF65D2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTMMBSGQZDQMQ>.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
--
Bas van der Vlies
| High Performance Computing & Visualization | SURF| Science Park 140
| 1098 XG Amsterdam | T +31 (0) 20 800 1300 | ***@***.***
| www.surf.nl
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
From the documentation
And in some examples
slistis put indefaults:, though not used invars:under a guard.Small example
And the unexpected result;
I've worked around this, but I was starting to get in the groove with a defaults/overrides pattern.
Beta Was this translation helpful? Give feedback.
All reactions