---
- name: Core Infrastructure - Layer 2
  hosts: vps
  become: true
  roles:
    - role: swap
      tags: [infrastructure, system, swap]
    - role: apt
      tags: [infrastructure, packages, apt]
    - role: bash
      vars:
        bash_user_name: "{{ admin_user_name }}"
        bash_user_home: "/home/{{ admin_user_name }}"
      tags: [infrastructure, shell, bash]
    - role: caddy
      tags: [infrastructure, web, proxy, caddy]
    - role: blocky
      tags: [infrastructure, network, dns, blocky]
    - role: headscale
      tags: [infrastructure, network, vpn, headscale]
      when: headscale_subdomain is defined and headscale_subdomain | length > 0
    - role: tailscale
      tags: [infrastructure, network, vpn, tailscale]

  handlers:
    - name: Reload systemd
      ansible.builtin.systemd_service:
        daemon_reload: true
    - name: Update apt cache
      ansible.builtin.apt:
        update_cache: true
