help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dealing with multiple domains


From: Chris Edillon
Subject: Re: dealing with multiple domains
Date: Mon, 10 Feb 2003 22:54:37 -0400 (GMT+4)

On Mon, 10 Feb 2003, Luke A. Kanies wrote:

> How are people dealing with multiple domains in cfengine?  I obviously
> can't just set it in the file, since it changes per-host, and I definitely
> don't want to have to configure lists in cfengine as to which machine is
> in which domain; I've already got that information stored on the machine,
> so I want cfengine to discover it.
> 
> I didn't realize it, but I have not set the domain names up on all my
> systems except in /etc/resolv.conf, so I can't just call /bin/domainname.
> I figured I could pretty easily just call 'domainname', see if it's set,
> and if not, pull the domain out of /etc/resolv.conf and set everything up
> appropriately:
> 
  first off, domainname returns the NIS domain, not the DNS domain
for the host.  if they happen to be the same at your site i suppose
it would work, but that's not necessarily going to be true everywhere.
linux has a (nonstandard) dnsdomainname program which returns everything
after the first dot in the hostname (which is all that cfengine seems
to do when setting the domain class if the hostname is fully-qualified),
but that won't help you on other platforms.
  second, it also seems that nested macros aren't allowed, so that's why
your "domain = ( ${tmpdomain} )" doesn't work.  my first thought was to
use a module to re-define domain based on a small shell script which looks
in /etc/resolv.conf, but the next roadblock is that the domain macro is a
global variable internally, which apparently can only be changed by
"domain = ( )" in the control: section.
  you can use ExecResult just fine though, so i'd write a small script
which gets the domain from /etc/resolv.conf and use ExecResult:

control:
    domain  =  ( ExecResult(/var/cfengine/scripts/getdomain) )


#!/bin/sh
# getdomain
PATH=/bin
echo `grep ^domain /etc/resolv.conf | awk '{print $2}'`

you might want to make the script more robust by checking for a
search directive as well (assuming the proper domain is the first
one listed in the search list), and returning "undefined.domain"
if you can't figure it out from /etc/resolv.conf.


chris





reply via email to

[Prev in Thread] Current Thread [Next in Thread]