infra/roles/pve/tasks/destroy_vm.yml

38 lines
957 B
YAML
Raw Normal View History

2018-10-02 09:12:23 +03:00
- set_fact: node_name="{{tmp_node}}"
- set_fact: vm_name="{{node_name}}.{{stack.name}}"
2019-11-20 16:09:23 +03:00
- set_fact:
kvm_timeout: 500
2018-10-02 09:12:23 +03:00
- name: checking that vm exists
proxmox_kvm:
node: pve
2018-10-02 09:12:23 +03:00
api_user: "{{env.pve.username}}"
api_password: "{{env.pve.password}}"
api_host: "{{env.pve.api_url}}"
name: "{{vm_name}}"
state: current
ignore_errors: true
register: vm_exists
- block:
- name: stopping vm
proxmox_kvm:
node: pve
2018-10-02 09:12:23 +03:00
api_user: "{{env.pve.username}}"
api_password: "{{env.pve.password}}"
api_host: "{{env.pve.api_url}}"
name: "{{vm_name}}"
state: stopped
2019-05-25 14:05:52 +03:00
force: yes
2019-11-20 16:09:23 +03:00
timeout: "{{ kvm_timeout }}"
2018-10-02 09:12:23 +03:00
- name: destroying vm
proxmox_kvm:
node: pve
2018-10-02 09:12:23 +03:00
api_user: "{{env.pve.username}}"
api_password: "{{env.pve.password}}"
api_host: "{{env.pve.api_url}}"
name: "{{vm_name}}"
state: absent
2019-11-20 16:09:23 +03:00
timeout: "{{ kvm_timeout }}"
2018-10-02 09:12:23 +03:00
when: vm_exists is succeeded