0

I am converting one of my masterless modules to use Consul. How do I use external facts to pass in the Consul host and Consul token? These change in every environment and are not managed by Puppet. I am using the Puppet module 'lynxman-hiera_consul', '0.1.2'. Note that I had to downgrade my hiera.yaml to version 3 to use it with this module.

Before my Puppet masterless run I export some facts

export FACTER_CONSULHOST=consul-randomid..us-west-2.elb.amazonaws.com

export FACTER_MYTOKEN=some-token

I can test this works with

facter mytoken; puppet facts --debug|grep mytoken

facter consulhost;puppet facts --debug|grep consulhost

My hiera.yaml looks like this Hiera.yaml Gist. This works fine if I replace the fact interpolation with strings.

With the basic issue being with the fact interpolation on line 15

:token: "%{facts.mytoken}"

This is my example manifest for testing this Consul.pp Gist

Eric Aldinger
  • 125
  • 1
  • 6
  • Try using the official documentation and let us know if something goes wrong for you by providing more information about what you tried: https://docs.puppet.com/facter/3.7/custom_facts.html#external-facts. Also, you don't need Hiera here as an extra point of failure. Use the facts directly. – Matthew Schuchard Aug 03 '17 at 13:59
  • Thank you. I did. and that was how I learned to add external facts and retrieve them in modules. However, I am using Consul backed Hiera for storing things that change per environment. This requires a Consul token that (for us) differs per environment. The token is stored in the Hiera yaml and I do not see how to override it in a manifest. I need the hiera yaml to have the Consul token interpolated at run time so I can pass in the environment specific Consul token for Hiera to use. – Eric Aldinger Aug 03 '17 at 22:19
  • In case you missed it, the code is linked in gists in the question. – Eric Aldinger Aug 03 '17 at 22:59
  • Oh is the Consul module using Hiera 5 module data? I see now that you are on an old version using Hiera 3. Yeah, you probably need to use an older version of the Consul module or get current with Puppet before moving forward. – Matthew Schuchard Aug 04 '17 at 13:57
  • As of last week the latest version of 'lynxman-hiera_consul' on the Forge was '0.1.2', which is not hiera.yaml v5 compliant. There is a feature request for that to be upgraded, which is not complete. However variable interpolation worked in Hiera 3, note the use of %{environment} in my hierarchy. { :hierarchy: - "%{environment}" - "common" } – Eric Aldinger Aug 04 '17 at 17:11

0 Answers0