3

I've created the next Puppet manifest file:

node 'puppetmaster' {
    package { "screen": ensure => "installed"}
    $enhancers = [ "pixman","pixman-devel","libXfont","tigervnc-server" ]
    package { $enhancers: ensure => "installed" }
    file { '/etc/skel/.vimrc':
    content => ":set nu\n :set incsearch\n :set ignorecase\n :set smartcase\n:set ts=2",}
    file { '/root/.vimrc':
    content => ":set nu\nset incsearch\n:set ignorecase\n:set smartcase\n:set ts=2",}
    file { '/etc/sysconfig/vncserver':
    content => 'VNCSERVERS="6:root"\nVNCSERVERARGS[6]="-geometry 1152x864"',}
 }

After applying the manifest, I check /etc/sysconfig/vncserver and it looks like this:

VNCSERVERS=6:root\nVNCSERVERARGS[6]="-geometry 1152x864"

Instead of being separated to two lines like this:

VNCSERVERS=6:root
VNCSERVERARGS[6]="-geometry 1152x864"

I used the same format when setting the /etc/skel/.vimrc file and it worked like a charm so I don't understand why it doesn't work while trying to set /etc/sysconfig/vncserver, I believe it has something to do with the double quotes "". Any help would be appreciated!

Itai Ganot
  • 10,644
  • 29
  • 93
  • 146

1 Answers1

5

You need to use double quotes ("") instead of single quotes ('). Much like the shell, perl, and other languages, single quotes in Puppet indicate a literal string and inhibit variable interpolation and the interpretation of backslash-escapes.

file { '/etc/sysconfig/vncserver':
  content => "VNCSERVERS=\"6:root\"\nVNCSERVERARGS[6]=\"-geometry 1152x864\"",}

Notice that I've had to escape the double quotes inside the string.

larsks
  • 43,623
  • 14
  • 121
  • 180