2015-05-28 11:32:57 +02:00
|
|
|
---
|
|
|
|
#
|
|
|
|
# Note: the library role 'tomcat' is a dependency
|
|
|
|
#
|
|
|
|
- name: disable the tomcat main instance
|
2016-03-02 15:19:25 +01:00
|
|
|
service: name='tomcat{{ tomcat_version }}' state=stopped enabled=no
|
2015-05-28 11:32:57 +02:00
|
|
|
when: not tomcat_service_enabled
|
2016-03-01 14:13:18 +01:00
|
|
|
tags: [ 'tomcat', 'tomcat_instances' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- name: Create a tomcat user for each instance if needed
|
|
|
|
user: name={{ item.user }} home={{ item.user_home }} createhome=false shell={{ item.user_shell }}
|
2016-03-02 16:44:43 +01:00
|
|
|
with_items: '{{ tomcat_m_instances }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
when:
|
|
|
|
- not tomcat_m_use_default_user
|
|
|
|
- item.user != "tomcat{{ tomcat_version }}"
|
|
|
|
- item.user_shell is defined
|
|
|
|
register: tomcat_first_install
|
2016-03-01 14:13:18 +01:00
|
|
|
tags: [ 'tomcat', 'tomcat_instances' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- name: Create a tomcat user if needed
|
|
|
|
user: name={{ tomcat_m_default_user }} home={{ tomcat_m_instances_base_path }} createhome=false shell={{ tomcat_m_default_user_shell }}
|
|
|
|
when:
|
|
|
|
- tomcat_m_use_default_user
|
|
|
|
- tomcat_m_default_user != "tomcat{{ tomcat_version }}"
|
|
|
|
register: tomcat_first_install
|
2016-03-01 14:13:18 +01:00
|
|
|
tags: [ 'tomcat', 'tomcat_instances' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- name: Create the instances directory trees
|
|
|
|
file: dest={{ item.0.instance_path }}/{{ item[1] }} owner={{ item.0.user }} group={{ item.0.user }} mode=0755 state=directory
|
|
|
|
with_nested:
|
2016-03-02 16:44:43 +01:00
|
|
|
- '{{ tomcat_m_instances }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
- [ 'common/classes', 'conf/Catalina/localhost', 'conf/policy.d', 'lib', 'server/classes', 'shared/classes', 'webapps' ]
|
|
|
|
register: tomcat_first_install
|
2016-03-01 14:13:18 +01:00
|
|
|
tags: [ 'tomcat', 'tomcat_instances' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- name: Create the instances log dirs
|
|
|
|
file: dest={{ tomcat_m_instances_logdir_base }}/{{ item.http_port }} owner={{ item.user }} group={{ item.user }} mode=0755 state=directory
|
2016-03-02 16:44:43 +01:00
|
|
|
with_items: '{{ tomcat_m_instances }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
register: tomcat_first_install
|
2016-03-01 14:13:18 +01:00
|
|
|
tags: [ 'tomcat', 'tomcat_instances' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- name: Create the instances work dirs
|
|
|
|
file: dest={{ tomcat_m_cache_base }}/{{ item.http_port }} owner={{ item.user }} group={{ item.user }} mode=0755 state=directory
|
2016-03-02 16:44:43 +01:00
|
|
|
with_items: '{{ tomcat_m_instances }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
register: tomcat_first_install
|
2016-03-01 14:13:18 +01:00
|
|
|
tags: [ 'tomcat', 'tomcat_instances' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- name: Create links to work dir inside the instances directory tree
|
|
|
|
file: src={{ tomcat_m_cache_base }}/{{ item.http_port }} dest={{ item.instance_path }}/work state=link
|
2016-03-02 16:44:43 +01:00
|
|
|
with_items: '{{ tomcat_m_instances }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
register: tomcat_first_install
|
2016-03-01 14:13:18 +01:00
|
|
|
tags: [ 'tomcat', 'tomcat_instances' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- name: Create links to log dir inside the instances directory tree
|
|
|
|
file: src={{ tomcat_m_instances_logdir_base }}/{{ item.http_port }} dest={{ item.instance_path }}/logs state=link
|
2016-03-02 16:44:43 +01:00
|
|
|
with_items: '{{ tomcat_m_instances }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
register: tomcat_first_install
|
2016-03-01 14:13:18 +01:00
|
|
|
tags: [ 'tomcat', 'tomcat_instances' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- 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:
|
2016-03-02 16:44:43 +01:00
|
|
|
- '{{ tomcat_m_instances }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
- [ 'catalina.properties', 'context.xml', 'tomcat-users.xml', 'web.xml' ]
|
|
|
|
register: restart_needed
|
|
|
|
notify:
|
|
|
|
- tomcat restart instances with changed configs
|
2016-03-01 14:13:18 +01:00
|
|
|
tags: [ 'tomcat', 'tomcat_instances' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- 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:
|
2016-03-02 16:44:43 +01:00
|
|
|
- '{{ tomcat_m_instances }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
- [ '01system.policy', '02debian.policy', '03catalina.policy', '04webapps.policy', '50local.policy' ]
|
|
|
|
register: restart_needed
|
|
|
|
notify:
|
|
|
|
- tomcat restart instances with changed configs
|
2016-03-01 14:13:18 +01:00
|
|
|
tags: [ 'tomcat', 'tomcat_instances' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- name: Install logging.properties if we do not use log4j for the tomcat logging
|
|
|
|
copy: src={{ item[1] }} dest={{ item.0.instance_path }}/conf/{{ item[1] }} owner={{ item.0.user }} group={{ item.0.user }} mode=0640
|
|
|
|
with_nested:
|
2016-03-02 16:44:43 +01:00
|
|
|
- '{{ tomcat_m_instances }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
- [ 'logging.properties' ]
|
|
|
|
when:
|
|
|
|
- tomcat_use_log4j is defined
|
|
|
|
- not tomcat_use_log4j
|
|
|
|
register: restart_needed
|
|
|
|
notify:
|
|
|
|
- tomcat restart instances with changed configs
|
2016-03-01 14:13:18 +01:00
|
|
|
tags: [ 'tomcat', 'tomcat_instances' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- 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
|
2016-03-02 16:44:43 +01:00
|
|
|
with_items: '{{ tomcat_m_instances }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
register: restart_needed
|
|
|
|
notify:
|
|
|
|
- tomcat restart instances with changed configs
|
2016-03-03 18:55:27 +01:00
|
|
|
tags: [ 'tomcat', 'tomcat_instances', 'tomcat_conf', 'tomcat_serverxml' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- name: Install the instances startup scripts
|
|
|
|
template: src=tomcat-instance.init.j2 dest=/etc/init.d/tomcat-instance-{{ item.http_port }} mode=0755 owner=root group=root
|
2016-03-02 16:44:43 +01:00
|
|
|
with_items: '{{ tomcat_m_instances }}'
|
2016-03-03 18:55:27 +01:00
|
|
|
tags: [ 'tomcat', 'tomcat_instances', 'tomcat_init' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- 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 }}
|
2016-03-02 16:44:43 +01:00
|
|
|
with_items: '{{ tomcat_m_instances }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
register: restart_needed
|
|
|
|
notify:
|
|
|
|
- tomcat restart instances with changed configs
|
2016-03-03 18:55:27 +01:00
|
|
|
tags: [ 'tomcat', 'tomcat_instances', 'tomcat_conf', 'tomcat_default' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- name: Install a logrotate entry for the access log file
|
|
|
|
template: src=tomcat.logrotate.j2 dest=/etc/logrotate.d/tomcat_instance-{{ item.http_port }} owner=root group=root mode=0644
|
2016-03-02 16:44:43 +01:00
|
|
|
with_items: '{{ tomcat_m_instances }}'
|
2015-09-15 17:37:56 +02:00
|
|
|
tags: [ 'tomcat', 'tomcat_instances', 'tomcat_conf' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- name: Install the jmx authorization file
|
|
|
|
template: src=jmxremote.passwd.j2 dest={{ item.instance_path }}/conf/jmxremote.passwd owner={{ item.user }} group={{ item.user }} mode=0600
|
2016-03-02 16:44:43 +01:00
|
|
|
with_items: '{{ tomcat_m_instances }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
when:
|
|
|
|
- item.jmx_enabled is defined
|
|
|
|
- item.jmx_auth_enabled is defined
|
|
|
|
- item.jmx_enabled
|
|
|
|
- item.jmx_auth_enabled
|
|
|
|
register: jmx_restart_needed
|
|
|
|
notify:
|
|
|
|
- tomcat restart instances with changed jmx config
|
2015-09-15 17:37:56 +02:00
|
|
|
tags: [ 'tomcat', 'tomcat_instances', 'tomcat_jmx' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
- name: Install the jmx role file
|
|
|
|
copy: src=jmxremote.access dest={{ item.instance_path }}/conf/jmxremote.access owner={{ item.user }} group={{ item.user }} mode=0644
|
2016-03-02 16:44:43 +01:00
|
|
|
with_items: '{{ tomcat_m_instances }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
when:
|
|
|
|
- item.jmx_enabled is defined
|
|
|
|
- item.jmx_auth_enabled is defined
|
|
|
|
- item.jmx_enabled
|
|
|
|
- item.jmx_auth_enabled
|
|
|
|
register: jmx restart_needed
|
|
|
|
notify:
|
|
|
|
- tomcat restart instances with changed jmx config
|
2015-09-15 17:37:56 +02:00
|
|
|
tags: [ 'tomcat', 'tomcat_instances', 'tomcat_jmx' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
2015-10-01 17:56:38 +02:00
|
|
|
- name: Start all the tomcat instances
|
2016-03-02 16:44:43 +01:00
|
|
|
service: name='tomcat-instance-{{ item.http_port }}' state=started sleep=20
|
|
|
|
with_items: '{{ tomcat_m_instances }}'
|
2015-10-01 17:56:38 +02:00
|
|
|
when:
|
|
|
|
- tomcat_first_install.changed
|
|
|
|
- tomcat_m_start_instances
|
|
|
|
tags: [ 'tomcat', 'tomcat_instances']
|
|
|
|
ignore_errors: True
|
2015-05-28 11:32:57 +02:00
|
|
|
|
2015-10-01 17:56:38 +02:00
|
|
|
- name: Enable all the tomcat instances
|
2016-03-02 16:44:43 +01:00
|
|
|
service: name='tomcat-instance-{{ item.http_port }}' enabled=yes
|
2016-03-02 17:05:01 +01:00
|
|
|
with_items: '{{ tomcat_m_instances }}'
|
2015-10-01 17:56:38 +02:00
|
|
|
when: tomcat_m_enable_instances
|
|
|
|
tags: [ 'tomcat', 'tomcat_instances']
|