baseline/pb_install.yml

43 lines
1.2 KiB
YAML

---
- name: Install k3s server
hosts: all
gather_facts: false
tags: k3s-server
tasks:
- name: Download k3s install script
ansible.builtin.get_url:
url: https://get.k3s.io
dest: /usr/local/bin/k3s_install.sh
mode: "755"
- name: Install k3s server
ansible.builtin.command: "k3s_install.sh"
environment:
INSTALL_K3S_CHANNEL: v1.30.2+k3s1
INSTALL_K3S_EXEC: "--disable traefik"
changed_when: false
- name: Start and enable k3s server
ansible.builtin.service:
name: k3s
state: started
enabled: true
- name: Add restart cronjob
ansible.builtin.cron:
name: "restart k3s (and regenerate certs if necessary)"
special_time: monthly
job: "systemctl restart k3s"
- name: Get kubeconfig
ansible.builtin.fetch:
src: /etc/rancher/k3s/k3s.yaml
dest: kubeconfig_{{ ansible_host }}.yml
flat: true
- name: Deploy baseline
hosts: all
gather_facts: false
tags: baseline
tasks:
- name: Copy manifest
ansible.builtin.copy:
src: argocd-init.yml
dest: /var/lib/rancher/k3s/server/manifests/argocd-init.yml
mode: "644"