Rex::CMDB(3pm)

Rex::CMDB3pm

Function to access the cmdb (configuration management database)

Usage

 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' );
 };

Overview

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.

Exported functions

set cmdb

 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.

cmdb([$item, $server])

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.

Releases

5 releases since Debian 9 (Stretch); the text changed 4 times.

  1. 9
  2. 10
  3. 11
  4. 12
  5. 13

From rex 1.16.0-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.