Remove proxmox content (#10110)
Some checks failed
EOL CI / EOL Sanity (Ⓐ2.16) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.16+py2.7) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.16+py3.11) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.16+py3.6) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/3/) (push) Has been cancelled
nox / Run extra sanity tests (push) Has been cancelled

Remove proxmox content.
This commit is contained in:
Felix Fontein 2025-06-08 16:18:16 +02:00 committed by GitHub
commit f2b7bdf293
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
76 changed files with 124 additions and 14629 deletions

View file

@ -1,12 +0,0 @@
# Copyright (c) 2025 Nils Stein (@mietzen) <github.nstein@mailbox.org>
# Copyright (c) 2025 Ansible Project
# 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
azp/posix/3
destructive
needs/root
needs/target/connection
skip/docker
skip/alpine
skip/macos

View file

@ -1,18 +0,0 @@
---
# Copyright (c) 2025 Nils Stein (@mietzen) <github.nstein@mailbox.org>
# Copyright (c) 2025 Ansible Project
# 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
- hosts: localhost
gather_facts: true
serial: 1
tasks:
- name: Copy pct mock
copy:
src: files/pct
dest: /usr/sbin/pct
mode: '0755'
- name: Install paramiko
pip:
name: "paramiko>=3.0.0"

View file

@ -1,33 +0,0 @@
#!/usr/bin/env bash
# Copyright (c) 2025 Nils Stein (@mietzen) <github.nstein@mailbox.org>
# Copyright (c) 2025 Ansible Project
# 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
# Shell script to mock proxmox pct behaviour
>&2 echo "[DEBUG] INPUT: $@"
pwd="$(pwd)"
# Get quoted parts and restore quotes
declare -a cmd=()
for arg in "$@"; do
if [[ $arg =~ [[:space:]] ]]; then
arg="'$arg'"
fi
cmd+=("$arg")
done
cmd="${cmd[@]:3}"
vmid="${@:2:1}"
>&2 echo "[INFO] MOCKING: pct ${@:1:3} ${cmd}"
tmp_dir="/tmp/ansible-remote/proxmox_pct_remote/integration_test/ct_${vmid}"
mkdir -p "$tmp_dir"
>&2 echo "[INFO] PWD: $tmp_dir"
>&2 echo "[INFO] CMD: ${cmd}"
cd "$tmp_dir"
eval "${cmd}"
cd "$pwd"

View file

@ -1,32 +0,0 @@
---
# Copyright (c) Ansible Project
# 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
- hosts: "{{ target_hosts }}"
gather_facts: false
serial: 1
tasks:
- name: create file without content
copy:
content: ""
dest: "{{ remote_tmp }}/test_empty.txt"
force: no
mode: '0644'
- name: assert file without content exists
stat:
path: "{{ remote_tmp }}/test_empty.txt"
register: empty_file_stat
- name: verify file without content exists
assert:
that:
- empty_file_stat.stat.exists
fail_msg: "The file {{ remote_tmp }}/test_empty.txt does not exist."
- name: verify file without content is empty
assert:
that:
- empty_file_stat.stat.size == 0
fail_msg: "The file {{ remote_tmp }}/test_empty.txt is not empty."

View file

@ -1,19 +0,0 @@
#!/usr/bin/env bash
# Copyright (c) 2025 Nils Stein (@mietzen) <github.nstein@mailbox.org>
# Copyright (c) 2025 Ansible Project
# 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
set -eux
ANSIBLE_ROLES_PATH=../ \
ansible-playbook dependencies.yml -v "$@"
./test.sh "$@"
ansible-playbook plugin-specific-tests.yml -i "./test_connection.inventory" \
-e target_hosts="proxmox_pct_remote" \
-e action_prefix= \
-e local_tmp=/tmp/ansible-local \
-e remote_tmp=/tmp/ansible-remote \
"$@"

View file

@ -1 +0,0 @@
../connection_posix/test.sh

View file

@ -1,14 +0,0 @@
# Copyright (c) 2025 Nils Stein (@mietzen) <github.nstein@mailbox.org>
# Copyright (c) 2025 Ansible Project
# 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
[proxmox_pct_remote]
proxmox_pct_remote-pipelining ansible_ssh_pipelining=true
proxmox_pct_remote-no-pipelining ansible_ssh_pipelining=false
[proxmox_pct_remote:vars]
ansible_host=localhost
ansible_user=root
ansible_python_interpreter="{{ ansible_playbook_python }}"
ansible_connection=community.general.proxmox_pct_remote
proxmox_vmid=123

View file

@ -1,9 +0,0 @@
# Copyright (c) Ansible Project
# 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
unsupported
proxmox_domain_info
proxmox_group_info
proxmox_user_info
proxmox_storage_info

View file

@ -1,616 +0,0 @@
####################################################################
# 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
- 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: List content on storage
proxmox_storage_contents_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 }}"
node: "{{ node }}"
content: images
register: results_list_storage
- assert:
that:
- results_storage is not changed
- results_storage.proxmox_storage_content is defined
- results_storage.proxmox_storage_content |length == 1
- 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
tags:
- TagWithUppercaseChars
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"
- 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
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 }}"
- 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 }}"
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"
- name: Retrieve information about nodes
proxmox_node_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_nodes is defined
- results.proxmox_nodes|length >= 1
- results.proxmox_nodes[0].type == 'node'

View file

@ -1,7 +0,0 @@
# Copyright (c) Ansible Project
# 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
unsupported
proxmox_pool
proxmox_pool_member

View file

@ -1,7 +0,0 @@
# Copyright (c) 2023, Sergei Antipov <greendayonfire at gmail.com>
# 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
poolid: test
member: local
member_type: storage

