[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Multiple values for variables
From: |
Josh Smith |
Subject: |
Multiple values for variables |
Date: |
Thu, 17 Feb 2005 16:52:29 -0800 |
Short version: I define a variable to point to a directory, containing a
set of files I want to install on a host. Each host usually only gets the
files from at most one of these directories, but sometimes I want to put
the contents of two directories on a single host. Can I do that in
cfengine? If I were using Perl or a similar language, I'd make the
variable an array, and iterate over it, but I don't know if cfengine can
do that, or do this some other way.
Details:
I have a collection of servers, each of which runs a service or two. For
some of those services, the server has a separate IP address (on a virtual
interface) for the service: For example, ns.cacr.caltech.edu is a separate
IP address that runs as a virtual interface on a host called 'tulum'. One
advantage of this is that if the host is off the air for some reason --
for scheduled maintenance, an unplanned outage, whatever -- I can easily
swing the service over to another host just by moving the IP address.
Well, and the associated configuration files for the service, which is
where cfengine comes in.
I use cfengine to move the IP address as well: I'm running Fedora Core 3,
and I have a set of directories named things like 'dns-cacr', containing
the various ifcfg-eth0:$foo files (some services, like Apache, might have
multiple IP addresses, for IP-based virtualhosting). My cfengine
configuration has, e.g:
groups:
server_apache_cacr = ( thebes )
server_dns_cacr = ( tulum )
ifcfg_multi = ( server_apache_cacr server_dns_cacr )
control:
ifcfg_multi.server_apache_cacr::
network_ifcfg_dirname = ( "apache-cacr" )
ifcfg_multi.server_dns_cacr::
network_ifcfg_dirname = ( "dns-cacr" )
copy:
ifcfg_multi::
$(configdir)/network/ifcfg/$(network_ifcfg_dirname)
dest=/etc/sysconfig/network-scripts
owner=root group=root mode=0444
recurse=1
backup=false
define=reload_ifcfg
(plus a shellcommands block to activate the interface based on the
reload_ifcfg class)
All well and good; but what if I tulum dies, and I want to move DNS to
thebes temporarily? If I replace tulum with thebes in the server_dns_cacr
class, I get
cfengine::/var/cfengine/mf/cfengine/cfagent.conf/generic:135: Warning:
Redefinition of macro network_ifcfg_dirname=apache-cacr (or perhaps
missing quote)
which makes sense, as I am in fact redefining that variable, which is in
fact not really what I want to do. What I really want is either for that
variable to have multiple values, or for my copy block to iterate over a
set of variables, or something like that. Is that possible in cfengine? Is
there a better way to do this? Or am I just out of luck?
(I could certainly make a temporary directory "apache-dns-cacr", put the
contents of both directories into it, and then change my cfengine
configuration to use it, but that's clunky enough that I feel like I might
as well just copy the files and fire up the interface by hand at that point.)
-Josh (jbs@cacr.caltech.edu)
- Multiple values for variables,
Josh Smith <=