From 25fcdd2292f75f31938b9c18b1911a9ae30cb99c Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Thu, 30 Nov 2023 09:57:18 -0800 Subject: [PATCH] WIP: Add support for creating a test cluster This will help with verifying backups and making sure my configuration is dynamic. --- ansible_playbooks/setup-cluster.yml | 2 + ansible_playbooks/spin-test-cluster.yml | 25 +++++++++++ ansible_playbooks/test_ansible_hosts.yml | 55 ++++++++++++++++++++++++ core/traefik/traefik.nomad | 2 + 4 files changed, 84 insertions(+) create mode 100644 ansible_playbooks/spin-test-cluster.yml create mode 100644 ansible_playbooks/test_ansible_hosts.yml diff --git a/ansible_playbooks/setup-cluster.yml b/ansible_playbooks/setup-cluster.yml index 4175d3c..7be878d 100644 --- a/ansible_playbooks/setup-cluster.yml +++ b/ansible_playbooks/setup-cluster.yml @@ -106,6 +106,8 @@ - name: photoprism-media path: /srv/volumes/photos/Photoprism read_only: false + + # TODO: If test hosts, use a different path - name: photoprism-storage path: /srv/volumes/nas-container/photoprism read_only: false diff --git a/ansible_playbooks/spin-test-cluster.yml b/ansible_playbooks/spin-test-cluster.yml new file mode 100644 index 0000000..7fc708b --- /dev/null +++ b/ansible_playbooks/spin-test-cluster.yml @@ -0,0 +1,25 @@ +--- +- name: Stop prod cluster + hosts: nomad_instances + vars: + template_vm_name: jammy-cloud-tmpl + + tasks: + - name: Stop prod cluster + community.general.proxmox_kvm: + name: "{{ test_prod_vm }}" + state: stopped + delegate_to: localhost + when: test_prod_vm + + - name: Create test instances + community.general.proxmox_kvm: + clone: "{{ template_vm_name }}" + name: "{{ ansible_hostname }}" + ipconfig: + ipconfig0: "ip={{ test_ip_address }},gw=192.168.2.1" + delegate_to: localhost + + - name: Wait for cluster to spin up + +- import_playbook: setup-cluster.yml diff --git a/ansible_playbooks/test_ansible_hosts.yml b/ansible_playbooks/test_ansible_hosts.yml new file mode 100644 index 0000000..0be21d3 --- /dev/null +++ b/ansible_playbooks/test_ansible_hosts.yml @@ -0,0 +1,55 @@ +--- +all: + children: + servers: + hosts: + tn1.thefij: + test_prod_vm: n1 + test_ip_address: 192.168.2.201 + + nomad_node_role: both + nomad_unique_host_volumes: + - name: mysql-data + path: /srv/volumes/mysql + owner: "999" + group: "100" + mode: "0755" + read_only: false + - name: postgres-data + path: /srv/volumes/postgres + owner: "999" + group: "999" + mode: "0755" + read_only: false + tn2.thefij: + test_prod_vm: n2 + test_ip_address: 192.168.2.202 + + nomad_node_class: ingress + nomad_node_role: both + nomad_unique_host_volumes: + - name: nextcloud-data + path: /srv/volumes/nextcloud + owner: "root" + group: "bin" + mode: "0755" + read_only: false + - name: gitea-data + path: /srv/volumes/gitea + owner: "root" + group: "bin" + mode: "0755" + read_only: false + - name: sonarr-data + path: /srv/volumes/sonarr + owner: "root" + group: "bin" + mode: "0755" + read_only: false + tn3: + test_ip_address: 192.168.2.203 + nomad_node_role: both + + nomad_instances: + children: + servers: {} diff --git a/core/traefik/traefik.nomad b/core/traefik/traefik.nomad index 1a38f31..47b5a77 100644 --- a/core/traefik/traefik.nomad +++ b/core/traefik/traefik.nomad @@ -37,9 +37,11 @@ job "traefik" { dns { servers = [ + # TODO: Get these IP addresses from ansible? Or, do these need to be here? "192.168.2.101", "192.168.2.102", "192.168.2.30", + # Fallback DNS IP should be static "192.168.2.170", ] }