Testing with Vagrant
To test the Ansible playbook locally, you can leverage the power of Vagrant to create a virtualized environment.
Prerequisites
Before you begin, make sure you have the following software installed on your system:
- Vagrant: A tool for building and managing virtual machine environments.
- VirtualBox: A virtualization platform that Vagrant can use to create the virtual machine.
You can install these on Debian-based systems using the following command:
sudo apt install -y vagrant virtualbox
Testing Steps
Follow these steps to set up and test your Ansible playbook with Vagrant:
- Navigate to the Project Directory:
- Create and Provision the Vagrant Box: Run the following command to create a new Vagrant box and provision it with your Ansible playbook:
vagrant up --provision
This will:
- Download the specified Ubuntu image (if not already present).
- Create a virtual machine based on that image.
- Execute the
playbook_vagrant.yml
Ansible playbook to configure the virtual machine. - Force Destroy and Recreate (Optional):
If you need to start from a clean slate or make changes to your Ansible playbook, you can force destroy the existing box and recreate it with the latest configuration:
vagrant destroy --force && vagrant up --provision
Important Notes
playbook_vagrant.yml
as the Ansible entry point.ubuntu/mantic64
box. You can find more information about this box on the Vagrant Cloud.Troubleshooting
If you encounter any issues during the testing process, consult the FAQ for assistance.
Github Actions
The project is configured with Github Actions to run the playbook on every push to the main branch. You can find the workflow file at .github/workflows/build.yml
.