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

Add property to configure logback.xml #143

Merged
merged 4 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
default['nexus3']['properties_variables']['nexus-context-path'] = '/'
default['nexus3']['properties_variables']['nexus.scripts.allowCreation'] = 'true'

default['nexus3']['logback_variables'] = {}

default['nexus3']['nofile_limit'] = 65_536

# Nexus JVM tunning
Expand Down
15 changes: 14 additions & 1 deletion resources/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
property :vmoptions_variables, Hash, default: lazy { node['nexus3']['vmoptions_variables'] }
property :outbound_proxy, [Hash, NilClass], sensitive: true, default: lazy { node['nexus3']['outbound_proxy'] }
property :plugins, Hash, default: lazy { node['nexus3']['plugins'] }
property :logback_variables, Hash, default: lazy { node['nexus3']['logback_variables'] }

action :install do
action :install do # rubocop:disable Metrics/BlockLength
install_dir = ::File.join(new_resource.path, "nexus-#{new_resource.version}")

group new_resource.nexus3_group do
Expand Down Expand Up @@ -108,6 +109,18 @@
notifies :run, "ruby_block[#{blocker}]", :delayed
end

template ::File.join(new_resource.data, 'etc', 'logback', 'logback.xml') do
source new_resource.logback_variables['source']
cookbook new_resource.logback_variables['cookbook']
mode '0644'
owner new_resource.nexus3_user
group new_resource.nexus3_group
variables(config: new_resource.logback_variables['config'])
notifies :restart, "nexus3_service[#{new_resource.service_name}]", :delayed
notifies :run, "ruby_block[#{blocker}]", :delayed
not_if { new_resource.logback_variables.empty? }
end
Comment on lines +112 to +122
Copy link
Contributor

Choose a reason for hiding this comment

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

OPT/FAR: we could have a more generic solution allowing to inject any arbitrary template (not only logback).
With a bit of refacto I have the impression we could reuse the same system for nexus.vmoptions, nexus.properties & nexus.rc, and any future config need.


# Install plugins
new_resource.plugins.each do |name, config|
plugin_file_path = ::File.join(install_dir, 'deploy', "#{config['name'] || name}-bundle.kar")
Expand Down