diff --git a/Justfile b/Justfile index 572dc9a..c7a72b9 100644 --- a/Justfile +++ b/Justfile @@ -15,12 +15,7 @@ tofu-destroy: tofu-init tofu -chdir={{ opentofu_dir }} apply -auto-approve -destroy ansible-run-playbook: - ansible-playbook -i ansible/inventory/incus.yaml -c community.general.incus ansible/playbook.yaml - -clean: - rm ansible/hosts.ini || true - rm -r ansible/.ssh/ || true - rm admin.conf || true + ansible-playbook -i ansible/inventories/incus/incus.yaml -c community.general.incus ansible/site.yaml get-admin-conf: incus exec master-0 -- cat /etc/kubernetes/admin.conf > k8s-admin.conf diff --git a/ansible/group_vars/all.yaml b/ansible/group_vars/all.yaml new file mode 100644 index 0000000..e425179 --- /dev/null +++ b/ansible/group_vars/all.yaml @@ -0,0 +1,2 @@ +--- +ansible_python_interpreter: /usr/bin/python3 diff --git a/ansible/inventory/incus.yaml b/ansible/inventories/incus/incus.yaml similarity index 65% rename from ansible/inventory/incus.yaml rename to ansible/inventories/incus/incus.yaml index 4bd7250..46c3ae0 100644 --- a/ansible/inventory/incus.yaml +++ b/ansible/inventories/incus/incus.yaml @@ -2,4 +2,4 @@ plugin: community.general.incus strict: true remotes: - - local:deskpi-cluster + - local:home-infrastructure diff --git a/ansible/playbook.yaml b/ansible/playbook.yaml deleted file mode 100644 index 83fce0a..0000000 --- a/ansible/playbook.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: Provision with Incus - ansible.builtin.import_playbook: playbooks/common.yaml diff --git a/ansible/playbooks/common.yaml b/ansible/playbooks/common.yaml deleted file mode 100644 index 04c0dfc..0000000 --- a/ansible/playbooks/common.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- name: Bootstrap - Stage 1 - hosts: all - gather_facts: false - tasks: - - name: Install Python 3 - ansible.builtin.raw: | - if ! command -v python3 >/dev/null 2>&1; then - apk add --no-cache python3 - fi - register: apk_result - changed_when: "'OK' in apk_result.stdout or 'Installing' in apk_result.stdout" - -- name: Bootstrap - Stage 2 - hosts: all - tasks: - - name: Install Python 3 Libraries - ansible.builtin.package: - name: "{{ item }}" - loop: - - py3-yaml - - py3-kubernetes diff --git a/ansible/roles/common/tasks/main.yaml b/ansible/roles/common/tasks/main.yaml new file mode 100644 index 0000000..f087a90 --- /dev/null +++ b/ansible/roles/common/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- name: Install required provision packages + ansible.builtin.import_tasks: packages.yaml diff --git a/ansible/roles/common/tasks/packages.yaml b/ansible/roles/common/tasks/packages.yaml new file mode 100644 index 0000000..6737e0f --- /dev/null +++ b/ansible/roles/common/tasks/packages.yaml @@ -0,0 +1,5 @@ +--- +- name: Upgrade all packages + ansible.builtin.package: + name: '*' + state: latest diff --git a/ansible/site.yaml b/ansible/site.yaml new file mode 100644 index 0000000..468f01f --- /dev/null +++ b/ansible/site.yaml @@ -0,0 +1,5 @@ +--- +- name: Common + hosts: all + roles: + - common diff --git a/infra/bootstrap.sh b/infra/bootstrap.sh deleted file mode 100644 index 05c3221..0000000 --- a/infra/bootstrap.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env sh -set -e - -err() { echo "$@" >&2; exit 1; } -log() { echo "$@" >&2; } - -[ "$(id -u)" -ne 0 ] && err "You must run this script as root" - -# Install minimal packages for provisioning -PACKAGES="dropbear openssh-sftp-server python3 py3-yaml py3-kubernetes cloud-utils-growpart e2fsprogs-extra lsblk" -apk update && apk upgrade -apk add ${PACKAGES} - -# Enable and start services -enable_and_start() { - service="$1" - rc-update add "${service}" default - service "${service}" start -} - -enable_and_start dropbear - -# increase root partition size -root_dev=$(readlink -f /dev/root) -disk=$(lsblk -no pkname "$root_dev") -part_num=$(echo "$root_dev" | sed 's|.*[^0-9]||') - -echo "Growing /dev/${disk}${part_num}..." - -# Grow partition and resize -growpart "/dev/$disk" "$part_num" || err "Partition growth failed" -resize2fs "$root_dev" || err "Filesystem resize failed" diff --git a/infra/main.tofu b/infra/main.tofu index bfd13be..47413c5 100644 --- a/infra/main.tofu +++ b/infra/main.tofu @@ -9,6 +9,8 @@ locals { master_count = 2 worker_count = 0 + + image = "ubuntu/26.04" } # --------- @@ -16,16 +18,16 @@ locals { # --------- resource "incus_project" "this" { - name = "deskpi-cluster" - description = "The emulated DeskPi Super6C stack." + name = "home-infrastructure" + description = "An emulated home infrastructure stack." } -resource "incus_image" "alpine" { +resource "incus_image" "this" { project = incus_project.this.name source_image = { remote = "images" - name = "alpine/edge" + name = local.image type = "virtual-machine" } } @@ -76,7 +78,7 @@ resource "incus_instance" "master" { project = incus_project.this.name type = "virtual-machine" - image = incus_image.alpine.fingerprint + image = incus_image.this.fingerprint profiles = [incus_profile.this.name] wait_for { @@ -127,7 +129,7 @@ resource "incus_instance" "worker" { project = incus_project.this.name type = "virtual-machine" - image = incus_image.alpine.fingerprint + image = incus_image.this.fingerprint profiles = [incus_profile.this.name] wait_for {