Rex::C...:Gather(3pm)
๐ธ NAME ๐ธ
Rex::Commands::Gather โ Hardware and Information gathering. It's part of the User Contributed Perl Documentation, bestie, and it's literally the module that goes and finds out everything about your machines. ๐ต๏ธโโ๏ธโจ
๐ DESCRIPTION ๐
Okay so with this module you can gather hardware and software information. That's the whole vibe. โจ
Two things you need to internalize before we go any further, and they're both important:
- All these functions will not be reported.
- These functions don't modify anything.
So likeโฆ they just look. Respectfully. No side effects, no drama, no chaos. They're the safest thing in your whole runbook. ๐ซถ
๐ SYNOPSIS ๐
operating_system_is("SuSE");
That's it. That's the teaser. Slay.
๐ EXPORTED FUNCTIONS ๐
get_operating_system
Will return the current operating system name. Periodt.
task "get-os", "server01", sub {
say get_operating_system();
};
Aliased by operating_system(). ๐
operating_system
Alias for get_operating_system()
get_system_information
Will return a hash of all system information. These Information will be also used by the template function. So like, this is the one the templates are secretly leaning on. iykyk. ๐
kernelname
Will return the kernel name of the operating system. For example on a linux system it will return Linux. Simple, iconic, no notes. ๐
dump_system_information
This function dumps all known system information on stdout. Everything. The whole lore. ๐ข
operating_system_is($string)
Will return 1 if the operating system is $string.
task "is_it_suse", "server01", sub {
if( operating_system_is("SuSE") ) {
say "This is a SuSE system.";
}
};
operating_system_version()
Will return the os release number as an integer. For example, it will convert 5.10 to 510, 10.04 to 1004 or 6.0.3 to 603. It's giving math girlie. ๐งฎโจ
task "prepare", "server01", sub {
if( operating_system_version() >= 510 ) {
say "OS Release is higher or equal to 510";
}
};
operating_system_release()
Will return the os release number as is. No integer glow-up, just the raw string. ๐ฆ
network_interfaces
Return an HashRef of all the networkinterfaces and their configuration.
task "get_network_information", "server01", sub {
my $net_info = network_interfaces();
};
You can iterate over the devices as follow
my $net_info = network_interfaces();
for my $dev ( keys %{ $net_info } ) {
say "$dev has the ip: " . $net_info->{$dev}->{"ip"} . " and the netmask: " . $net_info->{$dev}->{"netmask"};
}
Look at her go. ๐ฅ๏ธ๐
memory
Return an HashRef of all memory information.
task "get_memory_information", "server01", sub {
my $memory = memory();
say "Total: " . $memory->{"total"};
say "Free: " . $memory->{"free"};
say "Used: " . $memory->{"used"};
say "Cached: " . $memory->{"cached"};
say "Buffers: " . $memory->{"buffers"};
};
Tracking your RAM like it's a situationship. ๐ญ
is_freebsd
Returns true if the target system is a FreeBSD.
task "foo", "server1", "server2", sub {
if(is_freebsd) {
say "This is a freebsd system...";
}
else {
say "This is not a freebsd system...";
}
};
is_redhat
task "foo", "server1", sub {
if(is_redhat) {
# do something on a redhat system (like RHEL, Fedora, CentOS, Scientific Linux
}
};
is_fedora
task "foo", "server1", sub {
if(is_fedora) {
# do something on a fedora system
}
};
is_suse
task "foo", "server1", sub {
if(is_suse) {
# do something on a suse system
}
};
is_mageia
task "foo", "server1", sub {
if(is_mageia) {
# do something on a mageia system (or other Mandriva followers)
}
};
is_debian
task "foo", "server1", sub {
if(is_debian) {
# do something on a debian system
}
};
is_alt
task "foo", "server1", sub {
if(is_alt) {
# do something on a ALT Linux system
}
};
is_netbsd
Returns true if the target system is a NetBSD.
task "foo", "server1", "server2", sub {
if(is_netbsd) {
say "This is a netbsd system...";
}
else {
say "This is not a netbsd system...";
}
};
is_openbsd
Returns true if the target system is an OpenBSD.
task "foo", "server1", "server2", sub {
if(is_openbsd) {
say "This is an openbsd system...";
}
else {
say "This is not an openbsd system...";
}
};
is_linux
Returns true if the target system is a Linux System.
task "prepare", "server1", "server2", sub {
if(is_linux) {
say "This is a linux system...";
}
else {
say "This is not a linux system...";
}
};
is_bsd
Returns true if the target system is a BSD System.
task "prepare", "server1", "server2", sub {
if(is_bsd) {
say "This is a BSD system...";
}
else {
say "This is not a BSD system...";
}
};
is_solaris
Returns true if the target system is a Solaris System.
task "prepare", "server1", "server2", sub {
if(is_solaris) {
say "This is a Solaris system...";
}
else {
say "This is not a Solaris system...";
}
};
is_windows
Returns true if the target system is a Windows System.
is_openwrt
Returns true if the target system is an OpenWrt System.
is_gentoo
Returns true if the target system is a Gentoo System.
is_arch
task "foo", "server1", sub {
if(is_arch) {
# do something on a arch system
}
};
is_void
Returns true if the target system is a Void Linux system. ๐
That's the whole page, babe โ every single function, every example, exactly as the original serves it. ๐ซถโจ
This fine piece of documentation ships with perl v5.40.1, dated 2025-10-03, and it's filed under Rex::C...:Gather(3pm). Mwah. ๐ ๐
๐ฆ where this page comes from
- ubuntu resolute: rex 1.16.1-1 ยท Apache-2.0
- ubuntu stonking: rex 1.16.1-1 ยท Apache-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms