# Load distro-specific variables
- include_vars: "{{ ansible_distribution | lower }}.yml"
  tags: always
  ignore_errors: True

- block:
  - debug:
      msg: Debug
  # basics
  - import_tasks: system_setup/hostname.yml
  - import_tasks: system_setup/hosts.yml
  - import_tasks: system_setup/clock.yml
  - import_tasks: system_setup/locale.yml
  - import_tasks: system_setup/wireguard.yml
    when:
      - wireguard is defined
      - wireguard == true
      - ansible_default_ipv4.address | ansible.utils.ipaddr('public')
    ignore_errors: True
  - import_tasks: ansible_setup.yml
  - import_tasks: system_setup/git.yml
  # install software
  # - import_tasks: software/repositories.yml
  - import_tasks: software/packages_zsh.yml
  # - import_tasks: software/packages_development.yml
  - import_tasks: software/packages_cleanup.yml
  # - import_tasks: software/packages_pip.yml
  - import_tasks: software/packages_utilities.yml

  # Perform remaining tasks:
  - import_tasks: users.yml
  - import_tasks: system_setup/cron.yml
  # - import_tasks: system_setup/logging.yml
  # - import_tasks: system_setup/memory.yml
  # - import_tasks: system_setup/microcode.yml
  - import_tasks: system_setup/openssh.yml
  - import_tasks: system_setup/scripts.yml
  - import_tasks: system_setup/disable_standby.yml
    when: is_proxmox is defined and is_proxmox == true
  - import_tasks: software/wazuh-agent.yml
    when: ansible_distribution in ["Debian", "Pop!_OS", "Ubuntu", "Linux Mint", "Archlinux"]
  - import_tasks: system_setup/disable_standby.yml
    when: is_proxmox is defined and is_proxmox == true
  - import_tasks: system_setup/import_stepca.yml


  # Set up the ansible environment
  # - import_tasks: ansible_setup.yml

  rescue:
    - set_fact: task_failed=true
