Fix the restart sequence.

This commit is contained in:
Andrea Dell'Amico 2022-07-18 18:41:12 +02:00
parent 2289cbc9aa
commit c13b556fc8
Signed by: adellam
GPG Key ID: 147ABE6CEB9E20FF
3 changed files with 25 additions and 51 deletions

View File

@ -40,7 +40,8 @@ tomcat_m_shutdown_port: -1
tomcat_m_shutdown_pwd: "{{ lookup('password', '/tmp/passwordfile chars=ascii_letters,digits,hexdigits,punctuation') }}"
tomcat_m_max_threads: 200
tomcat_m_min_heap_size: 2048m
tomcat_m_heap_size: '{{ tomcat_m_min_heap_size }}'
catalina_tomcat_m_heap_size: '{{ tomcat_m_min_heap_size }}'
tomcat_m_heap_size: '{{ catalina_tomcat_m_heap_size }}'
tomcat_m_permgen_size: 512m
tomcat_m_file_encoding: 'UTF-8'
tomcat_m_restart_timeout: 300

View File

@ -1,28 +1,13 @@
---
- name: tomcat restart instances with changed configs
service: name='tomcat-instance-{{ item.item.http_port }}' state=restarted sleep=20
with_items: '{{ restart_needed.results }}'
when: item is changed
ignore_errors: True
- name: tomcat restart instances with changed jmx config
service: name='tomcat-instance-{{ item.item.http_port }}' state=restarted sleep=20
with_items: '{{ jmx_restart_needed.results }}'
when: item is changed
ignore_errors: True
- name: tomcat instances restart
service: name='tomcat-instance-{{ item.http_port }}' state=restarted sleep=20
with_items: '{{ tomcat_m_instances }}'
ignore_errors: True
- name: enable tomcat instances
service: name='tomcat-instance-{{ item.http_port }}' state=started enabled=yes sleep=20
with_items: '{{ tomcat_m_instances }}'
ignore_errors: True
- name: tomcat multiple-instances restart
service:
name: 'tomcat-instance-{{ item.http_port }}'
state: restarted
sleep: 20
loop: '{{ tomcat_m_instances }}'
ignore_errors: true
- name: disable tomcat instances
service: name='tomcat-instance-{{ item.http_port }}' state=stopped enabled=no sleep=20
with_items: '{{ tomcat_m_instances }}'
ignore_errors: True
loop: '{{ tomcat_m_instances }}'
ignore_errors: true

View File

