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:

  1. Navigate to the Project Directory:
Ensure you are in the root directory of your Griffin project where the Vagrantfile and playbook_vagrant.yml files are located.
  1. 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:

  1. Download the specified Ubuntu image (if not already present).
  2. Create a virtual machine based on that image.
  3. Execute the playbook_vagrant.yml Ansible playbook to configure the virtual machine.
  4. 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

The Vagrantfile in your project is already configured to use playbook_vagrant.yml as the Ansible entry point.
Base Box: The Vagrant setup uses the 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.