Skip to content

Instantly share code, notes, and snippets.

@aduitsis
Created February 18, 2015 14:41
Show Gist options
  • Save aduitsis/a2910f43f722bed33cb0 to your computer and use it in GitHub Desktop.
Save aduitsis/a2910f43f722bed33cb0 to your computer and use it in GitHub Desktop.

Revisions

  1. aduitsis created this gist Feb 18, 2015.
    28 changes: 28 additions & 0 deletions passwd2puppet.pl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    #!/usr/local/bin/perl -w

    use v5.16;
    use strict;
    use warnings;


    while(<>) {
    chomp;
    my ( $username, $password, $uid, $gid, $class, $change, $expire, $gecos, $home, $shell ) = split ':' // die "cannot parse $_";

    my $group = getgrgid($gid) // die "error, group-id $gid cannot be found in this system";

    say <<EOM
    user { '$username':
    ensure => present,
    password => '$password',
    home => '$home',
    shell => '$shell',
    comment => '$gecos',
    uid => $uid,
    gid => '$group',
    managehome => true,
    }
    EOM


    }