Cool, thanks! I was on the right path, just missing the classmatch() call. Here's what I've come up with that works but *usually* gives regex errors, though not always, and the junk in quotes changes, making me think there's some sort of memory boundary issue. Am I doing something wrong or should I open a support ticket? bundle common def { vars: "global_pilot_hosts" slist => { "gdcscf3lgmt01", "foo", "bar-a", "baz-b", "blah" };
classes: "pilot_hosts" or => { classmatch(canonify("$(global_pilot_hosts)")) }; } bundle agent blah { vars: "pilot_host_list" slist => { @(def.global_pilot_hosts) }; classes: "gold" and => { regcmp("gd.*", "$(sys.uqhost)") }; reports: gold:: "$(pilot_host_list)"; } # /var/cfengine/bin/cf-agent -Kf ./pilot_test.cf Regular expression error "missing )" in expression "(€¬ ଠ" at 9 Regular expression error "missing )" in expression "(€¬ ଠ" at 9 Regular expression error "missing )" in expression "(€¬ ଠ" at 9 [...snipped 80 more of those errors...] R: gdcscf3lgmt01 R: foo R: bar-a R: baz-b R: blah # Another error message I've seen in otherwise identical output is: Regular expression error "missing terminating ] for character class" in expression " E[ XE[ " at 9 Thanks, Justin -----Original Message----- From: Nakarin Phooripoom [mailto:mynameisje...@gmail.com] Sent: Friday, January 29, 2010 12:24 PM To: Justin Lloyd Cc: help-cfengine@cfengine.org Subject: Re: Turning a hostname list into a class list Could we do something like this following? classes: "test_hosts_c" or => { classmatch(canonify("$(test_hosts)")) }; Cheers, --Nakarin On Jan 29, 2010, at 8:02 PM, Justin Lloyd wrote: > If I have a list of hostnames, many of which have hyphens in them, what’s the > cleanest way of generating a class list. For example, say I have the > following slist, which may come from a text file, LDAP, or may just be > hard-coded in a policy file. > > vars: > “test_hosts” slist => { > “foo” > “bar-a” > “bar-b” > “baz” > }; > > I want to do something to this effect using canonify(): > > classes: > “test_hosts” or => { > “foo”, > “bar_a”, > “bar_b”, > “baz” > }; > > The source variable may be very long, so I don’t want to hard-code the class > definition, too. What would be the simplest way of doing this? > > Thanks, > Justin > > This electronic communication and any attachments may contain confidential > and proprietary > information of DigitalGlobe, Inc. If you are not the intended recipient, or > an agent or employee > responsible for delivering this communication to the intended recipient, or > if you have received > this communication in error, please do not print, copy, retransmit, > disseminate or > otherwise use the information. Please indicate to the sender that you have > received this > communication in error, and delete the copy you received. DigitalGlobe > reserves the > right to monitor any electronic communication sent or received by its > employees, agents > or representatives. > > _______________________________________________ > Help-cfengine mailing list > Help-cfengine@cfengine.org > https://cfengine.org/mailman/listinfo/help-cfengine This electronic communication and any attachments may contain confidential and proprietary information of DigitalGlobe, Inc. If you are not the intended recipient, or an agent or employee responsible for delivering this communication to the intended recipient, or if you have received this communication in error, please do not print, copy, retransmit, disseminate or otherwise use the information. Please indicate to the sender that you have received this communication in error, and delete the copy you received. DigitalGlobe reserves the right to monitor any electronic communication sent or received by its employees, agents or representatives. _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine