- name: Container removal
block:
- name: Stop container
community.general.proxmox:
vmid: "{{ id }}"
state: stopped
force: yes
- name: Wait for container to be stopped
uri:
url: "https://{{ PROXMOX_HOST }}:8006/api2/json/nodes/{{ PROXMOX_NODE }}/lxc/{{ id }}/status/current"
method: GET
headers: "{{ proxmox_auth }}"
delay: "{{ check_delay }}"
retries: "{{ check_retries }}"
register: container_status
until: container_status.json.data.status == "stopped"
ignore_errors: yes
- name: Remove container
community.general.proxmox:
vmid: "{{ id }}"
state: absent
register: removal
- name: Wait for container to be removed
uri:
url: "https://{{ PROXMOX_HOST }}:8006/api2/json/nodes/{{ PROXMOX_NODE }}/lxc/{{ id }}/status/current"
method: GET
headers: "{{ proxmox_auth }}"
delay: "{{ check_delay }}"
retries: "{{ check_retries }}"
register: container_status
until:
- container_status.status == 500
- "'does not exist' in container_status.json.message"
ignore_errors: yes
no_log: true