From fb5233125be9629c4f485fcf092ce445e362ff02 Mon Sep 17 00:00:00 2001 From: Jeremy Clerc Date: Fri, 26 Jan 2024 18:31:07 +0100 Subject: [PATCH] support plugins installation FAR: Install a plugin in tests, the one we have on hand for chef has some issues preventing us to create maven components. Until we've got a better/fixed plugin let's skip the install in tests. --- README.md | 1 + attributes/default.rb | 12 ++++++++++++ resources/default.rb | 14 ++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/README.md b/README.md index 6114744..c8d7141 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ Downloads and installs the latest Nexus 3 Repository Manager OSS. documentation on newer releases. - `node['nexus3']['outbound_proxy']` - Configure outbound HTTP/HTTPS proxy. See example 'Configure outbound HTTP/HTTPS proxy for all the attributes.' +- `node['nexus3']['plugins']` - Install external plugins, takes a hash of `{ 'plugin-name' : { "name": "name override", "source": "..", "checksum": "..", "action": "remote file action"}}`. Plugins should be bundled in KAR format, and will be written on disk as `-bundle.kar` ### Examples diff --git a/attributes/default.rb b/attributes/default.rb index 54caaa2..d94f0ef 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -50,3 +50,15 @@ default['nexus3']['vmoptions_variables']['Dkaraf.startLocalConsole'] = false default['nexus3']['vmoptions_variables']['Djava.net.preferIPv4Stack'] = true default['nexus3']['vmoptions_variables']['Djava.endorsed.dirs'] = 'lib/endorsed' + +# Plugins bundles in KAR format to install +# +# default['nexus3']['plugins']['nexus-repository-chef'] = { +# "name": "force_another_name", +# "source": "https://on.the.internet/nexus-repository-chef-0.0.10-bundle.kar", +# "checksum": "8e6494bd8edbf3beb6b7054d599561e698dcf3f666c2114b7126c246804484a9", +# "action": "create" # https://docs.chef.io/resources/remote_file/#actions +# } +# +# https://help.sonatype.com/en/installing-bundles.html +default['nexus3']['plugins'] = {} diff --git a/resources/default.rb b/resources/default.rb index 539716d..684292a 100644 --- a/resources/default.rb +++ b/resources/default.rb @@ -16,6 +16,7 @@ property :properties_variables, Hash, default: lazy { node['nexus3']['properties_variables'] } 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'] } action :install do install_dir = ::File.join(new_resource.path, "nexus-#{new_resource.version}") @@ -96,6 +97,19 @@ notifies :run, "ruby_block[#{blocker}]", :delayed end + # Install plugins + new_resource.plugins.each do |name, config| + plugin_file_path = ::File.join(install_dir, 'deploy', "#{config['name'] || name}-bundle.kar") + remote_file plugin_file_path do + source config['source'] + checksum config['checksum'] + owner new_resource.nexus3_user + action((config['action'] || :create).to_sym) + notifies :restart, "nexus3_service[#{new_resource.service_name}]", :delayed + notifies :run, "ruby_block[#{blocker}]", :delayed + end + end + link new_resource.nexus3_home do to install_dir owner new_resource.nexus3_user