Networker

Re: [Networker] automating the creation of multiple clients on a new nsrhost?

2006-04-27 12:42:03
Subject: Re: [Networker] automating the creation of multiple clients on a new nsrhost?
From: Darren Dunham <ddunham AT TAOS DOT COM>
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Date: Thu, 27 Apr 2006 09:39:27 -0700
> I have an idea of how to do this with nsradmin but I thought I'd see if
> anyone can save me the time if it's already been done.
> 
> I'd like to feed a list of hostnames into a script and have the script
> create client definitions for me using nsradmin.  Ideally the script would
> also assign each new hostname to a preset group, with a preset browse and
> retention policy, and with preset directives and all that stuff as well.

Yup.  Lots of times.

Just have the script punch out a text file and either save it for you to
review or if you're happy with it, directly to nsradmin.

I usually change more of the script depending on what data I'm passing
so it's not anything I keep around.  Here's some perl code off the top
of my head...

#!/usr/bin/perl
use strict;
use warnings;
while (<>)   # read in client data
{
  my ($hostname,$schedule,$group) = split;  # Change to reflect your data

  print "create type: NSR client;\n";
  print "name: $hostname;\n";
  print "group: $group;\n";
  print "schedule: $schedule;\n";
  print "retention policy: one year\n;";
  print "browse policy: one month\n;";
  # any other bits you want...
  print "\n";
}

% perl make_clients < client_info > nsradmin_input
# nsradmin -i nsradmin_inpput

-- 
Darren Dunham                                           ddunham AT taos DOT com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >

To sign off this list, send email to listserv AT listserv.temple DOT edu and 
type "signoff networker" in the
body of the email. Please write to networker-request AT listserv.temple DOT edu 
if you have any problems
wit this list. You can access the archives at 
http://listserv.temple.edu/archives/networker.html or
via RSS at http://listserv.temple.edu/cgi-bin/wa?RSS&L=NETWORKER