---
- name: Check tomcat_instance_name
  ansible.builtin.debug:
    msg: "{{ tomcat_instance_name }}"

- name: Check use of gid
  ansible.builtin.command:
    cmd: id -ng "{{ tomcat_instance_port }}"
  register: check_port_gid
  changed_when: False
  failed_when:
    - check_port_gid | success
    - check_port_gid.stdout != "{{ tomcat_instance_name }}"

- name: Check use of uid
  ansible.builtin.command:
    cmd: id -nu "{{ tomcat_instance_port }}"
  register: check_port_uid
  changed_when: False
  failed_when:
    - check_port_uid | success
    - check_port_uid.stdout != "{{ tomcat_instance_name }}"

#- name: Check use of http port
#  ansible.builtin.command:
#    cmd: grep '<Connector port="{{ tomcat_instance_port }}" protocol="HTTP/1.1"' $(ls {{ tomcat_instance_root }}/*/conf/server.xml|grep -v {{ tomcat_instance_name }})
