---
- name: Group hosts by platform
  hosts: all
  tags:
    - always
  pre_tasks:
    - include_tasks: tasks/meta/runtime-group-determination.yaml


- name: Bootstrap remote ansible environment
  hosts: linux
  gather_facts: false
  tags:
    - always
  tasks:
    - include_tasks: tasks/meta/bootstrap-remote-env.yaml


- name: Configure common settings
  hosts: linux
  gather_facts: false
  tasks:
    - name: Set hostname
      become: true
      ansible.builtin.hostname:
        name: "{{ skylab_hostname | default(inventory_hostname) }}"
        use: systemd

    - name: Disable case-sensitive tab-completion
      become: true
      ansible.builtin.lineinfile:
        line: set completion-ignore-case On
        path: /etc/inputrc
        state: present
        create: true

    - name: Install EPEL repository config
      when: ansible_distribution == "Rocky"
      become: true
      ansible.builtin.yum_repository:
        name: epel
        description: Extra Packages for Enterprise Linux
        baseurl: https://download.fedoraproject.org/pub/epel/$releasever{{ '/Everything' if ansible_distribution_major_version == '8' else '' }}/$basearch/

    - name: Install EPEL GPG key
      when: ansible_distribution == "Rocky"
      become: true
      ansible.builtin.rpm_key:
        state: present
        key: https://archive.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }}


- import_playbook: skylab.core.update


- import_playbook: skylab.core.configure
