Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interpolate and concatenate Puppet variable inside nested string quotes

Tags:

puppet

I am creating a Puppet configuration file for a service. I would like to add the hostname as a variable in the line. However, it got an error because of nested quotation marks (") in the line.

$hostlocal = "${hostname}"

file {'puppet_facts_example':
  ensure  => file,
  path    => '/tmp/test.txt',
  content => "modparam("topology_hiding", "th_callid_prefix", "$hostlocal_")"
}

If I just print $hostlocal, it shows the hostname correctly. Is there any way to use a Puppet variable inside nested string quotes (")?

I also tried to use template. In the template,

modparam("topology_hiding", "th_callid_prefix", "<$= @hostlocal %>_")"

But the result was no value.

modparam("topology_hiding", "th_callid_prefix", "_")"
like image 471
Mike Avatar asked Mar 17 '26 23:03

Mike


1 Answers

since hostname is a facter variable. it must be referenced as $hostlocal = $::hostname

Thanks vinodh

like image 182
vinodh Avatar answered Mar 23 '26 07:03

vinodh