Rex::Co...ds::User(3)
πΈ NAME πΈ
Rex::Commands::User β Manipulate users and groups. π
This is the Rex::Co...ds::User(3) manual page from User Contributed Perl Documentation, bestie. Manual name folded in near the top with a little bow on it. π
π¦ DESCRIPTION π¦
With this module you can manage user and groups. Thatβs the whole assignment: users and groups, and youβre gonna slay it. π
β¨ SYNOPSIS β¨
Okay so hereβs the starter pack, bestie:
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,
create_home => TRUE,
shell => '/bin/bash',
ssh_key => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQChUw...";
};
π EXPORTED FUNCTIONS π
π account($name, %option) π
Manage user account. π«Ά
account "krimdomu",
ensure => "present", # default
uid => 509,
home => '/root',
comment => 'User Account',
expire => '2011-05-30',
groups => [ 'root', '...' ],
login_class => 'staff', # on OpenBSD
password => 'blahblah',
crypt_password => '*', # on Linux, OpenBSD and NetBSD
system => 1,
create_home => TRUE,
shell => '/bin/bash',
ssh_key => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQChUw...";
Thereβs also a no_create_home option, similar to create_home but doing the opposite. If both are used, create_home takes precedence because itβs the preferred option for specifying home-directory creation policy.
If none of them are specified, Rex follows the remote system's home creation policy.
The crypt_password option specifies the encrypted value as found in /etc/shadow; on Linux special values are '*' and '!' which mean 'disabled password' and 'disabled login' respectively. Important little vibe check: those special values are Linux-specific, so donβt go inventing new meanings for them, bestie. π
π create_user($user => {}) π
Create or update a user. β¨
This function supports the following hooks:
beforeβ This gets executed before the user is created. All original parameters are passed to it.afterβ This gets executed after the user is created. All original parameters, and the user's"UID"are passed to it.
π get_uid($user) π
Returns the uid of $user. Lowkey essential. π
π¦ get_user($user) π¦
Returns all information about $user. The whole lore drop. π
πΈ user_groups($user) πΈ
Returns group membership about $user. Yes, the group chat knows everything. π«Ά
β user_list() β
Returns user list via getent passwd. Iconic.
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. Bye bestie, no cap. π
delete_user "trak", {
delete_home => 1,
force => 1,
};
π lock_password($user) π
Lock the password of a user account. Currently this is only available on Linux (see passwd --lock) and OpenBSD. Security era. π₯
π unlock_password($user) π
Unlock the password of a user account. Currently this is only available on Linux (see passwd --unlock) and OpenBSD. Let them back in, but make it graceful. π«Ά
π create_group($group, {}) π
Create or update a group. Group chat main character energy. π
create_group $group, {
gid => 1500,
system => 1,
};
π§ get_gid($group) π§
Return the group id of $group. The numeric receipt. π§Ύ
π get_group($group) π
Return information of $group. All the group lore, served fresh. β¨
$info = get_group("wheel");
π delete_group($group) π
Delete a group. Itβs giving clean exit. πͺ
Before you go, bestie: this page was brought to you by perl v5.42.3, dated 2023-08-05, and its manual-name home is Rex::Co...ds::User(3). Mwah πβ¨
π¦ where this page comes from
- nixos 26.05: perl5.42.3-Rex 1.14.3
- nixpkgs unstable: perl5.42.3-Rex 1.14.3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms