---
  - name: Set up Apache2 virtualhost
    template:
      src: "files/gs3-apache.conf.j2"
      dest: "/etc/apache2/sites-available/{{ apache2_revproxy_config.config_root_name }}.conf"

  - name: Adjusting Greenstone3 installations index.html to work in Apache2 DocumentRoot
    ansible.builtin.replace:
      path:   "{{ gsdl3srchome }}/web/index.html"
      regexp:  'href="(?!http://|/)'
      replace: 'href="/{{ gsdl3servlet_external.context }}/'

  - name: Enable new site
    shell: /usr/sbin/a2ensite {{ apache2_revproxy_config.config_root_name }}.conf
    notify: Reload Apache

#  - name: "UFW - Allow HTTP on port {{ gsdl3servlet_external.port | default('80',true) }}"
#    ufw:
#      rule: allow
#      port: "{{ gsdl3servlet_external.port | default('80',true) }}"
#      proto: tcp
#      when gsdl3servlet_external.protocol == "http"

#  - name: "UFW - Allow HTTP on port {{ gsdl3servlet_external.port | default('80',true) }}"
#    ufw:
#      rule: allow
#      port: "{{ gsdl3servlet_external.port | default('80',true) }}"
#      proto: tcp
#      when gsdl3servlet_external.port == "http"