-
-
05 Jul 2021 21:04:56 UTC
- Distribution: Rex
- Module version: v1.13.4
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues
- Testers (710 / 4 / 2)
- Kwalitee
Bus factor: 2- 49.25% Coverage
- License: apache_2_0
- Perl: v5.10.1
- Activity
24 month- Tools
- Download (342.78KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 118 contributors-
Jan Gehring
-
A Happy User
-
Alexander Romanenko
-
Alexandr Ciornii
-
Alex Mestiashvili
-
Ali Polatel
-
alx542
-
Anders Ossowicki
-
Andrej Zverev
-
Andrew Solomon
-
Andy Beverley
-
Arnold Bechtoldt
-
Boris Däppen
-
Brian Manning
-
Cameron Daniel
-
Chris Steigmeier
-
Christophe Wolfhugel
-
Crimson Thompson
-
Daniel Bäurer
-
Daniel Cesario
-
Daniel Dico
-
Denis Silakov
-
Dmitry Kopytov
-
Dominik Schulz
-
E. Choroba
-
Eduardo J
-
Eivin Giske Skaaren
-
elisdg
-
Elmer Quintanilla
-
Eric Johnson
-
Erik Huelsmann
-
Ferenc Erki
-
Franky Van Liedekerke
-
Fran Rodriguez
-
Gabor Szabo
-
Graham Todd
-
Harm Müller
-
Hayato Imai
-
Hiroaki Nakamura
-
Hiroki Matsuo
-
iblinder
-
Ilya Pavlov
-
James D Bearden
-
jdelgado7
-
Jean Charles Passard
-
Jean-Marie Renouard
-
Jeen Lee
-
Jens Berthold
-
Joachim Bargsten
-
John Karr
-
Jon Gentle
-
Joris DE POOTER
-
Jose Luis Martinez
-
Jose Luis Perez Diez
-
Kasim Tuman
-
Keedi Kim
-
Ken Crowell
-
Kent Fredric
-
Kirill Babikhin
-
labbeduddel
-
Leah Neukirchen
-
LeMerP
-
Mario Domgoergen
-
Max E. Aubrey
-
Mitch Broadhead
-
Nathan Abu
-
Naveed Massjouni
-
necrophcodr
-
Nicolas Leclercq
-
Nigel Gregoire
-
Nikolay A. Fetisov
-
Nils Domrose
-
okaoka
-
Oleg Hardt
-
Olivier Cherrier
-
Orange
-
Paco Esteban
-
Patrick Lauer
-
Pavel Timofeev
-
perlancar
-
Peter H. Ezetta
-
Peter Manthey
-
petersonchen
-
Pierrick DINTRAT
-
Piotr Karbowski
-
Prajithp
-
Randy Lauen
-
Renée Bäcker
-
Robert Abraham
-
Roy Storey
-
Samuele Tognini
-
Sascha Askani
-
Sascha Guenther
-
Simon Bertrang
-
Solène Rapenne
-
Stephane Benoit
-
Steve Dondley
-
Sven Dowideit
-
Tamas Molnar
-
Tianon Gravi
-
Tokuhiro Matsuno
-
Tomohiro Hosaka
-
Volker Kroll
-
Walery Wysotsky
-
Yanick Champoux
-
Yegor Korablev
-
Zane C. Bowers-Hadley
-
Сергей Романов
-
范野人
-
饶琛琳
-
Cuong Manh Le
-
David Golovan
-
Dominik Danter
-
Ilya Evseev
-
Niklas Larsson
-
Qiao Liu
-
Renato CRON
-
Peter Jankovics
- Dependencies
- AWS::Signature4
- Carp
- Cwd
- Data::Dumper
- Data::Validate::IP
- Devel::Caller
- Digest::HMAC_SHA1
- Digest::MD5
- English
- Exporter
- Fcntl
- File::Basename
- File::Spec
- File::Spec::Unix
- File::Spec::Win32
- FindBin
- HTTP::Request
- HTTP::Request::Common
- Hash::Merge
- IO::File
- IO::Select
- IO::Socket
- IO::String
- IPC::Open3
- JSON::MaybeXS
- LWP::UserAgent
- List::Util
- MIME::Base64
- Net::OpenSSH::ShellQuoter
- POSIX
- Scalar::Util
- Sort::Naturally
- Storable
- Symbol
- Term::ReadKey
- Test::Builder::Module
- Text::Glob
- Text::Wrap
- Time::HiRes
- UNIVERSAL
- URI
- URI::QueryParam
- XML::Simple
- YAML
- attributes
- base
- constant
- lib
- overload
- strict
- vars
- version
- warnings
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
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, 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 is also a no_create_home option similar to create_home but doing the opposite. If both used, create_home takes precedence as it the preferred option to specify 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.
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.
get_user($user)
Returns all information about $user.
user_groups($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, };
lock_password($user)
Lock the password of a user account. Currently this is only available on Linux (see passwd --lock) and OpenBSD.
unlock_password($user)
Unlock the password of a user account. Currently this is only available on Linux (see passwd --unlock) and OpenBSD.
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.
Module Install Instructions
To install Rex, copy and paste the appropriate command in to your terminal.
cpanm Rex
perl -MCPAN -e shell install Rex
For more information on module installation, please visit the detailed CPAN module installation guide.