This commit is contained in:
James Turland
2024-07-26 12:00:20 +01:00
parent 8d85943c50
commit 80d9a3c52b
9 changed files with 159 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
---
# Generate Machine Configurations. This is using the qemu agent as per: https://www.talos.dev/v1.7/talos-guides/install/virtualized-platforms/proxmox/
- name: Apply config to first worker
ansible.builtin.command:
cmd: talosctl apply-config --insecure --nodes {{ worker_1 }} --file {{ config_directory }}/worker.yaml
changed_when: true
- name: Apply config to second worker
ansible.builtin.command:
cmd: talosctl apply-config --insecure --nodes {{ worker_2 }} --file {{ config_directory }}/worker.yaml
changed_when: true

View File

@@ -0,0 +1,16 @@
---
# Generate Machine Configurations. This is using the qemu agent as per: https://www.talos.dev/v1.7/talos-guides/install/virtualized-platforms/proxmox/
- name: Apply config to first node
ansible.builtin.command:
cmd: talosctl apply-config --insecure --nodes {{ control_plane_ip }} --file {{ config_directory }}/controlplane.yaml
changed_when: true
- name: Apply config to second node
ansible.builtin.command:
cmd: talosctl apply-config --insecure --nodes {{ control_plane_2 }} --file {{ config_directory }}/controlplane.yaml
changed_when: true
- name: Apply config to first node
ansible.builtin.command:
cmd: talosctl apply-config --insecure --nodes {{ control_plane_3 }} --file {{ config_directory }}/controlplane.yaml
changed_when: true

View File

@@ -0,0 +1,11 @@
---
- name: Check that the config file doesn't already exist
ansible.builtin.stat:
path: "{{ config_file }}"
register: stat_result
# Generate Machine Configurations. This is using the qemu agent as per: https://www.talos.dev/v1.7/talos-guides/install/virtualized-platforms/proxmox/
- name: Generate config for cluster
when: "not stat_result.stat.exists"
ansible.builtin.command: talosctl gen config talos-proxmox-cluster https://{{ control_plane_ip }}:6443 --output-dir {{ config_directory }} --install-image factory.talos.dev/installer/ce4c980550dd2ab1b17bbf2b08801c7eb59418eafe8f279833297925d67c7515:{{ talos_version }}
changed_when: true

View File

@@ -0,0 +1,26 @@
---
# Update TalosCTL
- name: Update TalosCTL configs
ansible.builtin.command: talosctl config endpoint {{ control_plane_ip }} --talosconfig {{ config_file }}
changed_when: true
- name: Update TalosCTL configs
ansible.builtin.command: talosctl config node {{ control_plane_ip }} --talosconfig {{ config_file }}
changed_when: true
#################################
# WAIT FOR REBOOT & BOOTSTRAP #
#################################
- name: Keep trying to bootstrap
ansible.builtin.command:
cmd: "talosctl bootstrap --talosconfig {{ config_file }}"
register: bootstrap_result
retries: 10
delay: 30
until: bootstrap_result.rc == 0
changed_when: bootstrap_result.rc == 0
# Grab Kubeconfig
- name: Get Kubeconfig
ansible.builtin.command: talosctl kubeconfig . --talosconfig {{ config_file }}
changed_when: true

View File

@@ -0,0 +1,12 @@
---
# Ansible Playbook to install Talos
- name: Download talosctl for Linux (amd64)
ansible.builtin.get_url:
url: https://github.com/siderolabs/talos/releases/download/{{ talosctl_version }}/talosctl-linux-amd64
dest: /usr/local/bin/talosctl
mode: '0755' # Make the binary executable
register: download_result # Register the result for debugging or verification
- name: Display download result
ansible.builtin.debug:
var: download_result # Display the result of the download task