---
-
  name: "Managing progress for {{ ansible_role_name }}"
  when: count_progress | default(false)
  run_once: true
  block:
    - name: "Incrementing global progress step counter for {{ ansible_role_name }}"
      ansible.builtin.set_fact:
        global_current_progress_step: "{{ global_current_progress_step | default(0) | int + 1 }}"

    - name: "Including progress reporting task for {{ ansible_role_name }}"
      ansible.builtin.include_role:
        name: startcloud.startcloud_roles.progress
      vars:
        _progress_role_is_setup_run: false
        current_progress_step: "{{ global_current_progress_step | default(0) }}"
        progress_description: "{{ progress_role_description | default('Processing ' + ansible_role_name) }}"

-
  name: "Block to Allow Loading of Variables without running task"
  when: run_tasks
  block:
    -
      name: "Including OS-specific vars"
      ansible.builtin.include_vars: "{{ ansible_os_family | lower }}.yml"

    -
      name: "Include overrides specific to Fedora"
      ansible.builtin.include_vars: Fedora.yml
      when:
        - ansible_os_family == 'RedHat'
        - ansible_distribution == "Fedora"

    -
      name: "Including OS-specific tasks"
      ansible.builtin.include_tasks: "{{ ansible_os_family | lower }}.yml"

    -
      name: "Ensuring directories to export exist"
      ansible.builtin.file: # noqa 208
        path: "{{ item.strip().split()[0] }}"
        state: directory
      with_items: "{{ nfs_exports }}"

    -
      name: "Copying exports file"
      ansible.builtin.template:
        src: exports.j2
        dest: /etc/exports
        owner: root
        group: root
        mode: "0644"
      notify: Reload nfs

    -
      name: "Ensuring nfs is running"
      ansible.builtin.service:
        name: "{{ nfs_server_daemon }}"
        state: "started"
        enabled: "yes"
      when: nfs_exports | length | bool
