On Fri, Nov 5, 2010 at 12:05 AM, <no-re...@cfengine.com> wrote: > Forum: Cfengine Help > Subject: bundlesequence and inputs using readstringlist > Author: skibumatbu > Link to topic: https://cfengine.com/forum/read.php?3,19057,19057#msg-19057 > > As we start to use cfengine more and more, our bundlesequence is going to > grow longer and longer. Right now it is taking up 2 lines in our promises.cf > file, and we're just starting to roll it out. As we do more, it will only > grow larger. I'd like to do something like this: > > body common control { > bundlesequence => { "$(sequenceinputs.bundles)" }; > inputs => { "$(sequenceinputs.inputs)" }; > } > > bundle common sequenceinputs { > vars: > "dir" string => "/opt/cfengine/var/inputs"; > "inputs" slist => { readstringlist( "$(dir)/inputs", "$.*", "\s",100, > 1000000 ) }; > "bundles" slist => { readstringlist( "$(dir)/bundles", "$.*", "\s",100, > 1000000 ) }; > } > > When I try this, it hangs indefinitely when running > > /opt/cfengine/sbin/cf-agent -v -n > ...snip... > cf3 *********************************************************** > cf3 Loaded persistent memory > cf3 *********************************************************** > cf3 > Verifying the syntax of the inputs... > > I've got to be doing something simple wrong. Any thoughts?
I would recommend againt doing it this way - whenever you take things "out" of cfengine (like storing names in simple text files), you lose a lot of the power of the cfengine syntax, particularly the ability to use classes when building a list. I usually take this approach: have a file called site.cf that has a common bundle in it, and use classes to create and extend a list which you then include as your bundlesequence. Something like this: bundle common g { classes: "web_server" expression => classmatch("ACME_web.*"); "db_server" expression => classmatch("ACME_db.*"); "test_server" expression => classmatch("ACME_.*test.*"); "datacenter_1" expression => classmatch("ACME_.*dc1.*"); "datacenter_2" expression => classmatch("ACME_.*dc2.*"); vars: any:: "common_seq" slist => { "bootstrap_checks", "HelloWorld", "cleanup" }; web_server:: "local_seq" slist => { "apache2" }; db_server:: "local_seq" slist => { "mongoDB" }; test_server:: "local_seq" slist => { "apache2" }; web_server&datacenter_2&Overloaded:: "augment1" slist => { "migrate_web_workload" }; start_cf_procs:: "augment1" slist => { "bootstrap_services" }; any:: # Use this list as your bundlesequence! "site_seq" slist => { "@(g.common_seq)", "@(g.local_seq)", "@(g.augment1)", }, policy => "ifdefined"; } I think you will find this is a much more powerful and flexible approach. As for reading .cf files, hardcoding them into your pomises.cf "include" option can be tedious - however the solution I would prefer to see here is the ability to include a directory (and all the .cf file in it), in the same way other tools like Nagios and Apache allow you to do. > Scott > > _______________________________________________ > 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