Skip to content

Hiera backend to allow loading multiple JSON files as a single variable

License

Notifications You must be signed in to change notification settings

mapa3m/hiera_multijson_backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

hiera_multijson_backend

Hiera backend to allow loading multiple JSON files as a single variable

  1. Copy multijson_backend.rb to your $RUBLIB/hiera/backend directory
  2. Add multijson to the list of backends in hiera.yaml
  3. Add :multijson: section to hiera.yaml
---
:backends:
  - json
  - multijson
:json:
 :datadir: "%{settings::confdir}/config/hiera"
:multijson:
 :datadir: "%{settings::confdir}/config/hiera"
:hierarchy:
 - "clients/%{::clientcert}"
 - "roles/%{::role}"
 - "domains/%{::domain}"
 - common
  1. Create a directory in multijson :datadir: - directory name should be the variable, i.e if the variable you're looking to set is "clientname" - the directory name should be "clientname", if the variable is "client::config::user" - the directory should be "client__config__user" (replace :: with double underscore)
  2. Within the directory, create any number of JSON files. Name of each file becomes the hash key Example: client1.json
{
	"uid":5001,
	"password":"supersecret"
}

client2.json

{
	"uid":5002,
	"password":"evenmoresecret"
}

Resulting hash will be:

{
    "client1":{
        "uid":5001,
        "password":"supersecret"
    },
    "client2":{
        "uid":5002,
        "password":"evenmoresecret"
    }
}

About

Hiera backend to allow loading multiple JSON files as a single variable

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages