Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(MODULES-2971) Add java_home to all operating systems #184

Merged
merged 5 commits into from
Oct 17, 2016
Merged

(MODULES-2971) Add java_home to all operating systems #184

merged 5 commits into from
Oct 17, 2016

Conversation

ntpttr
Copy link

@ntpttr ntpttr commented Jul 17, 2016

This patch adds the java_home variable to all supported
operating systemd, and gives the user the option to
set it themselves. It also updates config.pp to
ensure that the JAVA_HOME variable is set to
the desired java_home.

This patch adds the java_home variable to all supported
operating systemd, and gives the user the option to
set it themselves. It also updates config.pp to
ensure that the JAVA_HOME variable is set to
the desired java_home.
@@ -9,6 +9,11 @@
unless => "test /etc/alternatives/java -ef '${java::use_java_alternative_path}'",
}
}
if $java::use_java_home != undef {
file { '/etc/environment':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is used for environment variables of all processes, so should not be directly managed by this module as any other lines would be erased or it would cause puppet resource conflicts.

Is there any other possible way to solve this? Or do we just have to leave JAVA_HOME settings up to the user to implement?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I wasn't really sure which way to go here - as it is the $java_home variable is being set, but unless I'm mistaken I don't think it's actually ever used. Is there no way for two different classes/modules to touch the same file without creating a resource conflict? (Like using line_in_file in ansible or something)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you use an exec resource to echo JAVA_HOME to /etc/environment instead?

Nate Potter and others added 3 commits September 17, 2016 11:58
This commit changes the way the JAVA_HOME variable is added to
/etc/environment from using a file resource to using an exec
resource. This way we can avoid resource conflicts with the
file.

Signed-off-by: Nate Potter <ntpttr@gmail.com>
@ntpttr
Copy link
Author

ntpttr commented Oct 3, 2016

The tests are passing now - would it be possible to remove the tests-fail lable?

user => 'root',
command => "echo JAVA_HOME=${$java::use_java_home} >> /etc/environment",
unless => "grep -Fx \"JAVA_HOME=${$java::use_java_home}\" \"/etc/environment\"",
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think this is exactly what file_line from stdlib is for: https://github.com/puppetlabs/puppetlabs-stdlib#file_line

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it is, updated the PR.

This commit updates the setting of JAVA_HOME in /etc/environment
to be done with file_line rather than exec.
@ntpttr
Copy link
Author

ntpttr commented Oct 14, 2016

Not sure why the facter test is hanging just on job 403.3, on my machine with ruby 2.3.1 and puppet 4 all the tests are passing.

@hunner
Copy link
Contributor

hunner commented Oct 14, 2016

The hanging is something we're seeing across the board. We think it's caused by mocha 1.5?

file_line { 'java-home-environment':
path => '/etc/environment',
line => "JAVA_HOME=${$java::use_java_home}",
match => 'JAVA_HOME=',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would say "look for a match of JAVA_HOME= and if found then assume it is updated. This would cause file_line to update the environment once and never again.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the file_line documentation, it looks like 'replace' defaults to true, which would mean if a match is found the current implementation would be to replace it with the updated java home for the environment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes. It looks for that line to replace instead of adding the new one, but looks for line exactly already.

@hunner hunner merged commit 06c3f9f into puppetlabs:master Oct 17, 2016
@ntpttr ntpttr deleted the fix/master/modules-2971 branch October 17, 2016 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants