1Rex::CMDB(3)          User Contributed Perl Documentation         Rex::CMDB(3)
2
3
4

NAME

6       Rex::CMDB - Function to access the CMDB (configuration management
7       database)
8

DESCRIPTION

10       This module exports a function to access a CMDB via a common interface.
11

SYNOPSIS

13        use Rex::CMDB;
14
15        set cmdb => {
16            type => 'YAML',
17            path => [
18                'cmdb/{hostname}.yml',
19                'cmdb/default.yml',
20            ],
21            merge_behavior => 'LEFT_PRECEDENT',
22        };
23
24        task "prepare", "server1", sub {
25          my $virtual_host = cmdb("vhost");
26          my %all_information = cmdb;
27        };
28

EXPORTED FUNCTIONS

30   set cmdb
31       CMDB is enabled by default, with Rex::CMDB::YAML as default provider.
32
33       The path option specifies an ordered list of places to look for CMDB
34       information. The path specification supports any Rex::Hardware variable
35       as macros, when enclosed within curly braces. Macros are dynamically
36       expanded during runtime. The default path settings is:
37
38        [qw(
39            cmdb/{operatingsystem}/{hostname}.yml
40            cmdb/{operatingsystem}/default.yml
41            cmdb/{environment}/{hostname}.yml
42            cmdb/{environment}/default.yml
43            cmdb/{hostname}.yml
44            cmdb/default.yml
45        )]
46
47       Please note that the default environment is, well, "default".
48
49       You can define additional CMDB paths via the `-O` command line option
50       by using a semicolon-separated list of `cmdb_path=path` key-value
51       pairs:
52
53        rex -O 'cmdb_path=cmdb/{domain}.yml;cmdb_path=cmdb/{domain}/{hostname}.yml;' taskname
54
55       Those additional paths will be prepended to the current list of CMDB
56       paths (so the last one specified will get on top, and thus checked
57       first).
58
59       The CMDB module looks up the specified files in order and then returns
60       the requested data. If multiple files specify the same data for a given
61       case, then the first instance of the data will be returned by default.
62
63       Rex uses Hash::Merge internally to merge the data found on different
64       levels of the CMDB hierarchy. Any merge strategy supported by that
65       module can be specified to override the default one. For example one of
66       the built-in strategies:
67
68        merge_behavior => 'LEFT_PRECEDENT'
69
70       Or even custom ones:
71
72        merge_behavior => {
73            SCALAR => { ... },
74            ARRAY  => { ... },
75            HASH   => { ... },
76        }
77
78       For full list of options, please see the documentation of Hash::Merge.
79
80   cmdb([$item, $server])
81       Function to query a CMDB. If this function is called without $item it
82       should return a hash containing all the information for the requested
83       server. If $item is given it should return only the value for $item.
84
85        task "prepare", "server1", sub {
86          my $virtual_host = cmdb("vhost");
87          my %all_information = cmdb;
88        };
89
90
91
92perl v5.28.1                      2017-03-01                      Rex::CMDB(3)
Impressum