infra/roles/pve/tasks/destroy_vm.yml

35 lines
873 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}}"
- 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
2018-11-01 23:52:33 +03:00
timeout: 120
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
when: vm_exists is succeeded