2

I'm attempting to use Puppet to install an application that requires parameters to be passed to the underlying MSI is a specific way.

Example:

package { 'Vendor Application':
  ensure => '8.4.12.0',
  source => 'C:\setup.exe',
  install_options => '/S /v"REBOOTPROMPT=Supress"'
}

I've noticed that it doesn't matter if I use double quotes for the install_options and escape the inner double quotes or user single quotes, it appears that each time Puppet is adding a slash in front of the double quote.

See below from the --debug output after running "puppet apply test.pp"

Debug: Executing: 'cmd.exe /c start "puppet-install" /w "C:\setup.exe" "/S /v\"REBOOTPROMPT=Supress\""'

Has anyone else encountered this and figured out how to prevent the extra slash from being added?

Thanks!

ferventcoder
  • 347
  • 3
  • 4
  • 12

1 Answers1

1

Puppet automatically adds quotes when there are spaces in install_options. This is by design. However this is quite undesirable when you want to control exactly how the input is passed, which is nearly every time you are using install_options. Due to the auto-quoting, it is adding \ to escape the existing quotes, which is also an undesirable behavior when it comes to Windows.

So your resource here:

package { 'Vendor Application':
  ensure => '8.4.12.0',
  source => 'C:\setup.exe',
  install_options => '/S /v"REBOOTPROMPT=Supress"'
}

Should be passed like:

package { 'Vendor Application':
  ensure          => '8.4.12.0',
  source          => 'C:\setup.exe',
  install_options => ['/S', '/v"REBOOTPROMPT=Suppress"'],
}

Formatting fixes are not required, but follow the Puppet Style Guide. Also fixed a typo (REBOOTPROMPT=Suppress).

Moreover, it's likely you will need to set it like this as it will be passed through cmd.exe /c (as you've seen above):

package { 'Vendor Application':
  ensure          => '8.4.12.0',
  source          => 'C:\setup.exe',
  install_options => ['"', '/S', '/v""REBOOTPROMPT=Suppress""', '"'],
}

If you really want an in depth understanding of how to determine to pass install_options, read install options with quotes or spaces (it applies to any use of install_options, not just with the provider mentioned).

ferventcoder
  • 347
  • 3
  • 4
  • 12
  • 1
    I'd suggest using a more capable provider when it comes to managing Windows software. I won't add it to this answer as you didn't ask for that, but when you end up running into the limits of the built-in Windows provider, a great place to ask for ideas is in Puppet Community Slack (Windows channel). – ferventcoder Jan 04 '18 at 05:10
  • Thanks I think this is going to work, I'll test more and follow up. I still don't understand why it's escaping quotes I've already escaped though? – Douglas Plumley Jan 04 '18 at 14:57
  • @DouglasPlumley It's part of the way Puppet works. If you have spaces in `install_options`, it will automatically quote the values and escape any current quotes. Going about it the way mentioned with an array, it will put the spaces back in automatically but it won't do any escaping or auto-quoting. – ferventcoder Jan 04 '18 at 18:24