Rex::CMDB(3)
π NAME π
Okay so bestie, this is the Rex::CMDB(3) page, and the module is Rex::CMDB β it gives you a function to access the CMDB, aka the configuration management database. π
β¨
π¦ DESCRIPTION π¦
This module exports a function so you can access a CMDB through one common interface. No cap, that's the whole vibe.
When the 0.51 feature flag or later is used, the CMDB is enabled by default, and Rex::CMDB::YAML is the default provider. Periodt. π
πΈ SYNOPSIS πΈ
Here's the group-chat screenshot of how it looks, literally:
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' );
};
β¨ EXPORTED FUNCTIONS β¨
π set cmdb π
The setup moment, iconic honestly:
set cmdb => {
type => 'YAML',
%provider_options,
};
This instantiates a specific type of CMDB provider with the options you give it. It returns the provider instance. π«Ά
Please go consult the documentation of that provider for the options it actually supports β that's where the provider-specific tea lives. π
π§ cmdb([$item, $server]) π§
This is the function to query a CMDB. Main character energy, fr fr.
- If you call it with no arguments, it returns the full CMDB data structure for the current connection. π
- If only a defined
$itemis passed, it returns only the value for that given CMDB item, for the current connection. β¨ - If only a defined
$serveris passed, it returns the whole CMDB data structure for that given server. π¦ - If both
$itemand$serverare defined, it returns that given CMDB item for that given server. π
The value returned is a Rex::Value, so you may need the get cmdb(...) form if you'd like to assign the result to a Perl variable. Lowkey important, bestie:
task 'prepare', 'server1', sub {
my %all_information = get cmdb;
my $specific_item = get cmdb('item');
my $specific_item_for_server = get cmdb( 'item', 'server' );
};
If caching is enabled, this function caches the full data structure for the given server under the cmdb/$CMDB_PROVIDER/$server cache key after the first query. Slay. ππ₯
mwah π this page is from perl v5.42.3, dated 2023-08-05 β bye bestie, go query that CMDB ππ
π¦ 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