Rex::Co...ds::User(3)

πŸ“¦ version 1.14.3, in nixos 26.05, nixpkgs unstable

🌸 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