puppetlabs / puppetlabs-windows_env

Puppet module for managing Windows environment variables.
https://forge.puppet.com/puppet/windows_env
Apache License 2.0
14 stars 23 forks source link

issue with REG_SZ and REG_EXPAND_SZ on Windows 2012R2 #16

Open mikecurrancs opened 8 years ago

mikecurrancs commented 8 years ago

We use this module with PuppetEnterprise 3.8 and Win2008R2 with no issues, but when I run it in our devlab (puppet 4.2 and win 2012R2) I get the following error

_Parameter type failed on Windows_env[PATH=%ProgramFiles(x86)%\Java\jre1.8.0_72\bin]: Invalid value "Reg_expand_sz[]". Valid values are REG_SZ, REG_EXPANDSZ.

Even though my type is set to REG_EXPAND_SZ -- have you tested this on 2012R2 ? Possible incompatibility ?

badgerious commented 8 years ago

I haven't tested that particular combination, no. Could you show me a sample of the puppet code that results in that error?

mikecurrancs commented 8 years ago

Here is the code that works on PE3.8 / w2k8r2 -- we read in hiera to build the variables below.

class cs_win_java ( $jre_version, $jre_installer, $jre_pkgname, $jre_directory, $staging_path, $puppet_file_mount ) {

file { $jre_installer: ensure => file, owner => 'Administrator', group => 'Administrators', mode => '0770', path => "${staging_path}/${jre_installer}", source => "puppet:///${puppet_file_mount}/${module_name}/${jre_installer}" } -> package { $jre_pkgname: ensure => installed, source => "${staging_path}/${jre_installer}", install_options => ['/s'], } -> windows_env { "PATH=%ProgramFiles(x86)%\Java\${jre_directory}\bin": type => REG_EXPAND_SZ, } -> windows_env { "JAVA_HOME=%ProgramFiles(x86)%\Java\${jre_directory}": type => REG_EXPAND_SZ, } }

mikecurrancs commented 8 years ago

I realized my agent was 4.4.1 and server was 4.3.2 -- replace agent with 4.3.2 , hoping it was a 4.4.x issue -- but same error.

mikecurrancs commented 8 years ago

Well -- I found that I did not have win32/registry installed with puppet server 4.3.2 -- and that there is an open bug report, where your module is listed as affected by the way Ruby 2.1.x (pre-packaged with puppet 4.x) Win32::Registry is handled -- here is the link

https://tickets.puppetlabs.com/browse/PUP-3837

badgerious commented 8 years ago

PUP-3837 was handled by #8, so that shouldn't be an issue. I'm not sure what you mean that you didn't have win32/registry installed with puppet server; it should only be installed on the Windows client, never on the (presumably Linux, but certainly not Windows) server.

I need to spin up a VM to test and I haven't had a chance yet; hopefully this weekend.

badgerious commented 8 years ago

Try:

type => "REG_EXPAND_SZ",

Instead of

type => REG_EXPAND_SZ,

Seems like new puppet interprets unquoted strings differently. I'll have to update the docs.

pngfei commented 8 years ago

quote the REG_EXPAND_SZ, the issue is gone