---
## Install Guide here: https://help.hcltechsw.com/traveler/11.0.0/Silent_install_Linux.html
-
  name: "Creating installation directories for Traveler"
  ansible.builtin.file:
    mode: '0644'
    path: "{{ item }}"
    state: directory
  with_items:
    - "{{ installer_dir }}/traveler/archives"
    - "{{ installer_dir }}/traveler/Traveler"

-
  name: "Checking if Traveler is installed: {{ traveler_base_version }} "
  register: traveler_installed_check
  ansible.builtin.stat:
    path: "{{ completed_dir }}/traveler_install"
    get_md5: false

-
  name: "Checking if Traveler installer is at traveler/archives/{{ traveler_archive }}"
  register: traveler_installer_check
  ansible.builtin.stat:
    path: "{{ installer_dir }}/traveler/archives/{{ traveler_archive }}"
    get_md5: false

-
  name: "Downloading Traveler from {{ domino_installer_base_url }}"
  register: travelerresult
  until: "travelerresult is not failed"
  retries: 3
  ansible.builtin.get_url:
    mode: '0755'
    url: "{{ domino_installer_base_url }}/ND{{ domino_major_version }}/{{ traveler_archive }}"
    dest: "{{ installer_dir }}/traveler/archives/{{ traveler_archive }}"
    username: "{{ domino_installer_url_user }}"
    password: "{{ secrets.domino_installer_url_pass }}"
  when: not traveler_installer_check.stat.exists and not traveler_installed_check.stat.exists

-
  name: "Extracting Traveler from {{ traveler_archive }}"
  when: not traveler_installed_check.stat.exists
  ansible.builtin.unarchive:
    mode: "a+x"
    owner: "{{ domino_user }}"
    group: "{{ domino_group }}"
    src: "{{ installer_dir }}/traveler/archives/{{ traveler_archive }}"
    dest: "{{ installer_dir }}/traveler/Traveler"
    creates: "{{ installer_dir }}/traveler/Traveler/Traveler"
    remote_src: true

-
  name: "Stopping Domino for Traveler Installation"
  when: not traveler_installed_check.stat.exists
  become: true
  ansible.builtin.service:
    name: domino
    state: stopped
    enabled: true

-
  name: "Adding Traveler silent install response file"
  when: not traveler_installed_check.stat.exists
  ansible.builtin.template:
    dest: "{{ installer_dir }}/traveler/Traveler/installer.properties"
    mode: a+x
    src: "installer.properties.j2"

-
  name: "Installing Traveler"
  when: not traveler_installed_check.stat.exists
  ansible.builtin.shell: "{{ item }}"
  become: true
  args:
    executable: "/bin/bash"
    chdir: "{{ installer_dir }}/traveler/Traveler"
  with_items:
    - "./TravelerSetup -f ./installer.properties -i SILENT -l en && touch {{ completed_dir }}/traveler_install"

-
  name: "Starting Domino"
  when: not traveler_installed_check.stat.exists
  ansible.builtin.service:
    name: domino
    state: started
    enabled: true
