[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RFC: Support for multiple cfrun.hosts files through new include= directi
From: |
Olivier Fauchon |
Subject: |
RFC: Support for multiple cfrun.hosts files through new include= directive |
Date: |
Tue, 09 Aug 2005 17:39:40 +0200 |
User-agent: |
Mozilla Thunderbird 1.0.2 (X11/20050317) |
This is my 2nd submition for this patch.
In my company, we have a multi-site Cfengine Infrastructure, and we find
useful to have one cfrun.host file per site.
The attached patch provides a new "include=" directive for cfrun, so
you can have the following configuration:
/etc/cfengine/cfrun.host:
...
include=cfrun.site1.external.hosts
include=cfrun.site1.internal.hosts
include=cfrun.site2.private.hosts
include=cfrun.site2.shared.hosts
/etc/cfengine/cfrun.site1.external.hosts:
server1.domain1
server2.domain1
/etc/cfengine/cfrun.site1.internal.hosts:
server3.domain3
server2.domain3
/etc/cfengine/site2.private.hosts:
server1.domain2
server2.domain2
/etc/cfengine/cfrun.host:
server3.domain4
server4.domain4
Any comments welcome
Olivier Fauchon
diff -ruN cfengine-2.1.14-old/src/cfrun.c cfengine-2.1.14/src/cfrun.c
--- cfengine-2.1.14-old/src/cfrun.c 2005-02-08 12:50:01.000000000 +0100
+++ cfengine-2.1.14/src/cfrun.c 2005-06-07 15:56:22.000000000 +0200
@@ -52,6 +52,7 @@
int TRUSTALL = false;
enum fileoutputlevels OUTPUTLEVEL = fopl_normal;
char OUTPUTDIR[CF_BUFSIZE];
+char INCLUDEFILE[CF_BUFSIZE];
struct Item *VCFRUNCLASSES = NULL;
struct Item *VCFRUNOPTIONHOSTS = NULL;
@@ -70,7 +71,7 @@
void SendClassData ARGLIST((int sd, char *sendbuffer));
void CheckAccess ARGLIST((char *users));
void cfrunSyntax ARGLIST((void));
-void ReadCfrunConf ARGLIST((void));
+void ReadCfrunConf ARGLIST((char* cfg_fic));
int ParseHostname ARGLIST((char *hostname, char *new_hostname));
void FileOutput ARGLIST((FILE *fp, enum fileoutputlevels level, char
*message));
@@ -245,7 +246,7 @@
}
}
- ReadCfrunConf();
+ ReadCfrunConf(VCFRUNHOSTS);
GetNameInfo();
@@ -553,8 +554,7 @@
/* Level 2 */
/********************************************************************/
-void ReadCfrunConf()
-
+void ReadCfrunConf(char* cfg_fic)
{ char filename[CF_BUFSIZE], *sp;
char buffer[CF_MAXVARSIZE], options[CF_BUFSIZE], line[CF_BUFSIZE];
FILE *fp;
@@ -578,7 +578,7 @@
}
}
-strcat(filename,VCFRUNHOSTS);
+strcat(filename,cfg_fic);
if ((fp = fopen(filename,"r")) == NULL) /* Open root file */
{
@@ -669,6 +669,14 @@
continue;
}
+ if (strncmp(line,"include", strlen("include")) == 0)
+ {
+ sscanf(line,"include = %295[^# \n]", INCLUDEFILE);
+ Verbose("cfrun: include = %s\n", INCLUDEFILE);
+ ReadCfrunConf(INCLUDEFILE);
+ continue;
+ }
+
if (strncmp(line,"access",6) == 0)
{
for (sp = line; (*sp != '=') && (*sp != '\0'); sp++)
@@ -695,6 +703,7 @@
{
continue;
}
+
if (VCFRUNOPTIONHOSTS != NULL && !IsItemIn(VCFRUNOPTIONHOSTS,buffer))
@@ -888,6 +897,7 @@
printf(" cfrun -v -- -k -- solaris Local verbose, all solaris, but no
copy\n\n");
printf("cfrun.hosts file syntax:\n");
printf("# starts a comment\n");
+ printf("include = [file]\t# External cfrun.hosts file to include.\n");
printf("domain = [domain]\t# Domain to use for connection(s).\n");
printf("maxchild = [num]\t# Maximum number of children to spawn during
run.\n");
printf("outputdir = [dir]\t# Directory where to put host output files.\n");
- RFC: Support for multiple cfrun.hosts files through new include= directive,
Olivier Fauchon <=