---
-
  name: "Checking if Genesis is installed: {{ genesis_version }}"
  register: genesis_installed_check
  ansible.builtin.stat:
    path: "{{ completed_dir }}/genesis_installed_check"
    get_md5: false

-
  name: "Creating installation directories for Genesis"
  when: not genesis_installed_check.stat.exists
  ansible.builtin.file:
    mode: '0755'
    path: "{{ item }}"
    state: directory
    owner: "{{ domino_user }}"
    group: "{{ domino_group }}"
  with_items:
    - "{{ domino_home_dir }}/JavaAddin/Genesis"
    - "{{ domino_home_dir }}/JavaAddin/Genesis/json"

-
  name: "Stopping Domino for Changes to take effect"
  become: true
  when: not genesis_installed_check.stat.exists
  ansible.builtin.service:
    name: domino
    state: stopped
    enabled: true
  register: domino_service_stopped
  until: domino_service_stopped.state == "stopped"
  retries: 3
  delay: 5

-
  name: Pause for 15 seconds to let Domino fully shutdown
  when: not genesis_installed_check.stat.exists
  ansible.builtin.pause:
    seconds: 15

-
  name: "Placing Genesis template Configuration file"
  when: not genesis_installed_check.stat.exists
  become: true
  ansible.builtin.copy:
    mode: '0755'
    dest: "{{ domino_home_dir }}/JavaAddin/Genesis/{{ genesis_jar }}"
    owner: "{{ domino_user }}"
    group: "{{ domino_group }}"
    src: "{{ genesis_jar }}"

-
  name: "Starting Domino for Changes to take effect"
  become: true
  when: not genesis_installed_check.stat.exists
  ansible.builtin.service:
    name: domino
    state: started
    enabled: true
  register: domino_genesis_service_start_details
  until: domino_genesis_service_start_details.state == "started"
  retries: 10
  delay: 10

-
  name: "Debug"
  when: ( genesis_debug or debug_all ) and not genesis_installed_check.stat.exists
  ansible.builtin.debug:
    var: domino_genesis_service_start_details

-
  name: "Marking Genesis as installed"
  when: not genesis_installed_check.stat.exists
  ansible.builtin.file:
    mode: '0644'
    path: "{{ item }}"
    state: touch
  with_items:
    - "{{ completed_dir }}/genesis_installed_check"
