infra/roles/pve/tasks/destroy_vm.yml

39 lines
980 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: srv
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: srv
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 }}"
ignore_errors: yes
2018-10-02 09:12:23 +03:00
- name: destroying vm
proxmox_kvm:
node: srv
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