Is there an equivalent to node-config-yml inheritance / overriding in hiera Puppet?

asked 2018-01-22 10:57:48 -0500

leeand00 gravatar image

updated 2018-01-22 11:10:36 -0500

I was coding a configuration in YAML for node.js and needed to override the defaults of a configuration, so I added the node-config-yml library to my project and added the following to index.js:

const cfg = require("node-config-yml");
const path = require("path");
cfg.load(path.join("config", "overrides", "config.yml"));
console.log(cfg.data);

index.js


#include ../config.yml

email: 'bob@bob.com'
experience: *WebdevExperience

./overrides/config.yml


experienceList:  
  - webDevXetex: &WebdevExperience
      posName: 'Web Dev'
      companyName: 'Precision Business Systems'
      city: 'Reading'
      state: 'PA'
      startYear: '2008'
      endYear: '2010'
  - webDevXetex: &PlumberExperience
      posName: 'Plumber'
      companyName: 'Piping Plumbers'
      city: 'Johnstown'
      state: 'PA'
      startYear: '2006'
      endYear: '2008'
company: 'ABC Company'
job: Plumber
email: tom@tmail.com
experience: *PlumberExperience

./config.yaml


And the resulting config (or at least the important part of it) is something like this:

...
      endYear: '2008'
company: 'ABC Company'
job: Plumber
email: bob@bob.com
experience: 
  -  posName: 'Web Dev'
      companyName: 'Precision Business Systems'
      city: 'Reading'
      state: 'PA'
      startYear: '2008'
      endYear: '2010'

Note that the ./config.yml file has it's values overridden by ./overrides/config.yml

Can this same thing be done with puppet YAML config files? And do I need a certain version of puppet, or installation of a particular plugin to achieve this?

edit retag flag offensive close merge delete

Comments

1

In yaml, you would generally have a 'common.yaml' or 'defaults.yaml' which would be the './config.yaml' in your example, and something that is matched higher in your hierarchy would 'override' any values that are specified in it.

DarylW gravatar imageDarylW ( 2018-01-22 14:33:03 -0500 )edit
1

https://puppet.com/docs/puppet/5.3/hiera_intro.html

DarylW gravatar imageDarylW ( 2018-01-22 14:33:38 -0500 )edit

@DarylW Thank man!

leeand00 gravatar imageleeand00 ( 2018-01-22 15:36:53 -0500 )edit