Jan Gehring > Rex > Rex::Commands::User

Download:
Rex-0.45.3.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  4
Open  0
View/Report Bugs
Source  

NAME ^

Rex::Commands::User - Manipulate users and groups

DESCRIPTION ^

With this module you can manage user and groups.

SYNOPSIS ^

 use Rex::Commands::User;
 
 task "create-user", "remoteserver", sub {
   create_user "root",
     uid => 0,
     home => '/root',
     comment => 'Root Account',
     expire => '2011-05-30',
     groups  => ['root', '...'],
     password => 'blahblah',
     system => 1,
     no_create_home => TRUE,
     ssh_key => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQChUw...";
 };

EXPORTED FUNCTIONS ^

account($name, %option)

Manage user account.

 account "krimdomu",
    ensure   => "present",
    uid      => 509,
    home     => '/root',
    comment  => 'User Account',
    expire   => '2011-05-30',
    groups   => ['root', '...'],
    password => 'blahblah',
    system   => 1,
    no_create_home => TRUE,
    ssh_key        => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQChUw...";
create_user($user => {})

Create or update a user.

get_uid($user)

Returns the uid of $user.

get_user($user)

Returns all information about $user.

user_group($user)

Returns group membership about $user.

user_list()

Returns user list via getent passwd.

 task "list_user", "server01", sub {
   for my $user (user_list) {
     print "name: $user / uid: " . get_uid($user) . "\n";
   }
 };
delete_user($user)

Delete a user from the system.

 delete_user "trak", {
   delete_home => 1,
   force     => 1,
 };
create_group($group, {})

Create or update a group.

 create_group $group, {
   gid => 1500,
   system => 1,
 };
get_gid($group)

Return the group id of $group.

get_group($group)

Return information of $group.

 $info = get_group("wheel");
delete_group($group)

Delete a group.

syntax highlighting: