Rex::CMDB(3pm)
π Rex::CMDB β the manual, bestie edition π
okay so first things first: this is the man page for Rex::CMDB (a Perl module, section 3pm, filed under User Contributed Perl Documentation, and honestly? iconic of it). It gives you a β¨ function to access the CMDB β¨ β that's the configuration management database, your new bestie for keeping all the config deets in one place. π
πΈ NAME πΈ
Rex::CMDB β a function to access the CMDB (configuration management database). that's it, that's the name, no notes. π
β¨ DESCRIPTION β¨
So this module exports a function that lets you poke at a CMDB through one common interface β no cap. Every provider gets talked to the same way, so you don't gotta learn a new vibe for each one. π¦
And here's the tea: when the 0.51 feature flag or later is in play, the CMDB is enabled by default, with Rex::CMDB::YAML as the default provider. so like, it just shows up ready to go. main character energy fr fr. π
π SYNOPSIS π
here's the whole vibe in code, verbatim, don't touch it:
use Rex::CMDB;
set cmdb => {
type => 'YAML',
path => [ 'cmdb/{hostname}.yml', 'cmdb/default.yml', ],
merge_behavior => 'LEFT_PRECEDENT',
};
task 'prepare', 'server1', sub {
my %all_information = get cmdb;
my $specific_item = get cmdb('item');
my $specific_item_for_server = get cmdb( 'item', 'server' );
};
see how tidy? {hostname} gets swapped per host, cmdb/default.yml is the fallback boo, and LEFT_PRECEDENT is doing the merge choreography. π
π EXPORTED FUNCTIONS π
two of them, both precious, both giving:
π set cmdb π
set cmdb => {
type => 'YAML',
%provider_options,
};
this one instantiates a specific type of CMDB provider with whatever options you hand over. it returns the provider instance so you can keep it around and use it. π«Ά
heads up bestie: for the options each provider actually supports, you gotta go read that provider's own documentation. this page isn't gonna guess for you. π
π¦ cmdb([$item, $server]) π¦
the query function! the moment we've all been waiting for. it takes optional $item and $server and behaves like this:
- no arguments at all β it gives you back the full CMDB data structure for the current connection. everything, the whole closet. π§
- only a defined
$itempassed β you get just the value for that CMDB item, still for the current connection. one item, one vibe. β¨ - only a defined
$serverpassed β you get the whole CMDB data structure but for the given server instead. π - both
$itemand$serverdefined β you get that specific item, for that specific server. chef's kiss, exactly what you asked for. π
now, the plot twist: the value you get back is a Rex::Value, not a plain Perl thing. so if you wanna assign it to a Perl variable you're gonna need the get cmdb(...) form. like this, literally:
task 'prepare', 'server1', sub {
my %all_information = get cmdb;
my $specific_item = get cmdb('item');
my $specific_item_for_server = get cmdb( 'item', 'server' );
};
and if caching is enabled? after the first query, this function caches the full data structure for the given server under the cache key:
cmdb/$CMDB_PROVIDER/$server
so subsequent hits are basically free. slay. π₯
π real talk reminder: use theget cmdb(...)form when assigning to Perl variables, becauseRex::Valueain't gonna just plop into yourmyfor you. iykyk.
and that's the whole page, bestie. this gem was documented under perl v5.40.1, dated 2025-10-03, and it's part of the Rex::CMDB(3pm) manual β User Contributed Perl Documentation, as always doing the absolute most. go configure something gorgeous. πβ¨π
π¦ 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