On 02/20/2012 11:36 AM, Nick Anderson wrote: > On 02/20/2012 10:46 AM, Wes Hardin wrote: >> I don't understand the reasoning behind the multitude of bundles. Is there >> a benefit that I'm not seeing? > > Whats a multitude? I have one paramaterized bundle that handles > specifically interface settings, it takes a 1 dimensional array > interfacename[paramater]
"A seperate bundle for each node" seems like a lot a bundles to me and "change the global reference ... each time i add a new node" seems like a lot of changes. How are you calling these node_specific_bundlenames? Individually classed methods promises? >> Cfengine supports multi-dimensional arrays. You can make the the nodename a >> component of the array name. I'm imagining something like this: > > It does indeed support multi-dimensional arrays I have had problems > getting slists back out of an array. I am not sure if its a bug, or if > its something I am doing wrong, in any case it hasn't been enough of a > hindrance thus far for me to continue pursuing. Implicit iteration on slists across bundles is not possible, you must import the slist locally. Other than that, I haven't seen any difference between a stand-alone slist and one contained in an array. See DNS example below. > I dont see anything wrong with your way of defining the configuration > either. I am curious how you would iterate over > "netconf[host0][eth0][PARAMATER]" Do you define a list of valid > parameters? As far as I know getindices wont work on a multidimensional > array. If you narrow your multi-dimensional array down to just a single dimension, getindices works just fine. See NIS example below. >> I don't think this is an issue when using the set_variable_values bundle >> from the COPBL, but before using a variable in an edit_line promise, I >> suggest you make sure that the variable exists. That way you don't end up >> with an unexpanded Cfengine variable name in your configuration files. See >> the isvariable function for this purpose. Should probably check that the >> "interfaces" slist is defined too before you use it in the files promise. I >> suspect it might try to create a file with the unexpanded variable name in >> the file name if the variable isn't defined first. > > You should share your bundles that help you manage this, sounds like > there might be some good examples the community could benefit from. Sure thing. Two examples here, both share a common global multi-dimensional array which I have broken down by site. DNS config uses slist for nameservers. NIS config uses getindices to iterate over NIS servers. This is not a full working example, how I set my $(mysite.site) variable is missing as are some class bodies (which may come from the COPBL). IPs and host names have been changed to protect me from doing something stupid. bundle common mysite { vars: "siteconf[dal][full_name]" comment => "City, State, and Country" , string => "Dallas, TX, USA"; "siteconf[dal][short_name]" comment => "City name only" , string => "Dallas"; "siteconf[dal][resolver_config][nameservers]" comment => "DNS servers for the site, in order" , slist => { "10.0.0.1" , "10.1.0.1" , "10.2.0.1" }; "siteconf[dal][nis_config][domain]" comment => "NIS Domain name" , string => "dalnis"; "siteconf[dal][nis_config][server][0]" comment => "Primary NIS Domain server" , string => "dalnis01"; "siteconf[dal][nis_config][server][1]" comment => "Secondary NIS Domain server" , string => "dalnis02"; } bundle agent resolver_config { vars: "dns_search_domains" string => "maxim-ic.com mxim.com dalsemi.com cdc.maxim-ic.com maxim-ic.internal testeng.maximhq.com"; classes: any:: "nameservers_defined" comment => "Test that nameservers are defined in Cfengine policy" , expression => isvariable("mysite.siteconf[$(mysite.site)][resolver_config][nameservers]"); files: nameservers_defined:: "$(sys.resolv)" comment => "Generate resolv.conf" , create => "true" , perms => mog("0444" , "root" , "root") , edit_line => resolvconf , edit_defaults => empty_first_time_backup , classes => if_repaired("resolver_config_modified"); } bundle edit_line resolvconf { vars: "my_dns_servers" comment => "Import the global list of site nameservers" , slist => { "@(mysite.siteconf[$(mysite.site)][resolver_config][nameservers])" }; insert_lines: "search $(resolver_config.dns_search_domains)" comment => "The standard DNS resolver search path"; "nameserver $(my_dns_servers)" comment => "Add the list of DNS servers for the site."; } bundle agent nis_config { classes: any:: "nis_domain_defined" comment => "Test for NIS domain in siteconf array variable" , expression => isvariable("mysite.siteconf[$(mysite.site)][nis_config][domain]"); "nis_server_defined" comment => "Test for NIS domain in siteconf array variable" , expression => isvariable("mysite.siteconf[$(mysite.site)][nis_config][server][0]"); files: redhat.nis_domain_defined.nis_server_defined.:: "/etc/yp.conf" comment => "Configure ypbind." , create => "true" , edit_line => ypconf , edit_defaults => empty_first_time_backup , classes => if_repaired("restart_ypbind_service"); } bundle edit_line ypconf { vars: "nis_idx" slist => getindices("mysite.siteconf[$(mysite.site)][nis_config][server]"); insert_lines: "domain $(mysite.siteconf[$(mysite.site)][nis_config][domain]) server $(mysite.siteconf[$(mysite.site)][nis_config][server][$(nis_idx)])" comment => "Add a line for each server in the default domain."; } /* Wes Hardin */ UNIX/Linux Systems Administrator, IT Engineering Support Maxim Integrated Products | Innovation Delivered® | www.maxim-ic.com _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine