Rex::CMDB(3)

πŸ“¦ version 1.14.3, in nixos 26.05, nixpkgs unstable

πŸ‘‘ 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 $item is passed, it returns only the value for that given CMDB item, for the current connection. ✨
  • If only a defined $server is passed, it returns the whole CMDB data structure for that given server. πŸ¦‹
  • If both $item and $server are 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