How do you concatenate strings in a Puppet .pp file?

后端 未结 6 1113
醉话见心
醉话见心 2021-02-03 17:27

Here is my naive approach:

# puppet/init.pp
$x = \'hello \' + 
     \'goodbye\'

This does not work. How does one concatenate strings i

6条回答
  •  北恋
    北恋 (楼主)
    2021-02-03 17:53

    Another option not mentioned in other answers is using Puppet's sprintf() function, which functions identically to the Ruby function behind it. An example:

    $x = sprintf('hello user %s', 'CoolUser')
    

    Verified to work perfectly with puppet. As mentioned by chutz, this approach can also help you concatenate the output of functions.

提交回复
热议问题