--- - name: Set the tomcat version for ubuntu Trusy set_fact: tomcat_version: 7 when: - ansible_distribution_major_version <= '16' - 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: 8 when: - ansible_distribution_major_version == '18' - tomcat_fixed_version is not defined tags: [ 'tomcat', 'tomcat_ver', 'tomcat_conf', 'tomcat_javamelody' ] - name: Impose a tomcat version set_fact: tomcat_version: '{{ tomcat_fixed_version }}' when: tomcat_fixed_version is defined tags: [ 'tomcat', 'tomcat_ver', 'tomcat_conf', 'tomcat_javamelody' ] - name: Print the Tomcat version debug: msg: "The Tomcat version we are going to install is {{ tomcat_version }}" tags: [ 'tomcat', 'tomcat_ver', 'tomcat_conf', 'tomcat_javamelody' ] - name: Install the tomcat packages apt: pkg={{ tomcat_pkgs }} state={{ tomcat_pkg_state }} cache_valid_time=1800 tags: tomcat - 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 tags: [ 'tomcat', 'tomcat_javamelody', 'tomcat_conf', 'tomcat_javamelody' ] - name: Create the tomcat tmp directory file: dest={{ tomcat_tmp_dir }} state=directory owner={{ tomcat_user }} group={{ tomcat_user }} 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 | bool notify: tomcat restart tags: [ 'tomcat', 'tomcat_default' ] - name: Configure tomcat server.xml template: src=tomcat-server.xml.j2 dest={{ tomcat_conf_dir }}/server.xml when: tomcat_install_server_xml | bool notify: tomcat restart tags: [ 'tomcat', 'tomcat_serverxml' ] - name: Configure tomcat web.xml template: src=tomcat-web.xml.j2 dest={{ tomcat_conf_dir }}/web.xml notify: tomcat restart tags: [ 'tomcat', 'tomcat_serverxml' ] - name: Install a slightly modified catalina.properties copy: src=catalina.properties dest={{ tomcat_conf_dir }}/catalina.properties owner=root group={{ tomcat_user }} mode=0644 when: tomcat_install_default_conf | bool notify: tomcat restart tags: [ 'tomcat', 'tomcat_catalinaprops' ] - name: Create some directories that the package do not creates itself file: dest={{ tomcat_catalina_home_dir }}/{{ item }} state=directory owner={{ tomcat_user }} group={{ tomcat_user }} mode=0755 with_items: - common/classes - server/classes - shared/classes tags: tomcat - name: On tomcat8, create a link to commons-daemon.jar to avoid exceptions at startup 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 tags: [ 'tomcat', 'tomcat_conf' ]