@ -6,7 +6,7 @@
service: name='tomcat{{ tomcat_version }}' state=stopped enabled=no
when: not tomcat_service_enabled
tags: [ 'tomcat', 'tomcat_instances' ]
- name: Create a tomcat user for each instance if needed
user: name={{ item.user }} home={{ item.user_home }} createhome=false shell={{ item.user_shell | default('/bin/false') }}
with_items: '{{ tomcat_m_instances }}'
@ -82,8 +82,7 @@
with_nested:
- '{{ tomcat_m_instances }}'
- [ 'context.xml' ]
register: restart_needed
notify: tomcat restart instances with changed configs
notify: tomcat multiple-instances restart
tags: [ 'tomcat', 'tomcat_instances' ]
- name: Install catalina.properties
@ -91,8 +90,7 @@
with_nested:
- '{{ tomcat_m_instances }}'
- [ 'catalina.properties' ]
register: restart_needed
notify: tomcat restart instances with changed configs
notify: tomcat multiple-instances restart
tags: [ 'tomcat', 'tomcat_instances', 'tomcat_catalina_properties' ]
- name: Populate the instances conf/policy.d directory
@ -100,8 +98,7 @@
with_nested:
- '{{ tomcat_m_instances }}'
- [ '01system.policy', '02debian.policy', '03catalina.policy', '04webapps.policy', '50local.policy' ]
register: restart_needed
notify: tomcat restart instances with changed configs
notify: tomcat multiple-instances restart
tags: [ 'tomcat', 'tomcat_instances' ]
- name: Install logging.properties if we do not use log4j for the tomcat logging
@ -112,22 +109,19 @@
when:
- tomcat_use_log4j is defined
- not tomcat_use_log4j | bool
register: restart_needed
notify: tomcat restart instances with changed configs
notify: tomcat multiple-instances restart
tags: [ 'tomcat', 'tomcat_instances' ]
- name: Install the server.xml conf file
template: src=tomcat-server.xml.j2 dest={{ item.instance_path }}/conf/server.xml owner={{ item.user }} group={{ item.user }} mode=0640
with_items: '{{ tomcat_m_instances }}'
register: restart_needed
notify: tomcat restart instances with changed configs
notify: tomcat multiple-instances restart
tags: [ 'tomcat', 'tomcat_instances', 'tomcat_conf', 'tomcat_serverxml' ]
- name: Install the web.xml file
template: src=tomcat-web.xml.j2 dest={{ item.instance_path }}/conf/web.xml owner={{ item.user }} group={{ item.user }} mode=0640
with_items: '{{ tomcat_m_instances }}'
register: restart_needed
notify: tomcat restart instances with changed configs
notify: tomcat multiple-instances restart
tags: [ 'tomcat', 'tomcat_instances', 'tomcat_conf', 'tomcat_serverxml' ]
- name: Install the tomcat-admin package if the host-manager or manager apps are required
@ -138,24 +132,21 @@
- name: Install the catalina configuration for the tomcat manager
template: src=tomcat-manager.xml.j2 dest={{ item.instance_path }}/conf/Catalina/localhost/manager.xml owner={{ item.user }} group={{ item.user }} mode=0640
with_items: '{{ tomcat_m_instances }}'
register: restart_needed
when: tomcat_m_manager_install | bool
notify: tomcat restart instances with changed configs
notify: tomcat multiple-instances restart
tags: [ 'tomcat', 'tomcat_instances', 'tomcat_conf', 'tomcat_manager' ]
- name: Install the catalina configuration for the tomcat host manager
template: src=tomcat-host-manager.xml.j2 dest={{ item.instance_path }}/conf/Catalina/localhost/host-manager.xml owner={{ item.user }} group={{ item.user }} mode=0640
with_items: '{{ tomcat_m_instances }}'
register: restart_needed
when: tomcat_m_host_manager_install | bool
notify: tomcat restart instances with changed configs
notify: tomcat multiple-instances restart
tags: [ 'tomcat', 'tomcat_instances', 'tomcat_conf', 'tomcat_host_manager' ]
- name: Install the catalina configuration for the tomcat manager
template: src=tomcat-users.xml.j2 dest={{ item.instance_path }}/conf/tomcat-users.xml owner={{ item.user }} group={{ item.user }} mode=0640
with_items: '{{ tomcat_m_instances }}'
register: restart_needed
notify: tomcat restart instances with changed configs
notify: tomcat multiple-instances restart
tags: [ 'tomcat', 'tomcat_instances', 'tomcat_conf', 'tomcat_host_manager', 'tomcat_manager' ]
- name: Install the instances startup scripts
@ -167,7 +158,7 @@
- name: Install the tomcat instances default file
template: src=tomcat-default.j2 dest=/etc/default/tomcat-instance-{{ item.http_port }} mode=0640 owner=root group={{ item.user }}
with_items: '{{ tomcat_m_instances }}'
notify: tomcat instances restart
notify: tomcat multiple-instances restart
tags: [ 'tomcat', 'tomcat_instances', 'tomcat_conf', 'tomcat_default', 'jdk' ]
- name: Reload the systemd daemon if we are running on a systemd-backed server
@ -179,8 +170,7 @@
- name: Install a custom context.xml file
template: src=tomcat-context.xml.j2 dest={{ item.instance_path }}/conf/context.xml owner={{ item.user }} group={{ item.user }} mode=0640
with_items: '{{ tomcat_m_instances }}'
register: restart_needed
notify: tomcat restart instances with changed configs
notify: tomcat multiple-instances restart
when: tomcat_m_jndi_pool | bool
tags: [ 'tomcat', 'tomcat_instances', 'tomcat_conf', 'tomcat_contextxml', 'jdk' ]
@ -197,8 +187,7 @@
- item.jmx_auth_enabled is defined
- item.jmx_enabled | bool
- item.jmx_auth_enabled | bool
register: jmx_restart_needed
notify: tomcat restart instances with changed jmx config
notify: tomcat multiple-instances restart
tags: [ 'tomcat', 'tomcat_instances', 'tomcat_jmx' ]
- name: Install the jmx role file
@ -209,8 +198,7 @@
- item.jmx_auth_enabled is defined
- item.jmx_enabled | bool
- item.jmx_auth_enabled | bool
register: jmx_restart_needed
notify: tomcat restart instances with changed jmx config
notify: tomcat multiple-instances restart
tags: [ 'tomcat', 'tomcat_instances', 'tomcat_jmx' ]
- name: Start all the tomcat instances