44class Hiera ::Interpolate
55 class << self
66 INTERPOLATION = /%\{ ([^\} ]*)\} /
7- METHOD_INTERPOLATION = /%\{ (scope|hiera)\( ['"]([^"']*)["']\) \} /
7+ METHOD_INTERPOLATION = /%\{ (scope|hiera|literal )\( ['"]([^"']*)["']\) \} /
88
99 def interpolate ( data , scope , extra_data )
1010 if data . is_a? ( String )
@@ -24,6 +24,10 @@ def do_interpolation(data, recurse_guard, scope, extra_data)
2424 recurse_guard . check ( interpolation_variable ) do
2525 interpolate_method , key = get_interpolation_method_and_key ( data )
2626 interpolated_data = send ( interpolate_method , data , key , scope , extra_data )
27+
28+ # Halt recursion if we encounter a literal.
29+ return interpolated_data if interpolate_method == :literal_interpolate
30+
2731 do_interpolation ( interpolated_data , recurse_guard , scope , extra_data )
2832 end
2933 else
@@ -37,6 +41,7 @@ def get_interpolation_method_and_key(data)
3741 case match [ 1 ]
3842 when 'hiera' then [ :hiera_interpolate , match [ 2 ] ]
3943 when 'scope' then [ :scope_interpolate , match [ 2 ] ]
44+ when 'literal' then [ :literal_interpolate , match [ 2 ] ]
4045 end
4146 elsif ( match = data . match ( INTERPOLATION ) )
4247 [ :scope_interpolate , match [ 1 ] ]
@@ -58,5 +63,10 @@ def hiera_interpolate(data, key, scope, extra_data)
5863 Hiera ::Backend . lookup ( key , nil , scope , nil , :priority )
5964 end
6065 private :hiera_interpolate
66+
67+ def literal_interpolate ( data , key , scope , extra_data )
68+ key
69+ end
70+ private :literal_interpolate
6171 end
6272end
0 commit comments