anonamonk has asked for the wisdom of the Perl Monks concerning the following question:

Greetings monks,

I have written some perl scripts here and there, but more significantly am just becoming familiar with working in a unix environment. My boss has asked me to replicate the perl modules/perl environment on a number of old servers on our spanking brand new ones.

The modules were installed over 3-4 yrs time. I see the scripts to output what modules I have installed, but there are hundreds, it seems. This is time sensitive and high profile.... Does anyone have tips? What do I need to look out for? Will all the older modules be accessible? Will my applications work if they're not? I know the standard CPAN install usually brings over the latest version; what if I need older versions? We have mostly web apps (database writes and info display, some xsl manipulation). Is this an impossible task to accomplish in a week? (6 servers?)

Thanks in advance.

Replies are listed 'Best First'.
Re: Installing modules, trial by fire
by tachyon (Chancellor) on Oct 24, 2004 at 07:50 UTC

    No problem (famous last words ;-) First decide on a version of Perl. I use 5.6.2 as I don't need the features of 5.8.x (and it is slower for some things). Once you have settled on a version of perl compile and install it on one server (use the source Luke). You can probably accept all the defaults. Next use autobundle feature of CPAN on the old server:

    $ perl -MCPAN -e autobundle [snip] Wrote bundle file /root/.cpan/Bundle/Snapshot_2004_10_24_00.pm

    This will get you your module inventory. On the virgin server run CPAN once to initialise it, then (after you have copied the bundle file over)

    $ perl -MCPAN -e 'install Bundle::Snapshot_YYYY_MM_DD_HH'

    All going well everything should now be installed. You may have to do a few modules by hand. Once you are finished on one server you can (on identical architecture) just tar.gz the /usr/lib/perl5 tree and copy it to the new server and untar in place. You also need to copy/link the actual perl binary (plus perldoc and perlbug binaries) into /usr/bin and you should have another complete perl done. No need to compile perl again or run the CPAN install - it should all just be there and work. Rinse and repeat. A Guide to Installing Modules may be of use if you don't know the perl Makefile && make && make test && make install mantra by heart yet.

    cheers

    tachyon

Re: Installing modules, trial by fire
by ysth (Canon) on Oct 24, 2004 at 09:55 UTC
    It's not clear to me what your boss meant by "replicate". Are you supposed to install a current stable perl and current versions of all the modules you had? That's fairly easy (see the autobundle suggestion), but presumes that there will be a thorough testing cycle before putting the new servers into production.

    A somewhat safer alternative (but perhaps not the best thing in the long run) is to keep the same version of perl and the same module versions. But that can get complicated.

    If you had been on 5.005_03, you may need to upgrade to 5.005_04 (which had really a bare minimum of patches necessary to make it compile on newer operating systems and newer gcc.) If you were using any other version, you need to chose between upgrading or possibly needing to patch perl to even get it to compile.

    If the original build of perl was done sensibly, you should be able to say perl -V:config_args to see what options were used to build perl; this won't work if the -d flag wasn't used or options were provided in the Policy.sh file instead of the command line.

    I would hope that modules that were installed on the old servers were done with some process that involved keeping the tarballs somewhere; if not, you've got some hunting to do. If the older versions are gone from CPAN, you may still find them at http://backpan.cpan.org.

    Even with preserving old versions of everything, you've still got interactions with the operating system or any other software to worry about; don't assume you can just plop the new servers into production and have everything just work.

Re: Installing modules, trial by fire
by kvale (Monsignor) on Oct 24, 2004 at 07:29 UTC
    Well, a week is not a lot of time to debug possible breakage of multiple scripts over hundreds of installed modules. I hope you have a good test suite :)

    CPAN does store old versions of modules (many, not all) so if you have a record of versions, you may be able to recover the original software. Also, packages are stored in the authors directory of the cpan working directory -- if you do not clean that out often, then you may find copies there.

    Probably the easiest approach is to hand build on one machine, checking for errors (you need to do this, because while the modules are unchamged, the compiler, glibc, etc. may be) and then rsync to the other machines.

    Note that many of the modules you find may already be installed as part of the core libraries of perl. It would be easier if you surveyed the scripts to see exactly which modules are use'd or require'd. It may be fewer than you think.

    -Mark

      Hmmm.... do you have any suggestions for a test suite? :) I've honestly never done this before, or on such a large scale. I've just installed modules here and there, but not this many.

      There are six machines, with different modules on each...