1Rex::Commands::User(3)User Contributed Perl DocumentationRex::Commands::User(3)
2
3
4

NAME

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

DESCRIPTION

9       With this module you can manage user and groups.
10

SYNOPSIS

12        use Rex::Commands::User;
13
14        task "create-user", "remoteserver", sub {
15          create_user "root",
16            uid         => 0,
17            home        => '/root',
18            comment     => 'Root Account',
19            expire      => '2011-05-30',
20            groups      => [ 'root', '...' ],
21            password    => 'blahblah',
22            system      => 1,
23            create_home => TRUE,
24            shell       => '/bin/bash',
25            ssh_key     => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQChUw...";
26        };
27

EXPORTED FUNCTIONS

29   account($name, %option)
30       Manage user account.
31
32        account "krimdomu",
33          ensure         => "present",  # default
34          uid            => 509,
35          home           => '/root',
36          comment        => 'User Account',
37          expire         => '2011-05-30',
38          groups         => [ 'root', '...' ],
39          login_class    => 'staff',   # on OpenBSD
40          password       => 'blahblah',
41          crypt_password => '*', # on Linux, OpenBSD and NetBSD
42          system         => 1,
43          create_home    => TRUE,
44          shell          => '/bin/bash',
45          ssh_key        => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQChUw...";
46
47       There is also a no_create_home option similar to create_home but doing
48       the opposite. If both used, create_home takes precedence as it the
49       preferred option to specify home directory creation policy.
50
51       If none of them are specified, Rex follows the remote system's home
52       creation policy.
53
54       The crypt_password option specifies the encrypted value as found in
55       /etc/shadow; on Linux special values are '*' and '!' which mean
56       'disabled password' and 'disabled login' respectively.
57
58   create_user($user => {})
59       Create or update a user.
60
61   get_uid($user)
62       Returns the uid of $user.
63
64   get_user($user)
65       Returns all information about $user.
66
67   user_groups($user)
68       Returns group membership about $user.
69
70   user_list()
71       Returns user list via getent passwd.
72
73        task "list_user", "server01", sub {
74          for my $user (user_list) {
75            print "name: $user / uid: " . get_uid($user) . "\n";
76          }
77        };
78
79   delete_user($user)
80       Delete a user from the system.
81
82        delete_user "trak", {
83          delete_home => 1,
84          force     => 1,
85        };
86
87   lock_password($user)
88       Lock the password of a user account. Currently this is only available
89       on Linux (see passwd --lock) and OpenBSD.
90
91   unlock_password($user)
92       Unlock the password of a user account. Currently this is only available
93       on Linux (see passwd --unlock) and OpenBSD.
94
95   create_group($group, {})
96       Create or update a group.
97
98        create_group $group, {
99          gid => 1500,
100          system => 1,
101        };
102
103   get_gid($group)
104       Return the group id of $group.
105
106   get_group($group)
107       Return information of $group.
108
109        $info = get_group("wheel");
110
111   delete_group($group)
112       Delete a group.
113
114
115
116perl v5.30.2                      2020-04-06            Rex::Commands::User(3)
Impressum