role for installing k3s
This commit is contained in:
@@ -5,12 +5,11 @@ home ansible_ssh_host=192.168.4.11
|
|||||||
cubox-i ansible_ssh_host=192.168.4.12
|
cubox-i ansible_ssh_host=192.168.4.12
|
||||||
|
|
||||||
[ns]
|
[ns]
|
||||||
home ansible_ssh_host=192.168.4.22
|
home ansible_ssh_host=192.168.4.11
|
||||||
cubox-i ansible_ssh_host=192.168.4.12
|
cubox-i ansible_ssh_host=192.168.4.12
|
||||||
|
|
||||||
[gfs]
|
[gfs]
|
||||||
home ansible_ssh_host=192.168.4.11
|
home ansible_ssh_host=192.168.4.11
|
||||||
cubox-i ansible_ssh_host=192.168.4.12
|
|
||||||
|
|
||||||
;[desktop]
|
;[desktop]
|
||||||
;richard-desktop ansible_connection=local
|
;richard-desktop ansible_connection=local
|
||||||
|
|||||||
8
ansible-5/playbooks/kube.yaml
Normal file
8
ansible-5/playbooks/kube.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- name: ping
|
||||||
|
hosts: managed
|
||||||
|
gather_facts: true
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: k3s
|
||||||
|
become: true
|
||||||
11
ansible-5/roles/common/tasks/install_tools.yml
Normal file
11
ansible-5/roles/common/tasks/install_tools.yml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Install required packages
|
||||||
|
apt:
|
||||||
|
name: "{{ item }}"
|
||||||
|
update_cache: yes
|
||||||
|
cache_valid_time: 3600
|
||||||
|
state: latest
|
||||||
|
with_items:
|
||||||
|
- htop
|
||||||
|
when: ansible_os_family == "Debian"
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
# update packages to latest
|
|
||||||
|
|
||||||
|
- include_tasks: install_tools.yml
|
||||||
|
|
||||||
|
# update packages to latest
|
||||||
- include_tasks: apply_updates.yml
|
- include_tasks: apply_updates.yml
|
||||||
|
|
||||||
- include_tasks: motd.yml
|
- include_tasks: motd.yml
|
||||||
|
|||||||
23
ansible-5/roles/k3s/tasks/install.yml
Normal file
23
ansible-5/roles/k3s/tasks/install.yml
Normal 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 }}"
|
||||||
15
ansible-5/roles/k3s/tasks/main.yml
Normal file
15
ansible-5/roles/k3s/tasks/main.yml
Normal 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
|
||||||
Reference in New Issue
Block a user