Ask Your Question
0

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

asked 2017-01-11 08:15:39 -0500

updated 2017-01-12 15:01:40 -0500

DarylW gravatar image

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 flag offensive 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.

Henrik Lindberg gravatar imageHenrik Lindberg ( 2017-01-12 05:48:13 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2017-01-12 14:59:35 -0500

bschonecker gravatar image

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.

edit flag offensive delete link more
1

answered 2017-01-12 15:05:58 -0500

DarylW gravatar image

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}\")"
}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2017-01-11 08:15:39 -0500

Seen: 27 times

Last updated: Jan 12