# Add variable in line that contains double quotation mark (")

Hello I am new with Puppet and creating configuration file. I would like to add the hostname as variable in the line. However, it got an error I think because of double quotation mark (") in the line.

$hostlocal = "${hostname}"

file {'puppet_facts_example':
ensure  => file,
path    => '/tmp/test.txt',
content => "modparam("topology_hiding", "th_callid_prefix", "$hostlocal_")"  Is there any way to add the variable in the line contains double quotation mark (") ? Thanks edit retag close merge delete ## Comments 1 think you need to edit your question as some characters got taken as markup - it is now hard to understand what your question is. ( 2017-01-12 05:48:13 -0600 )edit ## 2 Answers Sort by » oldest newest most voted Assuming you're trying to use the fact$::hostname, why would you want to encase the fact in double-quotes? There's no need to do so. Just use $::hostname or if you must,$hostlocal = $::hostname should work. more Assuming you aren't just using the$::hostname fact directly as bschonecker mentioned in his answer, if you wanted to create a string with embedded quotes you would have to escape them.

assuming $::hostname == 'foo.local' and you wish for the content of the file to be modparam("topology_hiding", "the_callid_prefix", "foo.local") file {'puppet_facts_example': ensure => file, path => '/tmp/test.txt', content => "modparam(\"topology_hiding\", \"th_callid_prefix\", \"${::hostname}\")"
}

more