sous-chefs / confluence

Development repository for the confluence cookbook
https://supermarket.chef.io/cookbooks/confluence
Other
43 stars 46 forks source link

Should this block evaluate to else case with bundled_jre set to false? #146

Closed rylectro closed 7 years ago

rylectro commented 7 years ago

<% if node['confluence']['install_type'] == 'installer' && node['confluence']['jvm']['bundled_jre'] -%> JRE_HOME="<%= node['confluence']['install_path'] %>/jre/"; export JRE_HOME <% else -%> JRE_HOME="<%= node['java']['java_home'] %>/jre/"; export JRE_HOME <% end -%>

I have set this in attributes file: override['confluence']['jvm']['bundled_jre'] = false

yet this block continues to evaluate true on the IF case, and sets the JRE_HOME to install_path/jre.

rylectro commented 7 years ago

I'm not sure if I was attempting to override properly, but here is what I came up with.

I added the template to my local wrapper cookbook.

template "#{node['confluence']['install_path']}/bin/setenv.sh" do source 'setenv.sh.erb' owner node['confluence']['user'] mode '0644' notifies :restart, 'service[confluence]', :delayed end

modified the setenv.sh.erb by adding = true to the bundled_jre condition <% if node['confluence']['install_type'] == 'installer' && node['confluence']['jvm']['bundled_jre'] == true -%> JRE_HOME="<%= node['confluence']['install_path'] %>/jre/"; export JRE_HOME <% else -%> JRE_HOME="<%= node['java']['java_home'] %>/jre/"; export JRE_HOME <% end -%>

set attribute `override['confluence']['jvm']['bundled_jre'] = false

got desired result

  • template[/opt/atlassian/confluence/bin/setenv.sh] action create
  • update content in file /opt/atlassian/confluence/bin/setenv.sh from 16c10a to bfdd7c --- /opt/atlassian/confluence/bin/setenv.sh 2017-01-23 20:06:48.940535000 +0000 +++ /opt/atlassian/confluence/bin/.chef-setenv20170123-26372-o8qk2e.sh 2017-01-23 20:17:35.184535000 +0000 @@ -51,5 +51,5 @@ export CATALINA_OPTS
       -JRE_HOME="/opt/atlassian/confluence/jre/"; export JRE_HOME
       +JRE_HOME="/usr/lib/jvm/java-8-oracle-amd64/jre/"; export JRE_HOME

`

Without modifying the if condition on the erb, setting the ['confluence']['jvm']['bundled_jre'] = false did not force the condition into the else action.

rylectro commented 7 years ago

Understand now that with installer, it will and is recommended to use the bundled JRE, so the condition would never get to else.

I was under the assumption that Atlassian always recommended using the JDK, which is incorrect. While I have configured confluence many times, I always used the archive and configured manually, never with installer.

This is not a bug, but I will create the PR against this to allow the condition to evaluate to false, if anyone wants to use installer but supply their own JRE_HOME. Up to you if you think it's a valid condition to allow.

legal90 commented 7 years ago

Hi @rylectro, This functionality should work fine as-is and we have it covered by unit tests: https://github.com/parallels-cookbooks/confluence/blob/master/spec/default_spec.rb#L37-L47

Please ensure that you override ['confluence']['jvm']['bundled_jre'] correctly to false (Boolean), not "false" (String). Try to reproduce it on the clean node from the scratch.

You can also investigate what is the actual value of this attribute by adding a print to the recipe:

# your_wrapper_recipe.rb
pp "BUNDLED_JRE_ATTR: #{node['confluence']['jvm']['bundled_jre']}"

or using Node#debug_value:

# your_wrapper_recipe.rb
pp "BUNDLED_JRE_ATTR: #{node.debug_value('confluence', 'jvm', 'bundled_jre')}"
lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.