From 70a6cb6a708d344c23c80f6e155182adca8cd670 Mon Sep 17 00:00:00 2001 From: Damian Bradicich Date: Mon, 28 Jun 2021 16:23:32 -0400 Subject: [PATCH] NEXUS-27617: Added new 3x-docker.rb recipe, this is effectively the rh-docker recipe, without java included (#60) --- README.md | 2 ++ recipes/3x-docker.rb | 74 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 recipes/3x-docker.rb diff --git a/README.md b/README.md index a461bac..d8730d1 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ We also provide a `nexus_repository_manager::docker` recipe which is exactly the OpenShift standards, a directory with the licenses applicable to the software and a man file for help on how to use the software. It also uses an ENTRYPOINT script to ensure the running user has access to the appropriate permissions for OpenShift 'restricted' SCC. + - nexus_repository_manager::3x-docker + Nearly identical to the rh-docker recipe, but excluding the java recipe #### Red Hat help.1 diff --git a/recipes/3x-docker.rb b/recipes/3x-docker.rb new file mode 100644 index 0000000..27ac59c --- /dev/null +++ b/recipes/3x-docker.rb @@ -0,0 +1,74 @@ +# +# Cookbook:: nexus_repository_manager +# Recipe:: 3x-docker +# +# Copyright:: Copyright (c) 2017-present Sonatype, Inc. Apache License, Version 2.0. + +if node['platform'] == 'rhel' + default['yum']['rhel-7-server-rpms']['enabled'] = true + default['yum']['rhel-7-server-rpms']['managed'] = true + default['yum']['rhel-7-server-optional-rpms']['enabled'] = true + default['yum']['rhel-7-server-optional-rpms']['managed'] = true + default['yum']['rhel-7-server-thirdparty-oracle-java-rpms']['enabled'] = true + default['yum']['rhel-7-server-thirdparty-oracle-java-rpms']['managed'] = true +end + +include_recipe 'nexus_repository_manager::users' +include_recipe 'nexus_repository_manager::download' +include_recipe 'nexus_repository_manager::configure' + +set_limit 'nexus' do + type 'hard' + item 'nofile' + value 65536 + use_system true +end + +set_limit 'nexus' do + type 'soft' + item 'nofile' + value 65536 + use_system true +end + +ruby_block "remove java memory settings from nexus.vmoptions" do + block do + file = Chef::Util::FileEdit.new(node['nexus_repository_manager']['nexus_home']['path'] + '/bin/nexus.vmoptions') + file.search_file_delete_line(/^-Xms/) + file.search_file_delete_line(/^-Xmx/) + file.search_file_delete_line(/^-XX:MaxDirectMemorySize/) + file.write_file + end +end + +group 'root' do + action :modify + members 'nexus' + append true +end + +directory '/licenses/' do + owner 'root' + group 'root' + mode '755' + action :create +end + +[ 'help.1', 'uid_template.sh', 'uid_entrypoint.sh', 'licenses/LICENSE' ].each do | file | + cookbook_file "/#{file}" do + source "rh-docker/#{file}" + owner 'root' + group 'root' + mode '755' + end +end + +bash 'uid_template.sh' do + code <<-EOH + /uid_template.sh + EOH +end + +file '/etc/passwd' do + mode '664' +end