![]() ![]() That’s basically preconfigured virtual machine images. In the example above you only see three VMs defined but the WireGuard role defines a few more but that doesn’t matter. In platforms the virtual machines are defined that should be started. name : test-wg-arch box : archlinux/archlinux interfaces : - auto_config : true network_name : private_network type : static ip : 192.168.10.80 groups : - vpn Platforms : - name : test-wg-ubuntu2004 box : generic/ubuntu2004 interfaces : - auto_config : true network_name : private_network type : static ip : 192.168.10.10 groups : - vpn - name : test-wg-ubuntu1804 box : generic/ubuntu1804 interfaces : - auto_config : true network_name : private_network type : static ip : 192.168.10.20 groups : - vpn. The first thing that is defined in this file is the dependency manager: That’s basically the configuration file for the resources that are needed to run the test suite. The content of the files in molecule/kvm/ directory is pretty rudimentary. When you create more scenarios it might make sense to share some files between them by creating a shared folder and point from the scenarios to the files in that folder. So I’ll just create an additional scenario google-cloud e.g. One example could be that maybe later I’ll decide that I don’t only want to test with KVM virtual machines but also within a Google Cloud project. ![]() You can create as many scenarios as you like and Molecule will run one after the other. For now, we can think of a scenario as a test suite for the role. Scenarios are the starting point for a lot of powerful functionality that Molecule offers. If you don’t specify a scenario name here the directory would have been called default. That’s the name of the scenario I defined above with molecule init scenario kvm. ![]() I’ll mention the required packages for Ubuntu 20.04 too but that’s mostly an educated guess (but I tried to install the packages in a virtual machine at least) -)īefore you start make sure that you add yourself to the libvirt group (for Ubuntu 20.04 you may also need to be part of group libvirt-qemu).Īs you can see above inside the molecule directory there is currently a folder called kvm. Everything else is the same no matter which Linux distribution you use. This instructions are mainly for Archlinux here but that only matters for installing the required packages. But why a second virtualization solution if I already have a few virtual machines running locally with libvirt and KVM (Kernel-based Virtual Machine)? That two components provide fast virtualization out of the box that basically comes with every Linux OS. The next natural fit would be to use the Vagrant driver with the VirtualBox provider to create virtual machines (VM) with a fully installed Linux operating system. Also I needed systemd which also requires some changes to make it work with Docker. But that could (and probably will) be different from the Docker container. If I would do this with Docker Ansible would report the kernel version of the host where the Docker container runs on. ![]() In such a case we need a DKMS module package and for this you need the correct kernel header package installed. I needed a “real” OS as some OSes still don’t have a kernel that supports WireGuard out of the box like Ubuntu 18.04 e.g. But for my WireGuard role Docker isn’t good enough. Molecule will instruct the Docker driver to launch a Docker container with Ubuntu 20.04. That means if you want to test your role with Ubuntu 20.04 e.g. Most people will use Docker as a driver which is also Molecule’s default. Molecule provides support for testing with multiple instances, operating systems and distributions, virtualization providers, test frameworks and testing scenarios.” To quote the description of Molecule: “Molecule project is designed to aid in the development and testing of Ansible roles. I needed something to test the role for all OSes. As I only use Ubuntu and Archlinux personally I needed to trust contributors that their code works as I couldn’t test the parts that were special for a specific OS. After a while people started contributing code esp. I maintain a small Ansible role for WireGuard. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |