Rex icon indicating copy to clipboard operation
Rex copied to clipboard

support dynamic cmdb path expansions (custom macros)

Open ehuelsmann opened this issue 7 years ago • 1 comments

The idea is to support something along the lines of

set cmdb => {
    type => "YAML",
    merge_behavior => 'LEFT_PRECEDENT',
    path => [
        "cmdb/{environment}/{server}.yml",
        "cmdb/{environment}/default.yml",
        "cmdb/{roles}.yml",
        "cmdb/{server}.yml",
        "cmdb/default.yml",
        ],
};

Notice the {roles} macro, which is taken from the CMDB YAML files read before that specific expansion pattern.

This pattern could be considered an "include" mechanism due to the merging behaviour of the CMDB YAML combination (dynamic includes); which yaml doesn't specify in its format specification.

ehuelsmann avatar Aug 16 '18 22:08 ehuelsmann

Dumping some thoughts for implementation details:

  • What to do with conflicting macro names, e.g. when both the Rexfile and the CMDB has an entry for environment? Is it an error? Should one of them win? If yes, which one? Should that be configurable?
  • What to do when not a "plain" scalar comes from the CMDB, like arrayrefs, hashrefs or even instances of some object? Perhaps iterate over elements for arrays? How to order them? What about nested structures?
  • What to do about nesting these expansions/macros, e.g. when a role wants to include other roles? What would be a good inclusion order then? Should that be configurable?

I can imagine the first iteration to be a (quite) restricted set of the whole problem domain, and just gradually adding complexity as we explore the desired direction and features.

ferki avatar Jul 29 '20 15:07 ferki