CFEngine Help: Re: It is possible to uses a slist variable in the inputs directive ?
Forum: CFEngine Help Subject: Re: It is possible to uses a slist variable in the inputs directive ? Author: davidlee Link to topic: https://cfengine.com/forum/read.php?3,26281,26299#msg-26299 Where, please, does the ref. manual describe this quoting/non-quoting? I get the feeling that $(foo) has to be quoted every time, without exception. (Correct?) But if I say @(bar), it seems that quoting is optional. When such mentions of @(bar) happen to occur in the ref. manual, the cases seem arbitrary and confused. When should, and should not, mentions of lists of quoted? See also bugs 855 and 856 about this lack of description in the manual. Perhaps 765 also. (All opened way back last year, but with no significant acknowledgment yet...) ___ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
Re: CFEngine Help: Re: Problem accessing list variables in hash
Thanks for the help - I've ended up taking bits from both solutions. I'm now calling the method bundle once per user account to add, which allows me to pass in the slist of keys to add. Pulling the keys into variables with readfile has made life easier in controlling the final output. Thanks for the help, Mike ___ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
CFEngine Help: Re: CFEngine Help: Templating the solution?
Forum: CFEngine Help Subject: Re: CFEngine Help: Templating the solution? Author: tjavo87 Link to topic: https://cfengine.com/forum/read.php?3,26068,26301#msg-26301 Hi, I'm now working with methods but encounter a problem. I've a bundle named all that needs to run on every system. The files are parsed but then there is the message when running cf-agent in verbose mode; cf3> -> Bundlesequence => {'main'} cf3> cf3> * cf3> BUNDLE main cf3> * cf3> cf3> cf3> + Private classes augmented: cf3> cf3> - Private classes diminished: cf3> cf3> cf3> cf3>= cf3>methods in bundle main (1) cf3>= cf3> cf3> cf3> . cf3> Promise's handle: cf3> Promise made by: "all" cf3> . cf3> cf3> cf3> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * cf3> BUNDLE all cf3> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * cf3> cf3> Initiate variable convergence... cf3> cf3>= cf3>vars in bundle all (1) cf3>= cf3> cf3> cf3> + Private classes augmented: cf3> cf3> - Private classes diminished: cf3> cf3> cf3> cf3>= cf3>vars in bundle all (2) cf3>= cf3> cf3> cf3> + Private classes augmented: cf3> cf3> - Private classes diminished: cf3> cf3> cf3> cf3>= cf3>vars in bundle all (3) cf3>= cf3> cf3> cf3> + Private classes augmented: cf3> cf3> - Private classes diminished: cf3> cf3> cf3> ==> Zero promises executed for bundle "all" cf3> -> Method invoked successfully cf3> cf3> . cf3> Promise's handle: cf3> Promise made by: "groupless" cf3> . cf3> cf3> cf3> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * cf3> BUNDLE groupless cf3> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * cf3> cf3> Initiate variable convergence... cf3> cf3> + Private classes augmented: cf3> cf3> - Private classes diminished: cf3> cf3> cf3> cf3>= cf3>methods in bundle groupless (1) cf3>= Here is a part of my config; bundle agent main { methods: any:: "all" usebundle => "all"; groupless:: "groupless" usebundle => "groupless"; all.cf bundle agent all { methods: "all" usebundle => "all_garbage"; all_garbage.cf bundle agent all_garbage { files: Sunday.Hr12.Min00_05:: "$(sys.workdir)/cf_repair.log" comment => "Rotate the promises repaired logs each week", handle => "garbage_collection_files_cf_repair_log", rename => rotate("7"), action => if_elapsed("1"); } Mark Burgess Wrote: --- > Consider using this approach instead of the > bundlesequence > > https://cfengine.com/manuals/st-menus#How-do-you-c > reate-menus-with-CFEngine > > On 05/25/2012 09:17 AM, no-re...@cfengine.com > wrote: > > Forum: CFEngine Help > > Subject: Templating the solution? > > Author: tjavo87 > > Link to topic: > https://cfengine.com/forum/read.php?3,26068,26068# > msg-26068 > > > > Hi Guys, > > > > I'm working with dynamic bundlesequences as > described on the website from Neil, the first > solution. > > > > > > bundle common g { > > vars: > > > > any:: > > > > "bseq" slist => { > > "site", > > "ntp", > > "hard" > > }, > > policy => "free"; > > > > cf_dbs:: > > > > "bseq" slist => { > > @{bseq}, > > "db2", > > "mysql" > > }, > > policy => "free"; > > > > cf_webfarm:: > > > > "bseq" slist => { > > @{bseq}, > > "httpd", > > "proxy", > > "ntp" > > }, > > policy => "free"; > > } > > > > > > The code is copied from the website but with one > execption. Under the cf_webfarm I've also defined > the ntp bundlesequence. For the cf_webfarm class >
array of lists expansion
Hi all OK, I admit this must be *dumb*, but I cannot get out of this... Suppose I have an array of lists: "array[key1]" slist => { ... } ; "array[key2]" slist => { ... } ; . . . "array[keyN]" slist => { ... } ; and suppose that $(selector) contains one of the keys. Given that, I'd like to expand the list in $(array[$(selector)]) into a separate list. I tried everything I thought sensible, but with no much success to be honest: e.g.: "list" slist => { "@(array[$(selector)])" } ; seems not to do exactly that; rather, it's creating a "reference" to that list; "list" slist => { @(array[$(selector)]) } ; "list" slist => { @($(array[$(selector)])) } ; don't work at all. Suggestions? Thanks -- M ___ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
Re: array of lists expansion
On 06/25/2012 09:10 AM, Marco Marongiu wrote: > Hi all > > OK, I admit this must be *dumb*, but I cannot get out of this... > > Suppose I have an array of lists: > > "array[key1]" slist => { ... } ; > "array[key2]" slist => { ... } ; > . . . > "array[keyN]" slist => { ... } ; > > > and suppose that $(selector) contains one of the keys. Given that, I'd > like to expand the list in $(array[$(selector)]) into a separate list. I > tried everything I thought sensible, but with no much success to be > honest: e.g.: > > "list" slist => { "@(array[$(selector)])" } ; Take a look at this example. It doesn't do exactly what you want but it will pull the list out of the array. I'm not sure how to get the list from each array index combinded into one list. https://gist.github.com/2988934 ___ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
Re: array of lists expansion
Here it is inline for the archives. body common control { bundlesequence => { "main", }; inputs => { "cfengine_stdlib.cf", }; } bundle agent main { vars: "array[key1]" slist => {"array1_key1_item1", "array1_key1_item2"}; "array[key2]" slist => {"array1_key2_item1", "array1_key2_item2"}; "keys" slist => getindices("array"); "array_list_$(keys)" slist => { "@(array[$(keys)])" }; reports: cfengine:: "$(array_list_key1)"; "$(array_list_key2)"; } ___ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
Re: CFEngine Help: Re: 3.1.4 => 3.3.4: has something changed regarding classes in bundles?
On Sat, 23 Jun 2012 19:34:36 +0200 (CEST) davidlee wrote: n> As it was, the "$(key)_in_file" was OK for a single call, but could fail when called on different files with the same key. n> The revised version "$(key)_in_$(file)" allows multiple calls for the same key on different files; it adds file-based uniqueness. ... n> I think you'll agree that this attempt at fudging global uniqueness is getting messy, and may still be prone to yet other non-uniqueness circumstances. n> The only clean solution is to use something of truly local, not global, scope. But is there such a thing available to us? In Design Center, cf-sketch feeds the bundles a unique prefix for every activation, which lets you create a "canonical prefix" for each top-level bundle call. grep for "canon_prefix", you'll see it. It doesn't solve the problem either (a leaf bundle can be invoked multiple times), and I would like a "classes_local" body that acts exacly like "classes" but the context it sets is local to the bundle invocation. This is the case for contexts created by other means in a bundle, so it should be possible. Ted ___ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
CFEngine Help: Re: renicing a process
Forum: CFEngine Help Subject: Re: renicing a process Author: neilhwatson Link to topic: https://cfengine.com/forum/read.php?3,25092,26307#msg-26307 One wonder if the C setpriority function might be used the by cf-agent in a new nicing feature. ___ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
CFEngine Help: Re: Templating the solution?
Forum: CFEngine Help Subject: Re: Templating the solution? Author: neilhwatson Link to topic: https://cfengine.com/forum/read.php?3,26068,26308#msg-26308 Verbose output can be misleading. What you see may not be an error. What is the exit status of the agent? Are promises in the bundle evaluated? ___ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
Re: array of lists expansion
Thanks Nick I actually discovered that there was a dumb, but it was not the question: it was me :) Due to a well hidden bug in my code, the list expansion appeared not to be working. It took me some time, some runs of cf-agent -v, and an incremental set of changes in a bundle, to discover that the failing part was an assignment which contained an unset variable. That, in turn, made everything fail in a mysterious way. Summing up, the right way to expand a slist contained in an array element is actually: "list" slist => { "@(array[$(selector)])" } ; However, if you plan to use list as a parameter for a bundle, you'd better prefix the list expansion with the bundle name, e.g.: "list" slist => { "@(testbundle.array[$(selector)])" } ; and then use, e.g. ... edit_line => editbundle("testbundle.list") ; ... otherwise, depending on what you do with list in that editbundle, things may not work properly. Ciao -- bronto ___ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
Re: array of lists expansion
On 06/25/2012 12:50 PM, Marco Marongiu wrote: > Summing up, the right way to expand a slist contained in an array > element is actually: > > "list" slist => { "@(array[$(selector)])" } ; > > However, if you plan to use list as a parameter for a bundle, you'd > better prefix the list expansion with the bundle name, e.g.: > > "list" slist => { "@(testbundle.array[$(selector)])" } ; Glad you got it working. Are you iterating over $(selector)? When I was playing with it briefly that did not seem to work for me. I didn't spend much time looking at it though once I verified the list was pulling out. ___ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
Re: array of lists expansion
On 25/06/12 19:56, Nick Anderson wrote: > On 06/25/2012 12:50 PM, Marco Marongiu wrote: >> Summing up, the right way to expand a slist contained in an array >> element is actually: >> >> "list" slist => { "@(array[$(selector)])" } ; >> >> However, if you plan to use list as a parameter for a bundle, you'd >> better prefix the list expansion with the bundle name, e.g.: >> >> "list" slist => { "@(testbundle.array[$(selector)])" } ; > > Glad you got it working. > > Are you iterating over $(selector)? No, I'm not. I am preparing a policy to create authorized_keys files on a set of server. Depending on which classes a server is in, it must get a different set of keys in its authorized_keys file. I organized my stuff this way: I have an sshgroup array, indexed by group name; each element in the array is a key identifier -- not the key itself. Based on that $(selector), which is a parameter of the bundle, I unroll the list in sshgroup[$(selector)] in a separate list -- this is just for clarity. Iterating on that list, I update my local copy of the corresponding ssh keys. Then I pass the list to an edit_line bundle. The edit_line bundle iterates over this list again, and for each identifier it reads a key into an array sshkey[$(list)] using readfile At this point, creating the authorized_keys file is just a matter of using a single insert_lines promise: "sshkey[$(list)]" ; (OK: two promises: one for the header, plus the one above ;) of course, I use edit_default => empty for this. Not sure it's the best way to do that, but it works very well for me ;) Ciao -- bronto ___ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
Re: array of lists expansion
Apologies, I spotted a few mistakes here: > I am preparing a policy to create authorized_keys files on a set of > server. read "servers" > Depending on which classes a server is in, it must get a > different set of keys in its authorized_keys file. I organized my stuff > this way: > > I have an sshgroup array, indexed by group name; each element in the > array is a key identifier -- not the key itself. read "is a slist of key identifiers -- not the actual keys" -- bronto ___ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
Re: CFEngine Help: Re: It is possible to uses a slist variable in the inputs directive ?
On Mon, Jun 25, 2012 at 12:55 AM, wrote: > Forum: CFEngine Help > Subject: Re: It is possible to uses a slist variable in the inputs directive ? > Author: davidlee > Link to topic: https://cfengine.com/forum/read.php?3,26281,26299#msg-26299 > > Where, please, does the ref. manual describe this quoting/non-quoting? 1.5 Syntax, identifiers and names The CFEngine 3 language has a few simple rules: CFEngine built-in words, and identifiers of your choosing (the names of variables, bundles, body templates and classes) may only contain the usual alphanumeric and underscore characters (‘a-zA-Z0-9_’). All other `literal' data must be quoted. ... CFEngine uses many `constraint expressions' as part of the body of a promise. These take the form: left-hand-side (CFEngine word) ‘=>’ right-hand-side (user defined data). This can take several forms: cfengine_word => user_defined_template(parameters) user_defined_template builtin_function() "quoted literal scalar" { list } As you can see from the preceeding paragraph, scalar values are quoted, lists are not. > I get the feeling that $(foo) has to be quoted every time, without exception. That's right. > But if I say @(bar), it seems that quoting is optional. When such mentions > of @(bar) happen to occur in the ref. manual, the cases seem arbitrary and > confused. > > When should, and should not, mentions of lists of quoted? Per the reference manual, as quoted above, mentions of lists are not quoted. I am sorry your documentation bugs have not been acknowledged yet, bugs in the documentation can really frustrate new users and barrier adoption. Yours truly, Aleksey ___ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
Re: CFEngine Help: Re: renicing a process
I'd love to be able to make promises about certain processes running nicely. I could use that in production today. Right now I have a shell script monitoring this case. I'd love to be able to use CFEngine to take care of it. I've opened a feature request ticket: https://cfengine.com/bugtracker/view.php?id=1197 Aleksey On Mon, Jun 25, 2012 at 10:46 AM, wrote: > Forum: CFEngine Help > Subject: Re: renicing a process > Author: neilhwatson > Link to topic: https://cfengine.com/forum/read.php?3,25092,26307#msg-26307 > > One wonder if the C setpriority function might be used the by cf-agent in a > new nicing feature. > > ___ > Help-cfengine mailing list > Help-cfengine@cfengine.org > https://cfengine.org/mailman/listinfo/help-cfengine ___ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
CFEngine Help: Re: Templating the solution?
Forum: CFEngine Help Subject: Re: Templating the solution? Author: tjavo87 Link to topic: https://cfengine.com/forum/read.php?3,26068,26316#msg-26316 Hi, The exit status when running the cf-agent is 0. Promises in the bundles are not evaluated. Only the input files are parsed. Regards, neilhwatson Wrote: --- > Verbose output can be misleading. What you see > may not be an error. What is the exit status of > the agent? Are promises in the bundle evaluated? ___ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
CFEngine Help: Re: Templating the solution?
Forum: CFEngine Help Subject: Re: Templating the solution? Author: tjavo87 Link to topic: https://cfengine.com/forum/read.php?3,26068,26315#msg-26315 Hi, The exit status is 0 when running the cf-agent. Prromises in the bundle are not evaluated. Only the input files are parsed. neilhwatson Wrote: --- > Verbose output can be misleading. What you see > may not be an error. What is the exit status of > the agent? Are promises in the bundle evaluated? ___ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
CFEngine Help: Re: Templating the solution?
Forum: CFEngine Help Subject: Re: Templating the solution? Author: neilhwatson Link to topic: https://cfengine.com/forum/read.php?3,26068,26304#msg-26304 Does the agent actually return an error status? Does the all_garbage bundle get executed? Verbose agent output can be very confusing. Most of the time the output is just a message and not an error. ___ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine