Set up ansible scripts to install k3s, helm, and ArgoCD in a Debian-based node
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
/target
|
||||
/.venv
|
||||
|
||||
.env
|
||||
|
||||
uv.lock
|
||||
@@ -0,0 +1 @@
|
||||
3.12
|
||||
Vendored
+2
-1
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"editor.formatOnSave": true
|
||||
"editor.formatOnSave": true,
|
||||
"ansible.python.interpreterPath": "/home/nyeki/Documents/Repositories/payphone/payphone/.venv/bin/python"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
[dev]
|
||||
dev-node ansible_host=p4.vps.nyeki.dev ansible_user=root
|
||||
@@ -0,0 +1,42 @@
|
||||
- name: Set up k3s on dev node
|
||||
hosts: dev
|
||||
become: true
|
||||
tasks:
|
||||
- name: Install curl
|
||||
ansible.builtin.apt:
|
||||
name: curl
|
||||
state: present
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Download k3s install script
|
||||
ansible.builtin.get_url:
|
||||
url: https://get.k3s.io
|
||||
dest: /tmp/k3s_install.sh
|
||||
mode: '0755'
|
||||
|
||||
- name: Run k3s installer
|
||||
ansible.builtin.command: /tmp/k3s_install.sh
|
||||
args:
|
||||
creates: /usr/local/bin/k3s
|
||||
|
||||
- name: Ensure k3s service is started and enabled
|
||||
ansible.builtin.systemd:
|
||||
name: k3s
|
||||
enabled: true
|
||||
state: started
|
||||
|
||||
- name: Install Python Kubernetes client
|
||||
ansible.builtin.apt:
|
||||
name: python3-kubernetes
|
||||
state: present
|
||||
|
||||
- name: Download helm install script
|
||||
ansible.builtin.get_url:
|
||||
url: https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
|
||||
dest: /tmp/get_helm.sh
|
||||
mode: '0755'
|
||||
|
||||
- name: Run helm installer
|
||||
ansible.builtin.command: /tmp/get_helm.sh
|
||||
args:
|
||||
creates: /usr/local/bin/helm
|
||||
@@ -0,0 +1,30 @@
|
||||
- name: Set up ArgoCD
|
||||
hosts: dev
|
||||
become: true
|
||||
tasks:
|
||||
- name: Create ArgoCD namespace
|
||||
kubernetes.core.k8s:
|
||||
api_version: v1
|
||||
kind: Namespace
|
||||
name: argocd
|
||||
kubeconfig: /etc/rancher/k3s/k3s.yaml
|
||||
|
||||
- name: Apply ArgoCD installation manifest
|
||||
kubernetes.core.k8s:
|
||||
state: present
|
||||
src: https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
|
||||
namespace: argocd
|
||||
kubeconfig: /etc/rancher/k3s/k3s.yaml
|
||||
|
||||
- name: Get ArgoCD initial admin password
|
||||
ansible.builtin.shell: kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}"
|
||||
register: encoded_pass
|
||||
changed_when: false
|
||||
|
||||
- name: Decode ArgoCD password
|
||||
ansible.builtin.set_fact:
|
||||
argocd_pass: "{{ encoded_pass.stdout | b64decode }}"
|
||||
|
||||
- name: Show ArgoCD password
|
||||
ansible.builtin.debug:
|
||||
msg: "ArgoCD admin password: {{ argocd_pass }}"
|
||||
@@ -0,0 +1,10 @@
|
||||
[project]
|
||||
name = "payphone"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"ansible>=11.9.0",
|
||||
"ansible-lint>=25.8.1",
|
||||
]
|
||||
Reference in New Issue
Block a user