From 4e6d78da54dcb05596dbc0a5147c53cebbd0feb5 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Tue, 5 Jul 2022 15:37:47 +0200 Subject: [PATCH] Customize the catalina shared loader. --- defaults/main.yml | 21 +++++++++++---------- templates/catalina.properties.j2 | 13 +++++++++---- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 22a3617..6b35a88 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,6 @@ --- tomcat_version: 8 -#tomcat_catalina_home_dir: '/usr/share/tomcat{{ tomcat_version }}' +# tomcat_catalina_home_dir: '/usr/share/tomcat{{ tomcat_version }}' tomcat_m_instances_install: True tomcat_m_host_manager_install: False @@ -9,21 +9,21 @@ tomcat_m_manager_install: False tomcat_m_manager_gui_user_enabled: False tomcat_m_manager_gui_user: guiadmin tomcat_m_manager_gui_r: "manager-gui" -#tomcat_m_manager_gui_pwd: *Use a vault file* +# tomcat_m_manager_gui_pwd: *Use a vault file* tomcat_m_manager_script_user_enabled: True tomcat_m_manager_script_user: scriptadmin tomcat_m_manager_script_r: "manager-script" -#tomcat_m_manager_script_pwd: *Use a vault file* +# tomcat_m_manager_script_pwd: *Use a vault file* tomcat_m_manager_jmx_user_enabled: False tomcat_m_manager_jmx_user: jmxadmin tomcat_m_manager_jmx_r: "manager-jmx" -#tomcat_m_manager_jmx_pwd: *Use a vault file* +# tomcat_m_manager_jmx_pwd: *Use a vault file* tomcat_m_manager_status_user_enabled: False tomcat_m_manager_status_user: statusadmin tomcat_m_manager_status_r: "manager-status" -#tomcat_m_manager_status_pwd: *Use a vault file* +# tomcat_m_manager_status_pwd: *Use a vault file* -#tomcat_m_manager_other_roles: +# tomcat_m_manager_other_roles: # - { role: '', user: '', password: '', user_roles: '' } tomcat_m_instances_port: '8180' @@ -50,6 +50,8 @@ tomcat_m_java_opts_permgen: "-XX:MaxPermSize={{ tomcat_m_permgen_size }}" tomcat_m_additional_java_8_opts: "-XX:+CrashOnOutOfMemoryError" tomcat_m_java_opts: "" tomcat_m_java_gc_opts: "-XX:+UseConcMarkSweepGC" +tomcat_m_enable_catalina_shared_loader: true +tomcat_m_catalina_shared_loader_path: '${catalina.base}/shared/classes,${catalina.base}/shared/*.jar' tomcat_m_catalina_classloader_paths: [] # - lib/mylibdir # - lib/mylibdir/*.jar @@ -58,7 +60,7 @@ tomcat_m_catalina_classloader_paths: [] # response time). If you use that option and you run Tomcat on a machine with # exactly one CPU chip that contains one or two cores, you should also add # the "-XX:+CMSIncrementalMode" option. -#tomcat_m_other_java_opts: "-Djsse.enableSNIExtension=false" +# tomcat_m_other_java_opts: "-Djsse.enableSNIExtension=false" tomcat_m_reverse_proxy_name_enabled: False tomcat_m_reverse_proxy_name: '{{ ansible_fqdn }}' tomcat_m_reverse_proxy_port: '{{ http_port | default(80) }}' @@ -90,12 +92,11 @@ tomcat_m_jmx_disable_additional_ports: True tomcat_m_jmx_localhost_only: False tomcat_m_jmx_ip_address: '{{ ansible_default_ipv4.address }}' -#tomcat_m_jmx_auth_dir: '{{ tomcat_m_instances_base_path }}' +# tomcat_m_jmx_auth_dir: '{{ tomcat_m_instances_base_path }}' # tomcat_m_jmx_monitorpass: define_in_a_vault_file # tomcat_m_jmx_controlpass: define_in_a_vault_file # This is only an example. Insert a line for each tomcat instance. 'app_contexts' can be used to automatically configure apache or nginx virtualhost http/ajp proxy # -#tomcat_m_instances: +tomcat_m_instances: [] # - { http_enabled: True, http_port: '{{ tomcat_m_instances_port }}', http_address: '127.0.0.1', ajp_enabled: False, ajp_port: '8109', ajp_address: '127.0.0.1', restart_timeout: '{{ tomcat_m_restart_timeout }}', shutdown_port: '8105', java_home: '{{ jdk_java_home }}', user: '{{ tomcat_m_default_user }}', user_home: '{{ tomcat_m_instances_base_path }}', user_shell: '{{ tomcat_m_default_user_shell }}', instance_path: '{{ tomcat_m_instances_base_path }}/8180', max_threads: '{{ tomcat_m_max_threads }}', autodeploy: '{{ tomcat_m_webapps_autodeploy }}', unpack: '{{ tomcat_m_webapps_unpack }}', install_server_xml: True, default_conf: True, java_opts: '{{ tomcat_m_java_opts }}', java_gc_opts: '{{ tomcat_m_java_gc_opts }}', proxy_enabled: '{{ tomcat_m_proxy_enabled }}', other_java_opts: '{{ tomcat_m_other_java_opts }}', jmx_enabled: '{{ tomcat_m_jmx_enabled }}', jmx_disable_additional_ports: '{{ tomcat_m_jmx_disable_additional_ports }}', jmx_auth_enabled: '{{ tomcat_m_jmx_auth_enabled }}', jmx_auth_dir: '{{ tomcat_m_instances_base_path }}/8180/conf', jmx_port: '{{ tomcat_m_jmx_port }}', jmx_monitorpass: '{{ set_in_a_vault_file }}', jmx_controlpass: '{{ set_in_a_vault_file }}', remote_debugging: '{{ tomcat_m_enable_remote_debugging }}', remote_debugging_uri: '{{ tomcat_m_remote_debugging_uri }}', access_log_enabled: True, log_rotation_freq: daily, log_retain: 30, allowed_hosts: [ 'xxx.xxx.xxx.xxx/32', 'yyy.yyy.yyy.yyy/32' ], app_contexts: [ 'app1', 'app2' ] } - diff --git a/templates/catalina.properties.j2 b/templates/catalina.properties.j2 index 8108fc3..a5c3da6 100644 --- a/templates/catalina.properties.j2 +++ b/templates/catalina.properties.j2 @@ -37,7 +37,7 @@ package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache # List of comma-separated paths defining the contents of the "common" # classloader. Prefixes should be used to define what is the repository type. # Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute. -# If left as blank,the JVM system loader will be used as Catalina's "common" +# If left as blank,the JVM system loader will be used as Catalinas "common" # loader. # Examples: # "foo": Add this folder as a class repository @@ -50,7 +50,7 @@ common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/l # List of comma-separated paths defining the contents of the "server" # classloader. Prefixes should be used to define what is the repository type. # Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute. -# If left as blank, the "common" loader will be used as Catalina's "server" +# If left as blank, the "common" loader will be used as Catalina s "server" # loader. # Examples: # "foo": Add this folder as a class repository @@ -59,11 +59,12 @@ common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/l # "foo/bar.jar": Add bar.jar as a class repository server.loader=${catalina.base}/server/classes,${catalina.base}/server/*.jar +{% if tomcat_m_enable_catalina_shared_loader %} # # List of comma-separated paths defining the contents of the "shared" # classloader. Prefixes should be used to define what is the repository type. # Path may be relative to the CATALINA_BASE path or absolute. If left as blank, -# the "common" loader will be used as Catalina's "shared" loader. +# the "common" loader will be used as Catalina s "shared" loader. # Examples: # "foo": Add this folder as a class repository # "foo/*.jar": Add all the JARs of the specified folder as class @@ -71,7 +72,11 @@ server.loader=${catalina.base}/server/classes,${catalina.base}/server/*.jar # "foo/bar.jar": Add bar.jar as a class repository # Please note that for single jars, e.g. bar.jar, you need the URL form # starting with file:. -shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/*.jar +{% if item.0.catalina_shared_loader_path is defined %} +shared.loader={{ item.0.catalina_shared_loader_path }} +{% else %} +shared.loader={{ tomcat_m_catalina_shared_loader_path }} +{% endif %} # List of JAR files that should not be scanned for configuration information # such as web fragments, TLD files etc. It must be a comma separated list of