feat(ansible): add K3s installation playbooks and configuration templates
这个提交包含在:
@@ -0,0 +1,4 @@
|
||||
---
|
||||
- name: Apply sysctl
|
||||
ansible.builtin.command: sysctl --system
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# 基础配置 Role
|
||||
# 功能: hostname、sysctl、Tailscale 安装
|
||||
---
|
||||
- name: Set hostname
|
||||
ansible.builtin.hostname:
|
||||
name: "{{ node_hostname }}"
|
||||
when: node_hostname is defined
|
||||
|
||||
- name: Update /etc/hosts
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/hosts
|
||||
regexp: '^127\.0\.1\.1'
|
||||
line: "127.0.1.1 {{ node_hostname }}"
|
||||
when: node_hostname is defined
|
||||
|
||||
- name: Configure sysctl for IP forwarding
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/sysctl.d/99-k3s.conf
|
||||
content: |
|
||||
net.ipv4.ip_forward = 1
|
||||
net.ipv6.conf.all.forwarding = 1
|
||||
mode: '0644'
|
||||
notify: Apply sysctl
|
||||
|
||||
- name: Install dependencies
|
||||
ansible.builtin.apt:
|
||||
name: [curl, wget, ca-certificates]
|
||||
state: present
|
||||
update_cache: yes
|
||||
|
||||
- name: Check if Tailscale is installed
|
||||
ansible.builtin.command: which tailscale
|
||||
register: tailscale_check
|
||||
ignore_errors: yes
|
||||
changed_when: false
|
||||
|
||||
- name: Install Tailscale
|
||||
ansible.builtin.shell: curl -fsSL https://tailscale.com/install.sh | sh
|
||||
when: tailscale_check.rc != 0
|
||||
|
||||
- name: Enable Tailscale service
|
||||
ansible.builtin.systemd:
|
||||
name: tailscaled
|
||||
enabled: yes
|
||||
state: started
|
||||
|
||||
在新议题中引用
屏蔽一个用户