2

I am new to puppet and I want to install Java using puppet. I have standalone puppet installed on my windows systems.

I was able to copy the binaries into specific folder using puppet but not able to set the path. Can anyone please help me to set the simple JAVA_HOME/environment variable using puppet?

Anony
  • 93
  • 1
  • 8
  • possible duplicate of [Set Environment Variables with Puppet](http://stackoverflow.com/questions/18411795/set-environment-variables-with-puppet) – vidit Apr 23 '15 at 12:17
  • I need script specific for windows. – Anony Apr 23 '15 at 12:57
  • seth PATH=%PATH%,C:\ and so on http://stackoverflow.com/questions/9546324/adding-directory-to-path-environment-variable-in-windows – Vishal Biyani Apr 23 '15 at 13:23
  • @vidit most definitely not a duplicate. – Felix Frank Apr 23 '15 at 13:34
  • @FelixFrank - Can you please tell me why it is not? I don't know much about Puppet. How's setting `JAVA_HOME` different from setting an env variable? – vidit Apr 23 '15 at 17:29
  • @vidit it is not, but the question you linked concerns itself with the environment on a Linux system, which is fundamentally different from how Windows goes about it. Even though Puppet tries to abstract from this kind of thing, this is not possible for all use cases, and environment variables are one of them. – Felix Frank Apr 24 '15 at 09:46

1 Answers1

4

There is a module for managing environment variables in Windows.

For example

windows_env { 'JAVA_HOME':
  ensure    => 'C:\JDK',
  mergemode => clobber,
}

The README even presents a specific example

windows_env { 'JAVA_HOME=%ProgramFiles%\Java\jdk1.6.0_02':
  type => REG_EXPAND_SZ,
}
Felix Frank
  • 8,125
  • 1
  • 23
  • 30