Initial monorepo scaffold
Turborepo + pnpm monorepo for k3s homelab cluster on Intel NUCs. - Apps: Next.js web frontend, Express API (TypeScript, Dockerfiles, k8s manifests) - Packages: shared UI, ESLint config, TypeScript config, Drizzle DB schemas - Infra/Ansible: bare-metal provisioning with roles for common, k3s-server, k3s-agent, hardening - Infra/Kubernetes: ArgoCD GitOps (app-of-apps + ApplicationSets), platform components (cert-manager, Traefik, CloudNativePG, Valkey, Longhorn, Sealed Secrets), namespaces - Observability: kube-prometheus-stack, Loki, Promtail as ArgoCD Applications - CI/CD: GitHub Actions for PR builds, preview deploys, production deploys - DX: Taskfile, utility scripts, copier templates, Ubiquiti network docs
This commit is contained in:
47
infra/ansible/roles/k3s-server/tasks/main.yaml
Normal file
47
infra/ansible/roles/k3s-server/tasks/main.yaml
Normal file
@@ -0,0 +1,47 @@
|
||||
---
|
||||
- name: Check if k3s is installed
|
||||
ansible.builtin.stat:
|
||||
path: /usr/local/bin/k3s
|
||||
register: k3s_binary
|
||||
|
||||
- name: Download k3s installer
|
||||
ansible.builtin.get_url:
|
||||
url: https://get.k3s.io
|
||||
dest: /tmp/k3s-install.sh
|
||||
mode: "0755"
|
||||
when: not k3s_binary.stat.exists
|
||||
|
||||
- name: Install k3s server
|
||||
ansible.builtin.command:
|
||||
cmd: /tmp/k3s-install.sh
|
||||
environment:
|
||||
INSTALL_K3S_VERSION: "{{ k3s_version }}"
|
||||
K3S_TOKEN: "{{ k3s_token }}"
|
||||
INSTALL_K3S_EXEC: "server {{ k3s_server_args }}"
|
||||
when: not k3s_binary.stat.exists
|
||||
changed_when: true
|
||||
|
||||
- name: Wait for k3s to be ready
|
||||
ansible.builtin.command:
|
||||
cmd: k3s kubectl get nodes
|
||||
register: k3s_ready
|
||||
retries: 30
|
||||
delay: 10
|
||||
until: k3s_ready.rc == 0
|
||||
changed_when: false
|
||||
|
||||
- name: Fetch kubeconfig
|
||||
ansible.builtin.fetch:
|
||||
src: /etc/rancher/k3s/k3s.yaml
|
||||
dest: "{{ playbook_dir }}/../../kubeconfig"
|
||||
flat: true
|
||||
run_once: true
|
||||
|
||||
- name: Update kubeconfig server URL
|
||||
ansible.builtin.lineinfile:
|
||||
path: "{{ playbook_dir }}/../../kubeconfig"
|
||||
regexp: "server: https://127.0.0.1:6443"
|
||||
line: " server: https://{{ ansible_host }}:6443"
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
run_once: true
|
||||
Reference in New Issue
Block a user