I have a few machines, one of those has the class dbserver
assigned via ENC.
The other machines run software which need the DB. Now I want to configure this software to be able to connect to the DB. I usually prefer to use the hiera autolookup feature for this. So the software-class, let's call it foo
, has a parameter $dbserver
. This gets looked up in hiera as foo::dbserver
. I can put a hiera lookup in hiera, like
dbserver: foo.bar.example.com
foo::dbserver: "%hiera('::dbserver')"
So I only have to configure the hostname once in hiera. Plus I have to configure the dbserver
-assignment in ENC. And I have to take care, that they match, so that the dbserver
runs on the machine of which I put the hostname into hiera.
Is there a way to automate this? Can I tell hiera to somehow check on which server this class runs and use the hostname of that machine for configuration?
edit1: hiera.yaml
---
:backends: yaml
:yaml:
:datadir: /etc/puppet/hieradata/%{::environment}
:hierarchy:
- "nodes/%{::certname}"
- "clients/%{::client}" # custom fact
- "os_%{::osfamily}"
- common # the code above is inside this common.yaml