---
-
  name: "Block to Allow Loading of Variables without running task"
  when: run_tasks
  block:
    -
      name: "Creating installation directories for Verse"
      ansible.builtin.file:
        mode: '0644'
        path: "{{ item }}"
        state: directory
      with_items:
        - "{{ installer_dir }}/verse/archives"
        - "{{ installer_dir }}/verse/Verse"
    
    -
      name: "Checking if Verse is installed: {{ verse_base_version }}"
      register: verse_installed_check
      ansible.builtin.stat:
        path: "{{ completed_dir }}/verse_install"
        get_md5: false
    
    -
      name: "Checking if Verse installer is at verse/archives/{{ verse_archive }}"
      register: verse_installer_check
      ansible.builtin.stat:
        path: "{{ installer_dir }}/verse/archives/{{ verse_archive }}"
        get_md5: false
    
    -
      name: "Downloading Verse from {{ domino_installer_base_url }}"
      register: verseresult
      until: "verseresult is not failed"
      retries: 3
      ansible.builtin.get_url:
        mode: '0755'
        validate_certs: false
        url: "{{ domino_installer_base_url }}/{{ installer_url_app_path }}/{{ verse_archive }}"
        dest: "{{ installer_dir }}/verse/archives/{{ verse_archive }}"
        username: "{{ domino_installer_url_user }}"
        password: "{{ secrets.domino_installer_url_pass }}"
      when: not verse_installer_check.stat.exists and not verse_installed_check.stat.exists
    
    -
      name: "Extracting Verse from {{ verse_archive }}"
      when: not verse_installed_check.stat.exists
      ansible.builtin.unarchive:
        mode: "a+x"
        owner: "{{ domino_user }}"
        group: "{{ domino_group }}"
        src: "{{ installer_dir }}/verse/archives/{{ verse_archive }}"
        dest: "{{ installer_dir }}/verse/Verse"
        creates: "{{ installer_dir }}/verse/Verse/HCL_Verse.zip"
        remote_src: true
    
    -
      name: "Stopping Domino for Verse Installation"
      when: not verse_installed_check.stat.exists
      become: true
      ansible.builtin.service:
        name: domino
        state: stopped
        enabled: true
    
    -
      name: "Extracting Verse Files from HCL_Verse.zip: {{ verse_base_version }}"
      when: not verse_installed_check.stat.exists
      ansible.builtin.unarchive:
        mode: "a+x"
        owner: "{{ domino_user }}"
        group: "{{ domino_group }}"
        src: "{{ installer_dir }}/verse/Verse/HCL_Verse.zip"
        dest: "{{ domino_home_dir }}/domino/workspace/applications"
        remote_src: true
    
    -
      name: "Starting Domino"
      when: not verse_installed_check.stat.exists
      ansible.builtin.service:
        name: domino
        state: started
        enabled: true
    
    -
      name: "Setting Verse as installed"
      when: not verse_installed_check.stat.exists
      ansible.builtin.file:
        mode: '0644'
        path: "{{ item }}"
        state: touch
      with_items:
        - "{{ completed_dir }}/verse_install"
