1

I need help on accessing hiera variable value in hiera.yaml file. Suppose I have a hiera.yaml file with the contents:

variable1: 'abc'<br>
variable2: "%{variable1}/xyz"

I mean I want to access/substitute variable1 value in hiera itself. How we can do this?

Thanks, Sanjiv

Vorsprung
  • 32,923
  • 5
  • 39
  • 63
sanjiv
  • 269
  • 4
  • 12
  • use a yaml library in the language of your choice, open the yaml file and read it in, modify the in memory representation of the yaml and then write out the whole thing again – Vorsprung Jan 15 '16 at 16:33
  • I think I was not able to explain the question. Is it possible to replace the value of variable1 so that I can get the variable2 value as "abc/xyz" in hiera.yaml automatically? – sanjiv Jan 16 '16 at 04:17

1 Answers1

3

I am answering my own question. It can be achieved as:

variable2: "%{hiera('variable1')}/xyz"

This is working fine for me with Hiera version 1.3.4 and puppet version: 3.8.4

This is documented on the Puppet/Hiera website under Interpolation Tokens, Variables, and Lookup Functions

Victor Häggqvist
  • 4,484
  • 3
  • 27
  • 35
sanjiv
  • 269
  • 4
  • 12