Use version_compare for the version comparisons.

This commit is contained in:
Andrea Dell'Amico 2024-07-22 11:22:58 +02:00
parent 37fe32e4a0
commit b9c9218418
Signed by: adellam
GPG Key ID: 147ABE6CEB9E20FF
4 changed files with 17 additions and 9 deletions

View File

@ -11,10 +11,10 @@
- import_tasks: tomcat-log4j-logging.yml
when:
- tomcat_use_log4j
- tomcat_version <= 7
- tomcat_version is version_compare('7', '<=')
tags: ['tomcat', 'tomcat_log4j']
- import_tasks: tomcat-logger-logging.yml
when: not tomcat_use_log4j or tomcat_version > 7
when: not tomcat_use_log4j or tomcat_version is version_compare('7', '>')
- import_tasks: access_log.yml
when: tomcat_access_log_enabled
- import_tasks: pgsql_jdbc.yml

View File

@ -3,7 +3,7 @@
set_fact:
tomcat_version: 7
when:
- ansible_distribution_major_version <= '16'
- ansible_distribution_major_version is version_compare('16.04', '<')
- tomcat_fixed_version is not defined
tags: [ 'tomcat', 'tomcat_ver', 'tomcat_conf', 'tomcat_javamelody' ]
@ -11,7 +11,15 @@
set_fact:
tomcat_version: 8
when:
- ansible_distribution_major_version == '18'
- ansible_distribution_major_version is version_compare('18.04', '==')
- tomcat_fixed_version is not defined
tags: [ 'tomcat', 'tomcat_ver', 'tomcat_conf', 'tomcat_javamelody' ]
- name: Set the tomcat version for Ubuntu bionic
set_fact:
tomcat_version: 10
when:
- ansible_distribution_major_version is version_compare('24.04', '==')
- tomcat_fixed_version is not defined
tags: [ 'tomcat', 'tomcat_ver', 'tomcat_conf', 'tomcat_javamelody' ]
@ -32,7 +40,7 @@
- name: Install additional packages needed by tomcat 8+
apt: pkg={{ tomcat8_additional_pkgs }} state={{ tomcat_pkg_state }} cache_valid_time=1800
when: tomcat_version >= 8
when: tomcat_version is version_compare('8', '>=')
tags: [ 'tomcat', 'tomcat_javamelody', 'tomcat_conf', 'tomcat_javamelody' ]
- name: Create the tomcat tmp directory
@ -81,5 +89,5 @@
file: src=/usr/share/java/{{ item }} dest={{ tomcat_catalina_home_dir }}/bin/{{ item }} state=link owner=root group=root mode=0644
with_items:
- commons-daemon.jar
when: tomcat_version >= 8
when: tomcat_version is version_compare('8', '>=')
tags: [ 'tomcat', 'tomcat_conf' ]

View File

@ -19,14 +19,14 @@ JAVA_HOME={{ jdk_java_home }}
{% endif %}
JAVA_OPTS="-server -Djava.awt.headless=true -Dfile.encoding={{ tomcat_file_encoding }}"
{% if jdk_default <= 7 %}
{% if jdk_default is version_compare('7', '<=') %}
{% if tomcat_permgen_defined %}
{% if tomcat_permgen_size is defined %}
JAVA_OPTS="-XX:MaxPermSize={{ tomcat_permgen_size }} $JAVA_OPTS"
{% endif %}
{% endif %}
{% endif %}
{% if jdk_default >= 8 %}
{% if jdk_default is version_compare('8', '>=') %}
JAVA_OPTS="{{ tomcat_additional_java_8_opts }} $JAVA_OPTS"
{% endif %}
{% if tomcat_java_opts is defined %}

View File

@ -32,7 +32,7 @@
<!--
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
-->
{% if tomcat_version <= 7 %}
{% if tomcat_version is version_compare (7, '<=') %}
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener" />
{% endif %}