Skip to content

Commit

Permalink
tests: Add env vars for unit tests
Browse files Browse the repository at this point in the history
Instead of hardcoded names in the molecule.yml file, use env vars to
specify site specific values.
  • Loading branch information
meffie committed Mar 14, 2022
1 parent 81bb1d8 commit 46476d8
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 15 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
*.pyd
*.egg-info/
__pycache__/
.*/
.*
dist/
build/

# test artifacts
.env.yml
38 changes: 37 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Installation
============

The ``molecule-proxmox`` plugin may be installed with Python ``pip``. A virtualenv
is recommended. The following commands install Anisble, Molecule, and the
is recommended. The following commands install Ansible, Molecule, and the
Molecule Proxmox plugin in a virtualenv called ``venv``.

.. code-block:: bash
Expand Down Expand Up @@ -107,6 +107,42 @@ Example
- name: test02
template_vmid: 9000
Development
===========

To checkout the source code:

$ git clone https://github.com/meffie/molecule-proxmox
$ cd molecule-proxmox

A `Makefile` is 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.

export PROXMOX_SECRETS=<proxmox secrets yaml file path>
export PROXMOX_NODE=<proxmox node name>
export PROXMOX_SSH_USER=<username>
export PROXMOX_SSH_IDENTITY_FILE=<ssh key file for username>

The secrets file should contain the proxmox login credentials, either the
username and password, or a Proxmox API token id and value. This file should
be encrypted with `ansible-vault`. The ssh user and identity file should match
the user and public key installed when the virtual machine template was
created.

To run the unit tests in verbose mode:

$ make test

To run the unit tests in quiet mode:

$ make check


Authors
=======

Expand Down
18 changes: 8 additions & 10 deletions tests/proxmox_driver/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,23 @@ driver:
name: proxmox
options:
# Creds file path. May be encrypted with ansible-vault.
proxmox_secrets: "${HOME}/proxmox_secrets.yml"
proxmox_secrets: "${PROXMOX_SECRETS}"
#api_host: "*********"
#api_user: "*********"
#api_password: "********"
#api_token_id: "********"
#api_token_secret: "*******************************"
node: "morty"
ssh_user: "molecule"
ssh_identity_file: "${HOME}/.ssh/id_rsa"
node: "${PROXMOX_NODE}"
ssh_user: "${PROXMOX_SSH_USER}"
ssh_identity_file: "${PROXMOX_SSH_IDENTITY_FILE}"
clone_delay: 2
box2vmid:
"generic/alma8": 9000

platforms:
- name: m01
template_vmid: 9000
- name: m02
template_vmid: 9000
- name: m03
box: generic/alma8
#- name: m02
# template_vmid: 9000
#- name: m03
# box: generic/alma8
provisioner:
name: ansible

0 comments on commit 46476d8

Please sign in to comment.