Hi all, I''ve seen this script which "convert a specified passwd file into the user::virtual class ". I''ve noticed that it does not take in count secondary groups. I''ve a perl script which does: ------------------------------------------------------------------------------------------ #!/usr/bin/perl use strict; if ( $#ARGV != 1 ) { die "You must pass 2 args: passwd and group files, and in order\n" } print "class user::virtual {"; open (PASSWD, "$ARGV[0]")||die "passwd file not found"; my @groups; my $name; while (<PASSWD>){ chomp; my @fields=split (/:/,$_); $name=$fields[0]; my $gid=$fields[3]; my $home=$fields[5]; my $uid=$fields[2]; my $desc=$fields[4]; print "\n\n#$_"; open (GROUP, "$ARGV[1]")||die "group file not found"; while (<GROUP>){ my @group_f=split (/:/,$_); if ( $group_f[3] =~ /$name/){ push(@groups,$group_f[0]); } } close (GROUP); if (scalar @groups != 0 ){ print "\nuser { \"$name\":\n ensure \=\> present,\n gid \=\> \"$gid\",\n home \=\> \"$home\",\n name \=\> $name,\n provider \=\> useradd,\n uid \=\> \"$uid\",\n groups \=\> \[ \"".join("\",\"",@groups)."\" \]\n}\n\n"; }else{ print "\nuser { \"$name\":\n ensure \=\> present,\n gid \=\> \"$gid\",\n home \=\> \"$home\",\n name \=\> $name,\n provider \=\> useradd,\n uid \=\> \"$uid\",\n}\n\n"; } @groups=(); } close (PASSWD); print "}\n"; ----------------------------------------------------------------------- Also an other script for groups: #!/usr/bin/perl use strict; if ( $#ARGV != 0 ) { die "You must pass group file as arg\n" } open (GROUP, "$ARGV[0]")||die "passwd file not found"; while (<GROUP>){ chomp; my @fields=split (/:/,$_); my $name=$fields[0]; my $gid=$fields[2]; print "group { \"$name\":\n ensure => \"present\",\n gid => \"$gid\",\n name => \"$name\",\n provider => \"groupadd\",\n}\n\n" } close (GROUP); Maybe someone find it useful... Cheers, Arnau --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---