Proxmox Molecule Plugin :: run molecule tests using proxmox
Project description
This is an Ansible Molecule Driver plugin to manage instances on a Proxmox VE hypervisor cluster. Only virtual machines are supported at this time.
Requirements
Access to a Proxmox VE cluster
One or more virtual machine templates with required setup
Python package proxmoxer
Ansible module community.general.proxmox_kvm
The required Python packages are automatically installed when molecule-proxmox is installed with pip.
The proxmox_kvm module is included with the Community.General collection and is automatically installed when Ansible is installed with pip.
Virtual machine template requirements
The molecule instances are created by cloning Proxmox virtual machine templates. You will need to create one or more templates.
Templates have the following requirements.
A cloud-init drive if any cloud-init settings are used
networking configured
Python installed for Ansible
qemu-guest-agent installed and enabled in Proxmox
ssh server installed
user account for Ansible
An ssh public key must be added to the authorized_keys for the Ansible user account.
If a non-root user is used for the Ansible user (recommended), that user should be added to the sudoers. (This is not needed for the driver, but will likely be needed for the converge playbook.)
Installation
The molecule-proxmox plugin may be installed with Python pip. A virtualenv is recommended. The following commands install Ansible, Molecule, and the Molecule Proxmox plugin in a virtualenv called venv.
$ python3 -m venv venv
$ . venv/bin/activate
$ pip3 install ansible-core molecule molecule-proxmox
Examples
driver:
name: molecule-proxmox
options:
api_host: <hostname> # e.g. pve01.example.com
api_user: <name>@<realm> # e.g. root@pam
api_password: "********"
node: pve01
ssh_user: tester
ssh_identity_file: /path/to/id_rsa
platforms:
- name: test01
template_name: debian11
- name: test02
template_name: alma8
driver:
name: molecule-proxmox
options:
api_host: <hostname> # e.g. pve01.example.com
api_user: <name>@<realm> # e.g. root@pam
# Optional: Use an API token for Proxmox authentication.
api_token_id: "********"
api_token_secret: "*******************************"
node: pve01
ssh_user: tester
ssh_identity_file: /path/to/id_rsa
# Optional: The default template name.
template_name: debian11
# Optional: Set the hostname after cloning.
sethostname: yes
# Optional: Create the VMs in the pool.
pool: test
platforms:
- name: test01
# Optional: Specify the VM id of the clone.
newid: 216
- name: test02
# Optional: Specify the VM id of the clone.
newid: 217
driver:
name: molecule-proxmox
options:
# Secrets file may be encrypted with ansible-vault.
proxmox_secrets: /path/to/proxmox_secrets.yml"
node: pve01
ssh_user: tester
ssh_identity_file: /path/to/id_rsa
template_name: debian11
platforms:
- name: test01
- name: test02
driver:
name: molecule-proxmox
options:
# Secrets file may be encrypted with ansible-vault.
proxmox_secrets: /path/to/proxmox_secrets.yml"
node: pve01
ssh_user: tester
ssh_identity_file: /path/to/id_rsa
template_name: debian11
platforms:
- name: test01
template_name: debian11
# See https://docs.ansible.com/ansible/latest/collections/community/general/proxmox_kvm_module.html
# for cloud-init options.
ciuser: some_user
cipassword: some_password
ipconfig:
ipconfig0: 'ip=192.168.0.2/24,gw=192.168.0.1'
nameservers:
- 192.169.0.245
Development
To checkout the source code:
$ git clone https://github.com/meffie/molecule-proxmox
$ cd molecule-proxmox
A Makefile and tox.ini are provided to facilitate development and testing. A Python virtualenv environment may be created with the init target.
$ make init
$ source .venv/bin/activate
Export the following shell environment variables to run the unit tests.
# Connection info:
export PROXMOX_HOST=<proxmox hostname>
export PROXMOX_USER=<username@realm> # e.g. root@pam
export PROXMOX_PASSWORD=<password>
export PROXMOX_TOKEN_ID=<id>
export PROXMOX_TOKEN_SECRET=<secret>
export PROXMOX_NODE=<proxmox node name>
export PROXMOX_SSH_USER=<username>
export PROXMOX_SSH_IDENTITY_FILE=<ssh key file for username>
# Template id and names for unit tests:
export PROXMOX_TEMPLATE_VMID=<template vmid to be cloned in by-vmid scenario>
export PROXMOX_TEMPLATE_NAME=<template name to be cloned in by-name scenario>
To run the unit tests in verbose mode:
$ make test
To run the unit tests in quiet mode:
$ make check
License
The MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file molecule_proxmox-1.0.0.tar.gz
.
File metadata
- Download URL: molecule_proxmox-1.0.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d19c8c7521fb2f7425e40bd27639046e659096bcbb70cc673e1520ce292b49c9 |
|
MD5 | 61fa605cc1a7367604014d45063a8878 |
|
BLAKE2b-256 | 1503bfe31f75f9b8d46c06e17d6c2048449da004423f4e6a1f51ce559d5ff38c |
File details
Details for the file molecule_proxmox-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: molecule_proxmox-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c00ea3d8bbff6b67e31390891d874c9b9e3fd033cd92ba78e4d7241863f50cad |
|
MD5 | ced78fd96db593c5a7fa8105712ce266 |
|
BLAKE2b-256 | 3cdd370033cac542524acdcabcc4e2975278028489097569c8e49685b483b6fa |