diff --git a/roles/tomcat/molecule/centos7/molecule.yml b/roles/tomcat/molecule/centos7/molecule.yml new file mode 100644 index 00000000..424b09ca --- /dev/null +++ b/roles/tomcat/molecule/centos7/molecule.yml @@ -0,0 +1,53 @@ +--- +# test this scenario from the roles/tomcat directory with the command +# molecule --base-config ../../molecule_configs/centos7_base_config.yml test --scenario centos7 +platforms: + - name: tomcat9_server + hostname: molecule.tomcat9.local + image: ${MOLECULE_DOCKER_IMAGE:-geerlingguy/docker-centos7-ansible:latest} + required: true + command: "" + cgroupns_mode: host + privileged: true + pre_build_image: ${MOLECULE_PRE_BUILD_IMAGE:-true} + volumes: + - ./tomcat9-data:/storage/molecule/tomcat9 + keep_volumes: false + groups: + - all + - molecule + - centos7 + - tomcat9 + docker_networks: + - name: molecule + ipam_config: + - subnet: 192.168.56.0/24 + gateway: 192.168.56.1 + networks: + - name: molecule + ipv4_address: 192.168.56.2 + + - name: tomcat10_server + hostname: molecule.tomcat10.local + image: ${MOLECULE_DOCKER_IMAGE:-geerlingguy/docker-centos7-ansible:latest} + required: true + command: "" + cgroupns_mode: host + privileged: true + pre_build_image: ${MOLECULE_PRE_BUILD_IMAGE:-true} + volumes: + - ./tomcat10-data:/storage/molecule/tomcat10 + keep_volumes: false + groups: + - all + - molecule + - centos7 + - tomcat10 + docker_networks: + - name: molecule + ipam_config: + - subnet: 192.168.56.0/24 + gateway: 192.168.56.1 + networks: + - name: molecule + ipv4_address: 192.168.56.3 diff --git a/roles/tomcat/molecule/resources/converge.yml b/roles/tomcat/molecule/resources/converge.yml new file mode 100644 index 00000000..cbea2394 --- /dev/null +++ b/roles/tomcat/molecule/resources/converge.yml @@ -0,0 +1,7 @@ +--- +- name: Install Tomcat + hosts: all + become: true + gather_facts: true + roles: + - role: mirsg.infrastructure.tomcat diff --git a/roles/tomcat/molecule/resources/inventory/group_vars/all.yml b/roles/tomcat/molecule/resources/inventory/group_vars/all.yml new file mode 100644 index 00000000..ed97d539 --- /dev/null +++ b/roles/tomcat/molecule/resources/inventory/group_vars/all.yml @@ -0,0 +1 @@ +--- diff --git a/roles/tomcat/molecule/resources/inventory/group_vars/tomcat10.yml b/roles/tomcat/molecule/resources/inventory/group_vars/tomcat10.yml new file mode 100644 index 00000000..07ea875c --- /dev/null +++ b/roles/tomcat/molecule/resources/inventory/group_vars/tomcat10.yml @@ -0,0 +1,2 @@ +--- +tomcat_version: 10.1.19 diff --git a/roles/tomcat/molecule/resources/prepare.yml b/roles/tomcat/molecule/resources/prepare.yml new file mode 100644 index 00000000..9244a3ee --- /dev/null +++ b/roles/tomcat/molecule/resources/prepare.yml @@ -0,0 +1,12 @@ +--- +- name: Prepare - install sudo and Java + hosts: all + gather_facts: true + pre_tasks: + - name: Install sudo + ansible.builtin.package: + name: sudo + state: present + roles: + - role: mirsg.infrastructure.install_java + java_package: "{{ 'java-11-openjdk' if 'tomcat10' in group_names else 'java-1.8.0-openjdk'}}" diff --git a/roles/tomcat/molecule/resources/verify.yml b/roles/tomcat/molecule/resources/verify.yml new file mode 100644 index 00000000..e9304751 --- /dev/null +++ b/roles/tomcat/molecule/resources/verify.yml @@ -0,0 +1,31 @@ +--- +- name: Verify correct tomcat version is installed and running + hosts: all + tasks: + - name: Get status of all services + ansible.builtin.service_facts: + + - name: Check tomcat is enabled and running + ansible.builtin.assert: + that: + - ansible_facts.services["tomcat.service"].state == "running" + - ansible_facts.services["tomcat.service"].status == "enabled" + + - name: Check installed Tomcat version + ansible.builtin.shell: | + set -o pipefail + ./version.sh | grep -oP '(?<=Apache Tomcat/)([0-9]+\.?)+' + args: + chdir: "/usr/share/tomcat/bin" + register: tomcat_check_version + + - name: Print version + ansible.builtin.debug: + var: tomcat_check_version.stdout + + - name: Check Tomcat version is correct + ansible.builtin.assert: + that: + - tomcat_check_version.stdout.split(".")[0] is version(expected_version) + vars: + expected_version: "{{ '10' if 'tomcat10' in group_names else '9' }}" diff --git a/roles/tomcat/molecule/rocky9/molecule.yml b/roles/tomcat/molecule/rocky9/molecule.yml new file mode 100644 index 00000000..e05d40d7 --- /dev/null +++ b/roles/tomcat/molecule/rocky9/molecule.yml @@ -0,0 +1,50 @@ +--- +# test this scenario from the roles/tomcat directory with the command +# molecule --base-config ../../molecule_configs/rocky9_base_config.yml test --scenario rocky9 +platforms: + - name: tomcat9_server + hostname: molecule.tomcat9.local + image: rockylinux/rockylinux:9-ubi-init + required: true + command: "" + cgroupns_mode: host + privileged: true + pre_build_image: ${MOLECULE_PRE_BUILD_IMAGE:-true} + volumes: + - ./tomcat9-data:/storage/molecule/tomcat9 + - /sys/fs/cgroup:/sys/fs/cgroup:rw + keep_volumes: false + groups: + - all + - molecule + - rocky9 + - tomcat9 + docker_networks: + - name: molecule + ipam_config: + - subnet: 192.168.56.0/24 + gateway: 192.168.56.1 + networks: + - name: molecule + ipv4_address: 192.168.56.2 + + - name: tomcat10_server + hostname: molecule.tomcat10.local + image: rockylinux/rockylinux:9-ubi-init + required: true + command: "" + cgroupns_mode: host + privileged: true + pre_build_image: ${MOLECULE_PRE_BUILD_IMAGE:-true} + volumes: + - ./tomcat10-data:/storage/molecule/tomcat10 + - /sys/fs/cgroup:/sys/fs/cgroup:rw + keep_volumes: false + groups: + - all + - molecule + - rocky9 + - tomcat10 + networks: + - name: molecule + ipv4_address: 192.168.56.3