View file

@ -1,220 +0,0 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
# Copyright (c) 2023, Sergei Antipov <greendayonfire at gmail.com>
# 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: Proxmox VE pool and pool membership management
tags: ["pool"]
block:
- name: Make sure poolid parameter is not missing
proxmox_pool:
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 }}"
ignore_errors: true
register: result
- assert:
that:
- result is failed
- "'missing required arguments: poolid' in result.msg"
- name: Create pool (Check)
proxmox_pool:
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 }}"
poolid: "{{ poolid }}"
check_mode: true
register: result
- assert:
that:
- result is changed
- result is success
- name: Create pool
proxmox_pool:
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 }}"
poolid: "{{ poolid }}"
register: result
- assert:
that:
- result is changed
- result is success
- result.poolid == "{{ poolid }}"
- name: Delete pool (Check)
proxmox_pool:
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 }}"
poolid: "{{ poolid }}"
state: absent
check_mode: true
register: result
- assert:
that:
- result is changed
- result is success
- name: Delete non-existing pool should do nothing
proxmox_pool:
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 }}"
poolid: "non-existing-poolid"
state: absent
register: result
- assert:
that:
- result is not changed
- result is success
- name: Deletion of non-empty pool fails
block:
- name: Add storage into pool
proxmox_pool_member:
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 }}"
poolid: "{{ poolid }}"
member: "{{ member }}"
type: "{{ member_type }}"
diff: true
register: result
- assert:
that:
- result is changed
- result is success
- "'{{ member }}' in result.diff.after.members"
- name: Add non-existing storage into pool should fail
proxmox_pool_member:
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 }}"
poolid: "{{ poolid }}"
member: "non-existing-storage"
type: "{{ member_type }}"
ignore_errors: true
register: result
- assert:
that:
- result is failed
- "'Storage non-existing-storage doesn\\'t exist in the cluster' in result.msg"
- name: Delete non-empty pool
proxmox_pool:
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 }}"
poolid: "{{ poolid }}"
state: absent
ignore_errors: true
register: result
- assert:
that:
- result is failed
- "'Please remove members from pool first.' in result.msg"
- name: Delete storage from the pool
proxmox_pool_member:
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 }}"
poolid: "{{ poolid }}"
member: "{{ member }}"
type: "{{ member_type }}"
state: absent
register: result
- assert:
that:
- result is success
- result is changed
rescue:
- name: Delete storage from the pool if it is added
proxmox_pool_member:
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 }}"
poolid: "{{ poolid }}"
member: "{{ member }}"
type: "{{ member_type }}"
state: absent
ignore_errors: true
- name: Delete pool
proxmox_pool:
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 }}"
poolid: "{{ poolid }}"
state: absent
register: result
- assert:
that:
- result is changed
- result is success
- result.poolid == "{{ poolid }}"
rescue:
- name: Delete test pool if it is created
proxmox_pool:
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 }}"
poolid: "{{ poolid }}"
state: absent
ignore_errors: true

View file

@ -1,6 +0,0 @@
# Copyright (c) Ansible Project
# 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
unsupported
proxmox_template

View file

@ -1,136 +0,0 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
# Copyright (c) 2023, Sergei Antipov <greendayonfire at gmail.com>
# 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: Proxmox VE virtual machines templates management
tags: ['template']
vars:
filename: /tmp/dummy.iso
block:
- name: Create dummy ISO file
ansible.builtin.command:
cmd: 'truncate -s 300M {{ filename }}'
- name: Delete requests_toolbelt module if it is installed
ansible.builtin.pip:
name: requests_toolbelt
state: absent
- name: Install latest proxmoxer
ansible.builtin.pip:
name: proxmoxer
state: latest
- name: Upload ISO as template to Proxmox VE cluster should fail
proxmox_template:
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 }}'
src: '{{ filename }}'
content_type: iso
force: true
register: result
ignore_errors: true
- assert:
that:
- result is failed
- result.msg is match('\'requests_toolbelt\' module is required to upload files larger than 256MB')
- name: Install old (1.1.2) version of proxmoxer
ansible.builtin.pip:
name: proxmoxer==1.1.1
state: present
- name: Upload ISO as template to Proxmox VE cluster should be successful
proxmox_template:
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 }}'
src: '{{ filename }}'
content_type: iso
force: true
register: result
- assert:
that:
- result is changed
- result is success
- result.msg is match('template with volid=local:iso/dummy.iso uploaded')
- name: Install latest proxmoxer
ansible.builtin.pip:
name: proxmoxer
state: latest
- name: Make smaller dummy file
ansible.builtin.command:
cmd: 'truncate -s 128M {{ filename }}'
- name: Upload ISO as template to Proxmox VE cluster should be successful
proxmox_template:
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 }}'
src: '{{ filename }}'
content_type: iso
force: true
register: result
- assert:
that:
- result is changed
- result is success
- result.msg is match('template with volid=local:iso/dummy.iso uploaded')
- name: Install requests_toolbelt
ansible.builtin.pip:
name: requests_toolbelt
state: present
- name: Make big dummy file
ansible.builtin.command:
cmd: 'truncate -s 300M {{ filename }}'
- name: Upload ISO as template to Proxmox VE cluster should be successful
proxmox_template:
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 }}'
src: '{{ filename }}'
content_type: iso
force: true
register: result
- assert:
that:
- result is changed
- result is success
- result.msg is match('template with volid=local:iso/dummy.iso uploaded')
always:
- name: Delete ISO file from host
ansible.builtin.file:
path: '{{ filename }}'
state: absent