When we were starting to work with puppet v4 we realize the benefits of hiera. Its strenghts of merging configurations of different levels of precendence can solve so many problems of having duplicated data. The decission of Ansible to deprecate and remove the possiblity of merging configuration hashes is also understandable because merging can create very complex scenarios. With this collection we want to give you the decision to organise your configuration in another way.
The collection is hosted on galaxy, so you can simply use
ansible-galaxy to install it.
ansible-galaxy collection install codeaffen.hieradata
Alternatively you can install it from source.
git clone https://github.com/codeaffen/ansible-hiera-data.git cd ansible-hiera-data make dist ansible-galaxy collection install codeaffen-hieradata-<version>.tar.gz
vars plugin configuration
The plugin comes with useful defaults to start to use the
hieradata vars plugin without any configuration.
But if you need to customize the configuration you can see in
you can configure the vars plugin eigther via
ansible.cfg parameter in section
hieradata or via environment variables.
You have to keep in mind that the paths for
config are relative to your inventory directory. Without any configuration you have to place
the basedir and config as followed.
. ├── ansible.cfg ├── hieradata ├── hieradata.yml └── hosts
If you want to use a different base then
hieradata you can override it by exporting
HIERADATA_BASE_DIR environment variable. This directory also has to belongs to inventory dirctory.
. ├── ansible.cfg └── inventory ├── hieradata │ └── customer_a ├── hieradata.yml └── hosts
In this example you need to do
export HIERADATA_BASE_DIR=hieradata/customer_a if you want to use
hieradata/customer_a as hiera basedir.
To get more information you can use the following sources: