---
# k3scluster-decommission.yml — Decommission k3scluster blueprint instances
#
# Aether sends ffsdn_instances (a list of all instances in the deployment).
# This playbook loops over each instance and routes to K3s uninstall.

- name: K3scluster decommission — graceful cleanup via Incus API
  hosts: localhost
  gather_facts: false
  connection: local

  vars:
    incus_api: "https://192.168.102.140:8443"
    incus_cert: "/runner/project/incus-client.crt"
    incus_key: "/runner/project/incus-client.key"

  tasks:
    - name: Validate required variables
      ansible.builtin.assert:
        that:
          - ffsdn_instances is defined
          - ffsdn_instances | length > 0
        fail_msg: "ffsdn_instances must be provided by Aether"

    - name: Decommission each instance
      ansible.builtin.include_tasks: showcase/decommission/k3scluster-instance.yml
      loop: "{{ ffsdn_instances }}"
      loop_control:
        loop_var: instance
