Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Perl in a multi-platform environment

by lowcoordination (Initiate)
on Jul 17, 2014 at 13:15 UTC ( #1094040=perlquestion: print w/ replies, xml ) Need Help??
lowcoordination has asked for the wisdom of the Perl Monks concerning the following question:

Hey everyone! I have inherited a new project where we want to migrate some existing perl and shell scripts that our admin team uses for user maintenance purposes into a web based platform. Examples of the functionality would be add/remove user accounts, add/remove groups to user accounts, create/remove groups, password resets, etc. We have AIX, Solaris, and Linux servers in the environment and I was wondering how you go about setting up a system to service all these different flavors of unix. What have you implemented in the past? what was the general methodology used? that sort of thing... Cheers!

Comment on Perl in a multi-platform environment
Re: Perl in a multi-platform environment
by neilwatson (Curate) on Jul 17, 2014 at 13:51 UTC

    I think you should move away from custom scripts for configuration management and consider the excellent choice of ready made tools: CFEngine, Puppet, Chef, and Ansible to name a few.

    I do much consulting on CFEngine, feel free to drop me a line if you have questions.

    I do sometimes have to maintain Perl programs that work with multiple versions. Usually, you have to make the program work on the system that has the oldest Perl installed, the later versions of Perl will usually accept this code without complaint, but you can't be too careful. TEST, TEST, TEST.

    Neil Watson
    watson-wilson.ca

      For Perl, there is Rex (also on http://rexify.org/), which also does remote execution for configuration etc.

Re: Perl in a multi-platform environment
by sundialsvc4 (Monsignor) on Jul 17, 2014 at 18:03 UTC

    Also, in any multi-machine and especially multi-architecture “shop,” it is an excellent idea to standardize all of the authorization and authentication duties upon a well-known industry standard, such as LDAP (Active Directory®) or Kerberos.   Then, you can manage all user accounts from a single authoritative source, and provide for “single sign-on” capability across all platforms.   You no longer have to “roll your own” administrative interfaces for this.

Re: Perl in a multi-platform environment
by bulrush (Sexton) on Jul 17, 2014 at 18:55 UTC
    Another way to do this in Perl.
    $system=`uname`; 
    if ($system=~m/Linux/i)
        {print "Linux\n";
        }
    elsif ($system=~m/Solaris/)
        {
        print "Solaris\n";
        }
    elsif ($system=~m/AIX/)
        {
        print "AIX\n";
        }
    else {
         print "Unknown OS\n";
        }
    
    Perl 5.8.8 on Redhat Linux RHEL 5.5.56 (64-bit)
      Perl already knows your OS, $^O.

      And are you kidding me with that if/else travesty?

      If a small scale change, use a hash of subroutine references to make dispatching easy.

      If you have time, create a parent class and subclass out to each OS (again, if you really have to do different things on each OS).

      use strict; my $os_dispatch = { linux => sub {print qq{Linux\n}}, solaris => sub {print qq{Solaris\n}}, aix => sub {print qq{AIX\n}}, freebsd => sub {print qq{FreeBSD\n}}, darwin => sub {print qq{MacOSX\n}}, unknown => sub {print qq{Unknown\n}}, }; if (exists $os_dispatch->{$^O}) { $os_dispatch->{$^O}->(); } else { $os_dispatch->{unknown}->(); }
      Finally, do you really have to do that much OS specific stuff?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1094040]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2014-08-23 19:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (178 votes), past polls