---
# Simple CDN Deployment

- name: Deploy Simple CDN for Germany
  hosts: cdn_nodes
  become: yes
  serial: 1  # Ein Node nach dem anderen
  
  pre_tasks:
    - name: Update system packages
      apt:
        update_cache: yes
        upgrade: dist
        
    - name: Install required packages
      apt:
        name:
          - nginx
          - certbot
          - python3-certbot-nginx
          - curl
          - htop
          - bc
        state: present
        
  roles:
    - nginx-cdn-config
    - ssl-certificates
    - simple-monitoring
    
  post_tasks:
    - name: Verify CDN health
      uri:
        url: "https://{{ inventory_hostname }}/health"
        method: GET
        status_code: 200
        validate_certs: yes
      retries: 5
      delay: 10
      
    - name: Display deployment success
      debug:
        msg: "✅ CDN Node {{ inventory_hostname }} ({{ city }}) successfully deployed!"
