Testing¶
This project includes several tasks for testing the Ansible playbooks against different architectures.
AMD64¶
To test the playbooks on amd64 hosts, run the following command:
This task will run the ansible.builtin.apt module with update_cache=true on all hosts in the inventory/amd64.proxmox.yaml inventory.
ARM64¶
To test the playbooks on arm64 hosts, run the following command:
This task will run the ansible.builtin.apt module with update_cache=true on all hosts in the inventory/arm64.proxmox.yaml inventory.
Raspberry Pi¶
To test the playbooks on Raspberry Pi hosts, run the following command:
This task will run the ansible.builtin.apt module with update_cache=true on all hosts in the inventory/rpis.yaml inventory.
Dockerized Testing Environment¶
This project includes a Dockerized testing environment in the test/ subdirectory, which allows you to test Ansible playbooks in an isolated Ubuntu container.
Configuration¶
test/Dockerfile: Defines the Docker image used for testing. It sets up an Ubuntu container with SSH access.test/machine-setup.yml: The Ansible playbook that will be run inside the test container. You can modify this file to test your own playbooks and roles.
Usage¶
To run the Dockerized test, navigate to the test/ directory and use the task run command:
This will execute the setup-container.sh script, which automates the entire testing process:
- Creates a temporary directory.
- Generates a temporary SSH key.
- Builds and starts a Docker container.
- Creates a temporary Ansible inventory file.
- Runs the
machine-setup.ymlplaybook inside the container. - Cleans up the container and temporary files.