[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Build a file with serveral time the same sequence
From: |
Tim Nelson |
Subject: |
Re: Build a file with serveral time the same sequence |
Date: |
Mon, 13 Feb 2006 10:43:18 +1100 (EST) |
On Fri, 10 Feb 2006, Etienne Chove wrote:
On Fri, Feb 10, 2006 at 04:25:20PM +1100, Tim Nelson wrote:
We'll need a little more information before we can help, such as:
- Do you want to generate this on the server, or on each client
- Assuming you want it on the server, do you want a bunch of these
entries in the one file, or do you want them in separate files for
each server?
I have a main server (green), wich have 3 replicat (blue, red, yellow).
The 3 replicat are in the cfengine group 'replicat'.
On the server 'green', I've to generate a unique file with theses lines :
"""
define server blue.localdomain
type replicat
auth ssl /path/to/ssl/blue.ssl
define server red.localdomain
type replicat
auth ssl /path/to/ssl/red.ssl
define server yellow.localdomain
type replicat
auth ssl /path/to/ssl/yellow.ssl
"""
I'd like to generate this file with cfengine, so if I want to add a
replicat, I add it in the group 'replica' and cfengine generate the main
server config and install the service on the replica.
I can't think of any way to do this with cfengine itself.
However, it is possible if you also use cfengine-masterconf (and
cfengine-masterconf-pt) which you can find by going to
http://arpmats.sourceforge.net/ and clicking the cfengine-masterconf link.
If you're using that, it should be possible to embed server-side
perl that will do this.
Alternatively, you could use a perl script that does this:
--------------------------------------------
#!/usr/bin/perl
@replicats = qw(red blue yellow);
$str = join "\n", map {
<<EOT;
define server $_.localdomain
type replicat
auth ssl /path/to/ssl/yellow.ssl
EOT
} @replicats;
putfile("configfile", $str);
$str = join " ", @replicats;
$str = <<EOT;
groups:
any::
replicat = ( $str )
EOT
putfile("classes.conf", $str);
--------------------------------------------
The putfile function puts the string in the file, and is left as
an exercise to the reader.
You would then need to have the following file:
cfagent.conf
--------------------------------------------
import:
any::
classes.conf
main.conf
--------------------------------------------
...and you would put all your main cfengine config in main.conf
The perl code above is untested, but should hopefully give you the
idea.
--
Kind Regards,
Tim Nelson
Server Administrator
P: 03 9934 0888
F: 03 9934 0899
E: tim.nelson@webalive.biz
W: www.webalive.biz
WebAlive Technologies
Level 1, Innovation Building
Digital Harbour
1010 La Trobe Street
Docklands Melbourne VIC 3008
This email (including all attachments) is intended solely for the named
addressee. It is confidential and may contain legally privileged information. If
you receive it in error, please let us know by reply email, delete it from your
system and destroy any copies. This email is also subject to copyright. No
part of it should be reproduced, adapted or transmitted without the written
consent of the copyright owner.
Emails may be interfered with, may contain computer viruses or other defects
and may not be successfully replicated on other systems. We give no
warranties in relation to these matters. If you have any doubts about the
authenticity of an email purportedly sent by us, please contact us immediately.