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.
Password file to puppet manifest
#!/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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment