Rex::CMDB(3pm) | User Contributed Perl Documentation | Rex::CMDB(3pm) |
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.
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.
If only a defined $server is passed, it returns the whole CMDB data structure for the given 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:
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.
2021-03-05 | perl v5.32.1 |