From 33d3286e7448d7152ba75aed1f8ffd427ff26772 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 15 Sep 2017 12:44:48 +0200 Subject: [PATCH] Change the tomcat roles so that we are now able to change the default temporary directory. --- tomcat-multiple-instances/tasks/main.yml | 7 ++++++- tomcat-multiple-instances/templates/tomcat-default.j2 | 3 +++ tomcat/tasks/tomcat-pkgs.yml | 6 ++++++ tomcat/templates/tomcat-default.j2 | 4 +++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tomcat-multiple-instances/tasks/main.yml b/tomcat-multiple-instances/tasks/main.yml index ee42680e..c49dec1b 100644 --- a/tomcat-multiple-instances/tasks/main.yml +++ b/tomcat-multiple-instances/tasks/main.yml @@ -56,6 +56,12 @@ register: tomcat_first_install tags: [ 'tomcat', 'tomcat_instances' ] +- name: Create the tmp directory + file: dest={{ item.catalina_tmp_directory }} state=directory + with_items: '{{ tomcat_m_instances }}' + when: item.catalina_tmp_directory is defined + tags: [ 'tomcat', 'tomcat_instances' ] + - name: Populate the instances conf directory copy: src={{ item[1] }} dest={{ item.0.instance_path }}/conf/{{ item[1] }} owner={{ item.0.user }} group={{ item.0.user }} mode=0640 with_nested: @@ -76,7 +82,6 @@ - tomcat restart instances with changed configs tags: [ 'tomcat', 'tomcat_instances', 'tomcat_catalina_properties' ] - - name: Populate the instances conf/policy.d directory copy: src=policy.d/{{ item[1] }} dest={{ item.0.instance_path }}/conf/policy.d/{{ item[1] }} owner={{ item.0.user }} group={{ item.0.user }} mode=0640 with_nested: diff --git a/tomcat-multiple-instances/templates/tomcat-default.j2 b/tomcat-multiple-instances/templates/tomcat-default.j2 index 74ac9143..8e165adc 100644 --- a/tomcat-multiple-instances/templates/tomcat-default.j2 +++ b/tomcat-multiple-instances/templates/tomcat-default.j2 @@ -50,6 +50,9 @@ JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,address={{ item.re {% endif %} # WARNING: This directory will be destroyed and recreated at every startup ! JVM_TMP={{ item.instance_path }}/tmp +{% if item.catalina_tmp_directory is defined %} +export CATALINA_TMPDIR={{ item.catalina_tmp_directory }} +{% endif %} # Additional options not managed by the provisioning tools if [ -f /etc/default/tomcat-instance-{{ item.http_port }}.local ] ; then . /etc/default/tomcat-instance-{{ item.http_port }}.local diff --git a/tomcat/tasks/tomcat-pkgs.yml b/tomcat/tasks/tomcat-pkgs.yml index 184f8adc..e5487d96 100644 --- a/tomcat/tasks/tomcat-pkgs.yml +++ b/tomcat/tasks/tomcat-pkgs.yml @@ -9,6 +9,12 @@ notify: tomcat restart tags: tomcat +- name: Create the catalina temp directory, if different from the default + file: dest={{ catalina_tmp_directory }} state=directory owner={{ tomcat_user }} group={{ tomcat_user }} + when: catalina_tmp_directory is defined + notify: tomcat restart + tags: tomcat + - name: Configure tomcat defaults template: src=tomcat-default.j2 dest=/etc/default/tomcat{{ tomcat_version }} when: tomcat_install_default_conf diff --git a/tomcat/templates/tomcat-default.j2 b/tomcat/templates/tomcat-default.j2 index 02ad6977..8d8862f1 100644 --- a/tomcat/templates/tomcat-default.j2 +++ b/tomcat/templates/tomcat-default.j2 @@ -48,7 +48,9 @@ JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,address={{ tomcat_ # Location of the JVM temporary directory # WARNING: This directory will be destroyed and recreated at every startup ! JVM_TMP={{ tomcat_tmp_dir }} - +{% if catalina_tmp_directory is defined %} +export CATALINA_TMPDIR={{ catalina_tmp_directory }} +{% endif %} {% if tomcat_load_additional_default_conf %} if [ -f /etc/default/tomcat.local ] ; then . /etc/default/tomcat.local