diff options
author | 2023-02-10 13:57:09 +0000 | |
---|---|---|
committer | 2023-02-22 21:47:57 +0400 | |
commit | b479965a80e579ebad2b2b1ba7eca2d2cc04c13b (patch) | |
tree | 90e3666fee9ed1571e46f0ee65a4af5a46cc50df | |
parent | Bump SebastiaanZ/github-status-embed-for-discord to 0.3.0 (diff) |
Add `local_testing` utilizing vagrant and virtualbox to create an environment that we can test ansible updates in
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | local_testing/.gitignore | 1 | ||||
-rw-r--r-- | local_testing/README.md | 46 | ||||
-rw-r--r-- | local_testing/Vagrantfile | 91 | ||||
-rw-r--r-- | local_testing/hosts.yaml | 56 | ||||
-rwxr-xr-x | local_testing/scripts/push-keys | 7 |
6 files changed, 204 insertions, 0 deletions
@@ -13,6 +13,9 @@ requirements.txt # Python requirements ``` ## Local Environment Setup + +To setup a local environment using VMs for testing, [Read here](./local_testing/README.md) + 1. Create a virtual environment: `python -m venv venv` 1. Activate the virtual environment - Windows: `.\venv\Scripts\activate` diff --git a/local_testing/.gitignore b/local_testing/.gitignore new file mode 100644 index 0000000..a977916 --- /dev/null +++ b/local_testing/.gitignore @@ -0,0 +1 @@ +.vagrant/ diff --git a/local_testing/README.md b/local_testing/README.md new file mode 100644 index 0000000..c600f79 --- /dev/null +++ b/local_testing/README.md @@ -0,0 +1,46 @@ +# Testing Locally + +### Requirements + +- [Vagrant](https://developer.hashicorp.com/vagrant/docs/installation) +- [VirtualBox](https://www.virtualbox.org/wiki/Downloads) + +## Get Started + +```shell +vagrant up # This will take a while +vagrant ssh # Get a shell, password=vagrant + +# inside control VM +/vagrant/scripts/push-keys # Push the control VM's ssh key to all nodes + +# run ansible +ansible-playbook playbook.yml --inventory local_testing/hosts.yaml --user vagrant + +``` + +Below are the IPs of the VMs on the VirtualBox network +```yaml +vms: +- control: 192.168.56.1 +- hopper: 192.168.56.2 +- lovelace: 192.168.56.3 +- neumann: 192.168.56.4 +- richie: 192.168.56.5 +- turing: 192.168.56.6 +``` + + +# Fixes/Notes + +### There was an error when attempting to rsync a synced folder. + +```shell +vagrant plugin install vagrant-vbguest +``` + + +### Kernel module is not loaded +```shell +sudo modprobe vbox{drv,netadp,netflt} +``` diff --git a/local_testing/Vagrantfile b/local_testing/Vagrantfile new file mode 100644 index 0000000..3ba743f --- /dev/null +++ b/local_testing/Vagrantfile @@ -0,0 +1,91 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.box = "bento/debian-11" + config.vm.box_version = "202212.11.0" + config.vm.provision "shell", inline: <<-SHELL + apt-get update + apt-get install -y python3 python3-pip openssh-server + systemctl enable ssh + SHELL + + config.vm.define "control", primary: true do |control| + control.vm.hostname = "control" + control.vm.network "private_network", ip: "192.168.56.1", + virtualbox__intnet: true + control.vm.synced_folder "../", "/home/vagrant/infra" + control.vm.provision "shell", inline: <<-SHELL + apt-get install -y sshpass + SHELL + + control.vm.provision "shell", privileged: false, inline: <<-SHELL + python3 -m pip install --user ansible dnspython + ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa <<< y + SHELL + + control.vm.provider "virtualbox" do |v| + v.name = "pydis_control" + end + end + + config.vm.define "hopper" do |hopper| + hopper.vm.hostname = "hopper" + hopper.vm.network "private_network", ip: "192.168.56.2", + virtualbox__intnet: true + hopper.vm.synced_folder '.', '/vagrant', disabled: true + + hopper.vm.provider "virtualbox" do |v| + v.name = "pydis_hopper" + v.memory = 2048 + end + end + + config.vm.define "lovelace" do |lovelace| + lovelace.vm.hostname = "lovelace" + lovelace.vm.network "private_network", ip: "192.168.56.3", + virtualbox__intnet: true + lovelace.vm.synced_folder '.', '/vagrant', disabled: true + + lovelace.vm.provider "virtualbox" do |v| + v.name = "pydis_lovelace" + v.memory = 2048 + end + end + + config.vm.define "neumann" do |neumann| + neumann.vm.hostname = "neumann" + neumann.vm.network "private_network", ip: "192.168.56.4", + virtualbox__intnet: true + neumann.vm.synced_folder '.', '/vagrant', disabled: true + + neumann.vm.provider "virtualbox" do |v| + v.name = "pydis_neumann" + v.memory = 2048 + end + end + + config.vm.define "ritchie" do |ritchie| + ritchie.vm.hostname = "ritchie" + ritchie.vm.network "private_network", ip: "192.168.56.5", + virtualbox__intnet: true + ritchie.vm.synced_folder '.', '/vagrant', disabled: true + + ritchie.vm.provider "virtualbox" do |v| + v.name = "pydis_ritchie" + v.memory = 2048 + end + end + + config.vm.define "turing" do |turing| + turing.vm.hostname = "turing" + turing.vm.network "private_network", ip: "192.168.56.6", + virtualbox__intnet: true + turing.vm.synced_folder '.', '/vagrant', disabled: true + + turing.vm.provider "virtualbox" do |v| + v.name = "pydis_turing" + v.memory = 2048 + end + end +end diff --git a/local_testing/hosts.yaml b/local_testing/hosts.yaml new file mode 100644 index 0000000..d1759a3 --- /dev/null +++ b/local_testing/hosts.yaml @@ -0,0 +1,56 @@ +all: + hosts: + hopper: + ansible_host: 192.168.56.2 + ip: 192.168.56.2 + access_ip: 192.168.56.2 + lovelace: + ansible_host: 192.168.56.3 + ip: 192.168.56.3 + access_ip: 192.168.56.3 + neumann: + ansible_host: 192.168.56.4 + ip: 192.168.56.4 + access_ip: 192.168.56.4 + ritchie: + ansible_host: 192.168.56.5 + ip: 192.168.56.5 + access_ip: 192.168.56.5 + turing: + ansible_host: 192.168.56.6 + ip: 192.168.56.6 + access_ip: 192.168.56.6 + children: + kube_control_plane: + hosts: + hopper: + turing: + kube_node: + hosts: + hopper: + turing: + lovelace: + neumann: + ritchie: + etcd: + hosts: + hopper: + turing: + lovelace: + k8s_cluster: + children: + kube_control_plane: + kube_node: + calico_rr: + hosts: {} + podman: + hosts: + turing: + lovelace: + hopper: + ritchie: + nginx: + hosts: + turing: + ritchie: + neumann: diff --git a/local_testing/scripts/push-keys b/local_testing/scripts/push-keys new file mode 100755 index 0000000..6fdc85f --- /dev/null +++ b/local_testing/scripts/push-keys @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# Intended to be used in the "control" VM to push keys to the other hosts + +for i in {1..6} ; do + ssh-keyscan 192.168.56.$i >> ~/.ssh/known_hosts + sshpass -p vagrant ssh-copy-id 192.168.56.$i +done |