abril/molecule
Simon Leiner 33ae0d4970
Fix CI (#332)
* Update pre-commit actions

This was done by running "pre-commit autoupdate --freeze".

* Remove pre-commit only dependencies from requirements.in

Including them in the file would create the illusion that those were the
versions actually used in CI, but they are not. The exact versions are
determined by the pre-commit hooks which are pinned in
.pre-commit-config.yaml.

* Ansible Lint: Fix role-name[path]

* Ansible Lint: Fix name[play]

* Ansible Lint: Fix key-order[task]

* Ansible Lint: Fix jinja[spacing]

* Ansible Lint: Fix no-free-form

* Ansible Lint: Fix var-naming[no-reserved]

* Ansible Lint: Fix yaml[comments]

* Ansible Lint: Fix yaml[line-length]

* Ansible Lint: Fix name[casing]

* Ansible Lint: Fix no-changed-when

* Ansible Lint: Fix fqcn[action]

* Ansible Lint: Fix args[module]

* Improve task naming
2023-07-20 10:50:02 -05:00
..
default Fix CI (#332) 2023-07-20 10:50:02 -05:00
ipv6 Fix CI (#332) 2023-07-20 10:50:02 -05:00
resources Fix CI (#332) 2023-07-20 10:50:02 -05:00
single_node Fix CI (#332) 2023-07-20 10:50:02 -05:00
README.md Add support for API servers on IPv6 addresses (#48) 2022-09-10 12:57:38 -05:00

Test suites for k3s-ansible

This folder contains the molecule-based test setup for this playbook.

Scenarios

We have these scenarios:

  • default: A 3 control + 2 worker node cluster based very closely on the sample inventory.
  • ipv6: A cluster that is externally accessible via IPv6 (more information) To save a bit of test time, this cluster is not highly available, it consists of only one control and one worker node.
  • single_node: Very similar to the default scenario, but uses only a single node for all cluster functionality.

How to execute

To test on your local machine, follow these steps:

System requirements

Make sure that the following software packages are available on your system:

Set up VirtualBox networking on Linux and macOS

You can safely skip this if you are working on Windows.

Furthermore, the test cluster uses the 192.168.30.0/24 subnet which is not set up by VirtualBox automatically. To set the subnet up for use with VirtualBox, please make sure that /etc/vbox/networks.conf exists and that it contains this line:

* 192.168.30.0/24
* fdad:bad:ba55::/64

Install Python dependencies

You will get Molecule, Ansible and a few extra dependencies via pip. Usually, it is advisable to work in a virtual environment for this:

cd /path/to/k3s-ansible

# Create a virtualenv at ".env". You only need to do this once.
python3 -m venv .env

# Activate the virtualenv for your current shell session.
# If you start a new session, you will have to repeat this.
source .env/bin/activate

# Install the required packages into the virtualenv.
# These remain installed across shell sessions.
python3 -m pip install -r requirements.txt

Run molecule

With the virtual environment from the previous step active in your shell session, you can now use molecule to test the playbook. Interesting commands are:

  • molecule create: Create virtual machines for the test cluster nodes.
  • molecule destroy: Delete the virtual machines for the test cluster nodes.
  • molecule converge: Run the site playbook on the nodes of the test cluster.
  • molecule side_effect: Run the reset playbook on the nodes of the test cluster.
  • molecule verify: Verify that the cluster works correctly.
  • molecule test: The "all-in-one" sequence of steps that is executed in CI. This includes the create, converge, verify, side_effect and destroy steps. See molecule.yml for more details.