From d0df49bbfa82616cfa63963fead44d955157128d Mon Sep 17 00:00:00 2001 From: Robert Wimmer <2039811+githubixx@users.noreply.github.com> Date: Wed, 16 Feb 2022 21:41:11 +0100 Subject: [PATCH] Add Molecule single server + two clients example (#148) * add Molecule scenario for single server * change verifier to Ansible --- molecule/kvm-single-server/converge.yml | 12 ++++ molecule/kvm-single-server/molecule.yml | 82 +++++++++++++++++++++++++ molecule/kvm-single-server/prepare.yml | 13 ++++ molecule/kvm/molecule.yml | 11 +--- 4 files changed, 109 insertions(+), 9 deletions(-) create mode 100644 molecule/kvm-single-server/converge.yml create mode 100644 molecule/kvm-single-server/molecule.yml create mode 100644 molecule/kvm-single-server/prepare.yml diff --git a/molecule/kvm-single-server/converge.yml b/molecule/kvm-single-server/converge.yml new file mode 100644 index 0000000..546010a --- /dev/null +++ b/molecule/kvm-single-server/converge.yml @@ -0,0 +1,12 @@ +--- +# Copyright (C) 2022 Robert Wimmer +# SPDX-License-Identifier: GPL-3.0-or-later + +- hosts: all + remote_user: vagrant + become: true + gather_facts: true + tasks: + - name: Include WireGuard role + ansible.builtin.include_role: + name: githubixx.ansible_role_wireguard diff --git a/molecule/kvm-single-server/molecule.yml b/molecule/kvm-single-server/molecule.yml new file mode 100644 index 0000000..7ab53ff --- /dev/null +++ b/molecule/kvm-single-server/molecule.yml @@ -0,0 +1,82 @@ +--- +# Copyright (C) 2022 Robert Wimmer +# SPDX-License-Identifier: GPL-3.0-or-later + +dependency: + name: galaxy + +driver: + name: vagrant + provider: + name: libvirt + type: libvirt + options: + memory: 192 + cpus: 2 + +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 + - ubuntu + - name: test-wg-ubuntu1804 + box: generic/ubuntu1804 + interfaces: + - auto_config: true + network_name: private_network + type: static + ip: 192.168.10.20 + groups: + - vpn + - ubuntu + - name: test-wg-debian11 + box: generic/debian11 + interfaces: + - auto_config: true + network_name: private_network + type: static + ip: 192.168.10.30 + groups: + - vpn + - debian + +provisioner: + name: ansible + connection_options: + ansible_ssh_user: vagrant + ansible_become: true + log: true + lint: + name: ansible-lint + inventory: + host_vars: + test-wg-ubuntu2004: + wireguard_address: "10.10.10.10/24" + wireguard_port: 51820 + wireguard_persistent_keepalive: "30" + wireguard_endpoint: "192.168.10.10" + test-wg-ubuntu1804: + wireguard_address: "10.10.10.20/24" + wireguard_persistent_keepalive: "30" + wireguard_endpoint: "" + test-wg-debian11: + wireguard_address: "10.10.10.30/24" + wireguard_persistent_keepalive: "30" + wireguard_endpoint: "" + ansible_python_interpreter: "/usr/bin/python3" + +scenario: + name: kvm-single-server + test_sequence: + - prepare + - converge + +verifier: + name: ansible + enabled: False diff --git a/molecule/kvm-single-server/prepare.yml b/molecule/kvm-single-server/prepare.yml new file mode 100644 index 0000000..8b00225 --- /dev/null +++ b/molecule/kvm-single-server/prepare.yml @@ -0,0 +1,13 @@ +--- +# Copyright (C) 2022 Robert Wimmer +# SPDX-License-Identifier: GPL-3.0-or-later + +- hosts: ubuntu + remote_user: vagrant + become: true + gather_facts: true + tasks: + - name: Update APT package cache + ansible.builtin.apt: + update_cache: true + cache_valid_time: 3600 diff --git a/molecule/kvm/molecule.yml b/molecule/kvm/molecule.yml index 3fba834..8d82642 100644 --- a/molecule/kvm/molecule.yml +++ b/molecule/kvm/molecule.yml @@ -219,12 +219,5 @@ scenario: - converge verifier: - name: testinfra - directory: tests - options: - # Add a -v so you see the individual test names, - # particularly useful with parameterized tests - v: true - sudo: true - lint: - name: flake8 + name: ansible + enabled: False