Skip to content

Commit

Permalink
Set JAVA_HOME environment variable for Keycloak service (#293)
Browse files Browse the repository at this point in the history
Fixes #285
  • Loading branch information
treydock authored Jul 15, 2023
1 parent a4c775b commit e5d93e8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
# @param java_package
# Java package name, only used when `java_declare_method` is `class`
# @param java_home
# Java home path, only used when `java_declare_method` is `class`
# Java home path. This value is used when `java_declare_method` is `class`
# as well as to set JAVA_HOME environment variable for the Keycloak service.
# @param java_alternative_path
# Java alternative path, only used when `java_declare_method` is `class`
# @param java_alternative
Expand Down
10 changes: 10 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@
)
end
end

context 'when java_home defined' do
let(:params) { { java_home: '/foo' } }

it do
is_expected.to contain_systemd__unit_file('keycloak.service').with(
content: %r{Environment='JAVA_HOME=/foo'},
)
end
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions templates/keycloak.service.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Environment='JAVA_OPTS_APPEND=<%= scope['keycloak::java_opts'].join(' ') %>'
Environment='JAVA_OPTS_APPEND=<%= scope['keycloak::java_opts'] %>'
<%- end -%>
<% end -%>
Environment='JAVA_HOME=<%= scope['keycloak::java_home'] %>'
User=<%= scope['keycloak::user'] %>
Group=<%= scope['keycloak::group'] %>
ExecStart=<%= scope['keycloak::service_start_cmd'] %>
Expand Down

0 comments on commit e5d93e8

Please sign in to comment.