Here's the problem: I have lots of server configuration files written in YAML, one file per server. There are a bunch of servers but actually only a few general types of them according to their respective main purpose (e.g. web servers, DNS servers, MySQL database servers, file servers, etc). However, some servers would be a little different from each other e.g. they have certain specific features turned on or off, etc. And of course each would have unique configuration items like IP address and hostname.

Now I would like to refactor these configuraion files, making them as, say, *.yamlt files where they can later be processed into the final *.yaml files.

The .yamlt file could contain normal YAML, or a reference/"use"/"include" statement followed by another .yaml/yamlt filename, optionally followed by a few specific differences. Sort of a parameterized templating, or inheritance templating, lacking a better terms. Basically for the config of a certain server I want to instruct, "use this type of server as a base, but turn feature A and B off, feature C on."

The YAML structure is a bit complex, sort of like a tree/registry, instead of a simple one-level hash.

Any idea how one might do this?


In reply to YAML + template/reuse by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.