---
- name: Setup the system
  hosts: all
  gather_facts: true
  pre_tasks:
    - name: Sanity checks
      tags: always
      block:
        - name: Check user ID
          fail:
            msg: This playbook should be run as 'root'
          when: ansible_real_user_id != 0
        - name: Import list of accepted values for custom variables
          include_vars:
            name: accepted_values
            file: ../requirements/assert.yml
        - name: Check defined values of top-level variables
          fail:
            msg: 'Variable `{{ item }}` needs to be 1 of {{ accepted_values[item] }}'
          when: not vars[item] in accepted_values[item]
          loop: '{{ accepted_values | flatten }}'
    - name: Get ZFS pool facts
      community.general.zpool_facts:
      tags: always
  roles:
    - role: system
