---
- name: Install WireGuard Server
  hosts: vpn
  become: true
  gather_facts: true
  
  pre_tasks:
    - name: Update package cache
      apt:
        update_cache: true
        cache_valid_time: 3600
  
  roles:
    - role: wireguard
      tags: [install, configure]

  post_tasks:
    - name: Show WireGuard status
      command: wg show
      register: wg_status
      changed_when: false
      ignore_errors: true
    
    - name: Display WireGuard status
      debug:
        var: wg_status.stdout_lines
      when: wg_status.stdout is defined
