No commit activity in last 3 years
No release in over 3 years
Consul client for hiera with magic deseralisation
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.10
~> 10.0
 Project Readme

Hiera Consul

A simple interface for delivering puppet hiera configuraton via a consul cluster.

Installation

$ gem install bgch-hiera-consul

Usage

Add the following blocks to your hiera.yaml:

:backends:
  - consul

:consul:
  :host: <address>
  :port: 8500
  :paths:
    - /v1/kv/configuration/%{::environment}
    - /v1/kv/configuration/common
  :autoconvert:
    - yaml
    - json

Other backends can be above or below consul.

There are various other options to the consul block. Autoconvert is optional, and without it all values will be treated as strings.

The hiera_hash and hiera_array functions work correctly.

You may add more paths as you see fit, using hiera interpolation to create dynamic paths based on facts.

Examples

NB Consul also provides a gui at http://<address>:8500/ui if you prefer.

Classes

Hiera always attempts to load a hiera_array of 'classes'.

To include a class called 'users' in all environments (per the consul block above):

curl -X PUT -d '["users"]' http://<address>:8500/v1/kv/configuration/common/classes

Hiera functions

If you load a list of users with hiera(users, []) for example.

To include classes called users and groups in all environments:

curl -X PUT -d '["users", "groups"]' http://<address>:8500/v1/kv/configuration/common/classes

To include (only) support users in the prod environment:

curl -X PUT -d '["support_jim", "support_sally"]' http://<address>:8500/v1/kv/configuration/prod/users

To include (only) dev users in the dev environment:

curl -X PUT -d '["dev_saket", "dev_david"]' http://<address>:8500/v1/kv/configuration/dev/users

To include (only) ops users in all environments:

curl -X PUT -d '["ops_justin", "ops_cathy"]' http://<address>:8500/v1/kv/configuration/common/users

Class Parameters

Once Hiera has found a list of classes, it will attempt to prepopulate the class parameters.

To include structured data from a file:

curl -X PUT -d @<myconfigfile> http://<address>:8500/v1/kv/configuration/common/myconfig

Derivation

Built substantially on top of lynxman's hiera-consul, with a more complete solution for structured data.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ConnectedHomes/bgch-hiera-consul.

License

The gem is available as open source under the terms of the MIT License.