role for installing k3s

This commit is contained in:
2021-12-23 16:22:24 -05:00
parent 14f8936790
commit ad554214af
6 changed files with 61 additions and 3 deletions

View File

@@ -0,0 +1,23 @@
---
# install k3s
- name: Install required packages
apt:
name: "{{ item }}"
update_cache: yes
cache_valid_time: 3600
state: latest
with_items:
- curl
- name: Fetch k3s install script
ansible.builtin.uri:
url: https://get.k3s.io
return_content: yes
register: k3s_installer
- name: Run installer
async: 300
poll: 10
ansible.builtin.shell:
cmd: sh -s --
stdin: "{{ k3s_installer.content }}"

View File

@@ -0,0 +1,15 @@
---
# Main task file for k3s role
- name: check for existing config
stat:
path: /etc/systemd/system/k3s.service
register: k3s_service
- include_tasks: install.yml
when: not k3s_service.stat.exists
- name: Start service k3s, if not started
ansible.builtin.service:
name: k3s
state: started