1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/integration/targets/proxmox/tasks/main.yml

580 lines
18 KiB
YAML
Raw Normal View History

####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
# Copyright (c) 2020, Tristan Le Guern <tleguern at bouledef.eu>
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: List domains
proxmox_domain_info:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
register: results
- assert:
that:
- results is not changed
- results.proxmox_domains is defined
- name: Retrieve info about pve
proxmox_domain_info:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
domain: pve
register: results
- assert:
that:
- results is not changed
- results.proxmox_domains is defined
- results.proxmox_domains|length == 1
- results.proxmox_domains[0].type == 'pve'
- name: List groups
proxmox_group_info:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
register: results
Add proxmox_nic module (#2449) * Add proxmox_nic module Add proxmox_nic module to manage NIC's on Qemu(KVM) VM's in a Proxmox VE cluster. Update proxmox integration tests and add tests for proxmox_nic module. This partially solves https://github.com/ansible-collections/community.general/issues/1964#issuecomment-790499397 and allows for adding/updating/deleting network interface cards after creating/cloning a VM. The proxmox_nic module will keep MAC-addresses the same when updating a NIC. It only changes when explicitly setting a MAC-address. * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * Add check_mode and implement review comments - check_mode added - some documentation updates - when MTU is set, check if the model is virtio, else fail - trunks can now be provided as list of ints instead of vlanid[;vlanid...] * Make returns on update_nic and delete_nic more readable Co-authored-by: Felix Fontein <felix@fontein.de> * Increase readability on update_nic and delete_nic * Implement check in get_vmid - get_vmid will now fail when multiple vmid's are returned as proxmox doesn't guarantee uniqueness - remove an unused import - fix a typo in an error message * Add some error checking to get_vmid - get_vmid will now return the error message when proxmoxer fails - get_vmid will return the vmid directly instead of a list of one - Some minor documentation updates * Warn instead of fail when setting mtu on unsupported nic - When setting the MTU on an unsupported NIC model (virtio is the only supported model) this module will now print a warning instead of failing. - Some minor documentation updates. * Take advantage of proxmox_auth_argument_spec Make use of proxmox_auth_argument_spec from plugins/module_utils/proxmox.py This provides some extra environment fallbacks. * Add blank line to conform with pep8 Co-authored-by: Felix Fontein <felix@fontein.de>
2021-05-13 21:48:49 +02:00
- assert:
that:
- results is not changed
- results.proxmox_groups is defined
- name: List users
proxmox_user_info:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
register: results
- assert:
that:
- results is not changed
- results.proxmox_users is defined
- name: Retrieve info about api_user using name and domain
proxmox_user_info:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
user: "{{ user }}"
domain: "{{ domain }}"
register: results_user_domain
- assert:
that:
- results_user_domain is not changed
- results_user_domain.proxmox_users is defined
- results_user_domain.proxmox_users|length == 1
- results_user_domain.proxmox_users[0].domain == "{{ domain }}"
- results_user_domain.proxmox_users[0].user == "{{ user }}"
- results_user_domain.proxmox_users[0].userid == "{{ user }}@{{ domain }}"
- name: Retrieve info about api_user using userid
proxmox_user_info:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
userid: "{{ user }}@{{ domain }}"
register: results_userid
- assert:
that:
- results_userid is not changed
- results_userid.proxmox_users is defined
- results_userid.proxmox_users|length == 1
- results_userid.proxmox_users[0].domain == "{{ domain }}"
- results_userid.proxmox_users[0].user == "{{ user }}"
- results_userid.proxmox_users[0].userid == "{{ user }}@{{ domain }}"
- name: Retrieve info about storage
proxmox_storage_info:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
storage: "{{ storage }}"
register: results_storage
- assert:
that:
- results_storage is not changed
- results_storage.proxmox_storages is defined
- results_storage.proxmox_storages|length == 1
- results_storage.proxmox_storages[0].storage == "{{ storage }}"
- name: VM creation
tags: [ 'create' ]
block:
- name: Create test vm test-instance
proxmox_kvm:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
node: "{{ node }}"
storage: "{{ storage }}"
vmid: "{{ from_vmid }}"
name: test-instance
clone: 'yes'
state: present
timeout: 500
register: results_kvm
- set_fact:
vmid: "{{ results_kvm.msg.split(' ')[-7] }}"
- assert:
that:
- results_kvm is changed
- results_kvm.vmid == from_vmid
- results_kvm.msg == "VM test-instance with newid {{ vmid }} cloned from vm with vmid {{ from_vmid }}"
- pause:
seconds: 30
- name: VM start
tags: [ 'start' ]
block:
- name: Start test VM
proxmox_kvm:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
node: "{{ node }}"
vmid: "{{ vmid }}"
state: started
register: results_action_start
- assert:
that:
- results_action_start is changed
- results_action_start.status == 'stopped'
- results_action_start.vmid == {{ vmid }}
- results_action_start.msg == "VM {{ vmid }} started"
- pause:
seconds: 90
- name: Try to start test VM again
proxmox_kvm:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
node: "{{ node }}"
vmid: "{{ vmid }}"
state: started
register: results_action_start_again
- assert:
that:
- results_action_start_again is not changed
- results_action_start_again.status == 'running'
- results_action_start_again.vmid == {{ vmid }}
- results_action_start_again.msg == "VM {{ vmid }} is already running"
- name: Check current status
proxmox_kvm:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
node: "{{ node }}"
vmid: "{{ vmid }}"
state: current
register: results_action_current
- assert:
that:
- results_action_current is not changed
- results_action_current.status == 'running'
- results_action_current.vmid == {{ vmid }}
- results_action_current.msg == "VM test-instance with vmid = {{ vmid }} is running"
Add proxmox_nic module (#2449) * Add proxmox_nic module Add proxmox_nic module to manage NIC's on Qemu(KVM) VM's in a Proxmox VE cluster. Update proxmox integration tests and add tests for proxmox_nic module. This partially solves https://github.com/ansible-collections/community.general/issues/1964#issuecomment-790499397 and allows for adding/updating/deleting network interface cards after creating/cloning a VM. The proxmox_nic module will keep MAC-addresses the same when updating a NIC. It only changes when explicitly setting a MAC-address. * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * Add check_mode and implement review comments - check_mode added - some documentation updates - when MTU is set, check if the model is virtio, else fail - trunks can now be provided as list of ints instead of vlanid[;vlanid...] * Make returns on update_nic and delete_nic more readable Co-authored-by: Felix Fontein <felix@fontein.de> * Increase readability on update_nic and delete_nic * Implement check in get_vmid - get_vmid will now fail when multiple vmid's are returned as proxmox doesn't guarantee uniqueness - remove an unused import - fix a typo in an error message * Add some error checking to get_vmid - get_vmid will now return the error message when proxmoxer fails - get_vmid will return the vmid directly instead of a list of one - Some minor documentation updates * Warn instead of fail when setting mtu on unsupported nic - When setting the MTU on an unsupported NIC model (virtio is the only supported model) this module will now print a warning instead of failing. - Some minor documentation updates. * Take advantage of proxmox_auth_argument_spec Make use of proxmox_auth_argument_spec from plugins/module_utils/proxmox.py This provides some extra environment fallbacks. * Add blank line to conform with pep8 Co-authored-by: Felix Fontein <felix@fontein.de>
2021-05-13 21:48:49 +02:00
- name: VM add/change/delete NIC
tags: [ 'nic' ]
block:
- name: Add NIC to test VM
proxmox_nic:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
vmid: "{{ vmid }}"
state: present
interface: net5
bridge: vmbr0
tag: 42
register: results
- assert:
that:
- results is changed
- results.vmid == {{ vmid }}
- results.msg == "Nic net5 updated on VM with vmid {{ vmid }}"
- name: Update NIC no changes
proxmox_nic:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
vmid: "{{ vmid }}"
state: present
interface: net5
bridge: vmbr0
tag: 42
register: results
- assert:
that:
- results is not changed
- results.vmid == {{ vmid }}
- results.msg == "Nic net5 unchanged on VM with vmid {{ vmid }}"
- name: Update NIC with changes
proxmox_nic:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
vmid: "{{ vmid }}"
state: present
interface: net5
bridge: vmbr0
tag: 24
firewall: true
Add proxmox_nic module (#2449) * Add proxmox_nic module Add proxmox_nic module to manage NIC's on Qemu(KVM) VM's in a Proxmox VE cluster. Update proxmox integration tests and add tests for proxmox_nic module. This partially solves https://github.com/ansible-collections/community.general/issues/1964#issuecomment-790499397 and allows for adding/updating/deleting network interface cards after creating/cloning a VM. The proxmox_nic module will keep MAC-addresses the same when updating a NIC. It only changes when explicitly setting a MAC-address. * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * Add check_mode and implement review comments - check_mode added - some documentation updates - when MTU is set, check if the model is virtio, else fail - trunks can now be provided as list of ints instead of vlanid[;vlanid...] * Make returns on update_nic and delete_nic more readable Co-authored-by: Felix Fontein <felix@fontein.de> * Increase readability on update_nic and delete_nic * Implement check in get_vmid - get_vmid will now fail when multiple vmid's are returned as proxmox doesn't guarantee uniqueness - remove an unused import - fix a typo in an error message * Add some error checking to get_vmid - get_vmid will now return the error message when proxmoxer fails - get_vmid will return the vmid directly instead of a list of one - Some minor documentation updates * Warn instead of fail when setting mtu on unsupported nic - When setting the MTU on an unsupported NIC model (virtio is the only supported model) this module will now print a warning instead of failing. - Some minor documentation updates. * Take advantage of proxmox_auth_argument_spec Make use of proxmox_auth_argument_spec from plugins/module_utils/proxmox.py This provides some extra environment fallbacks. * Add blank line to conform with pep8 Co-authored-by: Felix Fontein <felix@fontein.de>
2021-05-13 21:48:49 +02:00
register: results
- assert:
that:
- results is changed
- results.vmid == {{ vmid }}
- results.msg == "Nic net5 updated on VM with vmid {{ vmid }}"
- name: Delete NIC
proxmox_nic:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
vmid: "{{ vmid }}"
state: absent
interface: net5
register: results
- assert:
that:
- results is changed
- results.vmid == {{ vmid }}
- results.msg == "Nic net5 deleted on VM with vmid {{ vmid }}"
New module: Proxmox disk management (#5101) * New module: Proxmox disk management * Remove misplaced option * Type missed * Fixed docs, quotes, 2.7 syntax * Forgotten comma * Version added 5.5.0 Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Italic options Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Missed dot Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Pythonify python Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Shorten command Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Action parameter drop. General improvements. * Add proxmox_disk integration testing * Shorten getting vmid Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Code tag for value Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Italic tag for option Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Definite ID of the VM Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Docs edit and loop condition * Simplify conditions Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Dropped bps options, added idempotency checks * Documentaion edit * Rewrite create/import condition * Trainling comma Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Added type field to all choosable arguments * Description of disk bus ranges * Fix imports * Update version Co-authored-by: Felix Fontein <felix@fontein.de> * Lowercase YAML boolean * Rename grown to resized and update documentation * Documentation updated before actual changes * Added 'update' flag for 'present' state * Traling space * YAML indentation * Merged 'updated' option into 'present'. * Doc update. * Exclude 'import_from' on update * Version bump * yaml boolean lowercase Co-authored-by: Felix Fontein <felix@fontein.de> * yaml boolean lowercase Co-authored-by: Felix Fontein <felix@fontein.de> * More detailed description Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Felix Fontein <felix@fontein.de>
2022-09-18 22:06:21 +02:00
- name: Create new disk in VM
tags: ['create_disk']
block:
- name: Add new disk (without force) to VM
proxmox_disk:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
vmid: "{{ vmid }}"
disk: "{{ disk }}"
storage: "{{ storage }}"
size: 1
state: present
register: results
- assert:
that:
- results is changed
- results.vmid == {{ vmid }}
- results.msg == "Disk {{ disk }} created in VM {{ vmid }}"
- name: Try add disk again with same options (expect no-op)
proxmox_disk:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
vmid: "{{ vmid }}"
disk: "{{ disk }}"
storage: "{{ storage }}"
size: 1
state: present
register: results
- assert:
that:
- results is not changed
- results.vmid == {{ vmid }}
- results.msg == "Disk {{ disk }} is up to date in VM {{ vmid }}"
- name: Add new disk replacing existing disk (detach old and leave unused)
proxmox_disk:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
vmid: "{{ vmid }}"
disk: "{{ disk }}"
storage: "{{ storage }}"
size: 2
create: forced
state: present
register: results
- assert:
that:
- results is changed
- results.vmid == {{ vmid }}
- results.msg == "Disk {{ disk }} created in VM {{ vmid }}"
- name: Update existing disk in VM
tags: ['update_disk']
block:
- name: Update disk configuration
proxmox_disk:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
vmid: "{{ vmid }}"
disk: "{{ disk }}"
backup: false
ro: true
aio: native
state: present
register: results
- assert:
that:
- results is changed
- results.vmid == {{ vmid }}
- results.msg == "Disk {{ disk }} updated in VM {{ vmid }}"
- name: Grow existing disk in VM
tags: ['grow_disk']
block:
- name: Increase disk size
proxmox_disk:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
vmid: "{{ vmid }}"
disk: "{{ disk }}"
size: +1G
state: resized
register: results
- assert:
that:
- results is changed
- results.vmid == {{ vmid }}
- results.msg == "Disk {{ disk }} resized in VM {{ vmid }}"
- name: Detach disk and leave it unused
tags: ['detach_disk']
block:
- name: Detach disk
proxmox_disk:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
vmid: "{{ vmid }}"
disk: "{{ disk }}"
state: detached
register: results
- assert:
that:
- results is changed
- results.vmid == {{ vmid }}
- results.msg == "Disk {{ disk }} detached from VM {{ vmid }}"
- name: Move disk to another storage or another VM
tags: ['move_disk']
block:
- name: Move disk to another storage inside same VM
proxmox_disk:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
vmid: "{{ vmid }}"
disk: "{{ disk }}"
target_storage: "{{ target_storage }}"
format: "{{ target_format }}"
state: moved
register: results
- assert:
that:
- results is changed
- results.vmid == {{ vmid }}
- results.msg == "Disk {{ disk }} moved from VM {{ vmid }} storage {{ results.storage }}"
- name: Move disk to another VM (same storage)
proxmox_disk:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
vmid: "{{ vmid }}"
disk: "{{ disk }}"
target_vmid: "{{ target_vm }}"
target_disk: "{{ target_disk }}"
state: moved
register: results
- assert:
that:
- results is changed
- results.vmid == {{ vmid }}
- results.msg == "Disk {{ disk }} moved from VM {{ vmid }} storage {{ results.storage }}"
- name: Remove disk permanently
tags: ['remove_disk']
block:
- name: Remove disk
proxmox_disk:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
vmid: "{{ target_vm }}"
disk: "{{ target_disk }}"
state: absent
register: results
- assert:
that:
- results is changed
- results.vmid == {{ target_vm }}
- results.msg == "Disk {{ target_disk }} removed from VM {{ target_vm }}"
- name: VM stop
tags: [ 'stop' ]
block:
- name: Stop test VM
proxmox_kvm:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
node: "{{ node }}"
vmid: "{{ vmid }}"
state: stopped
register: results_action_stop
- assert:
that:
- results_action_stop is changed
- results_action_stop.status == 'running'
- results_action_stop.vmid == {{ vmid }}
- results_action_stop.msg == "VM {{ vmid }} is shutting down"
- pause:
seconds: 5
- name: Check current status again
proxmox_kvm:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
node: "{{ node }}"
vmid: "{{ vmid }}"
state: current
register: results_action_current
- assert:
that:
- results_action_current is not changed
- results_action_current.status == 'stopped'
- results_action_current.vmid == {{ vmid }}
- results_action_current.msg == "VM test-instance with vmid = {{ vmid }} is stopped"
- name: VM destroy
tags: [ 'destroy' ]
block:
- name: Destroy test VM
proxmox_kvm:
api_host: "{{ api_host }}"
api_user: "{{ user }}@{{ domain }}"
api_password: "{{ api_password | default(omit) }}"
api_token_id: "{{ api_token_id | default(omit) }}"
api_token_secret: "{{ api_token_secret | default(omit) }}"
validate_certs: "{{ validate_certs }}"
proxmox_default_behavior: "no_defaults"
node: "{{ node }}"
vmid: "{{ vmid }}"
state: absent
register: results_kvm_destroy
- assert:
that:
- results_kvm_destroy is changed
- results_kvm_destroy.vmid == {{ vmid }}
- results_kvm_destroy.msg == "VM {{ vmid }} removed"