Puppet Function: windows_msi_installargs

Defined in:
lib/puppet/parser/functions/windows_msi_installargs.rb
Function type:
Ruby 3.x API

Overview

windows_msi_installargs()Any

Return the $install_options parameter as a string usable in an msiexec command

Returns:

  • (Any)


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/puppet/parser/functions/windows_msi_installargs.rb', line 2

newfunction(:windows_msi_installargs, :arity => 1, :type => :rvalue, :doc => <<-EOS
Return the $install_options parameter as a string usable in an msiexec command
EOS
) do |args|

  install_args = args[0]

  arg_string = install_args.map do |option|
    if option.class == Hash
      key_value = option.shift
      "#{key_value[0]}=\"#{key_value[1]}\""
    else
      option
    end
  end
  # When the MSI installargs parameter is passed to the powershell script it's inside
  # a cmd.exe instance, so we need to escape the quotes correctly so they show up as
  # plaintext double quotes to the powershell command. (To correctly escape to a
  # plaintext " you use three "'s in cmd.exe)
  return arg_string.join(' ').gsub('"', '"""')
end