Rex::CMDB - Function to access the CMDB (configuration management database)
This module exports a function to access a CMDB via a common interface. When the 0.51 feature flag or later is used, the CMDB is enabled by default with Rex::CMDB::YAML as the default provider.
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' ); };
set cmdb => { type => 'YAML', %provider_options, };
Instantiate a specific type of CMDB provider with the given options. Returns the provider instance.
type
Please consult the documentation of the given provider for their supported options.
Function to query a CMDB.
If called without arguments, it returns the full CMDB data structure for the current connection.
If only a defined $item is passed, it returns only the value for the given CMDB item, for the current connection.
$item
If only a defined $server is passed, it returns the whole CMDB data structure for the given server.
$server
If both $item and $server are defined, it returns the given CMDB item for the given server.
The value returned is a Rex::Value, so you may need to use the get cmdb(...) form if you'd like to assign the result to a Perl variable:
get cmdb(...)
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.
cmdb/$CMDB_PROVIDER/$server
To install Rex, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Rex
CPAN shell
perl -MCPAN -e shell install Rex
For more information on module installation, please visit the detailed CPAN module installation guide.