---
- name: 'apply setup to {{ host | default("infrastructure_realm") }}'
  hosts: '{{ host | default("infrastructure_realm") }}'
  serial: "{{ serial_number | default(5) }}"
  strategy: free
  vars:
    ansible_ssh_host: "{{ stage_server_domain }}"
  become: yes

  pre_tasks:
    - name: "Check if ansible version is at least {{ ansible_minimal_version }}"
      assert:
        that:
          - ansible_version.string is version(ansible_minimal_version, ">=")
        msg: "The ansible version has to be at least {{ ansible_minimal_version }}"
      tags:
        - always

    - name: "Import autodiscover pre-tasks"
      import_tasks: tasks/autodiscover_pre_tasks.yml
      become: false
      tags:
        - always

  roles:
    - role: infrastructure_realm
      when:
        - "'infrastructure_realm' in group_names"
