forked from catalin/fukuops
feat: migrate ansible/k3s from https://gitlab.com/fukurokuju/vm-foundation
This commit is contained in:
parent
81b6f45b08
commit
1cc30ed503
15 changed files with 202 additions and 1 deletions
17
ansible/k3s/roles/k3s/tasks/agent.yml
Normal file
17
ansible/k3s/roles/k3s/tasks/agent.yml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
- name: Create rancher folder
|
||||
file:
|
||||
state: directory
|
||||
path: /etc/rancher/k3s
|
||||
owner: root
|
||||
group: root
|
||||
mode: 755
|
||||
|
||||
- name: Copy k3s config file
|
||||
template:
|
||||
src: agent.config.yaml.j2
|
||||
dest: /etc/rancher/k3s/config.yaml
|
||||
mode: 600
|
||||
|
||||
- name: Install k3s agent
|
||||
shell: "bash /tmp/k3s.install.sh agent"
|
||||
19
ansible/k3s/roles/k3s/tasks/copy-kubeconfig.yml
Normal file
19
ansible/k3s/roles/k3s/tasks/copy-kubeconfig.yml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
- name: Create .kube directory
|
||||
become: yes
|
||||
file:
|
||||
path: /home/ci/.kube
|
||||
state: directory
|
||||
mode: '0755'
|
||||
owner: ci
|
||||
group: ci
|
||||
|
||||
- name: Copy kubeconfig
|
||||
copy:
|
||||
remote_src: true
|
||||
src: /etc/rancher/k3s/k3s.yaml
|
||||
dest: /home/ci/.kube/config
|
||||
mode: 0644
|
||||
owner: ci
|
||||
group: ci
|
||||
become: yes
|
||||
7
ansible/k3s/roles/k3s/tasks/download.yml
Normal file
7
ansible/k3s/roles/k3s/tasks/download.yml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
|
||||
- name: Download k3s script
|
||||
get_url:
|
||||
url: https://get.k3s.io
|
||||
dest: /tmp/k3s.install.sh
|
||||
|
||||
14
ansible/k3s/roles/k3s/tasks/main.yml
Normal file
14
ansible/k3s/roles/k3s/tasks/main.yml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
- import_tasks: download.yml
|
||||
name: Download install script
|
||||
|
||||
- import_tasks: master.yml
|
||||
name: Install master node
|
||||
when: inventory_hostname in groups["k3s_masters"]
|
||||
|
||||
- import_tasks: agent.yml
|
||||
name: Install agent node
|
||||
when: inventory_hostname in groups["k3s_agents"]
|
||||
|
||||
- import_tasks: copy-kubeconfig.yml
|
||||
name: Copy kubeconfig
|
||||
when: inventory_hostname in groups["k3s_masters"] and is_first_master
|
||||
19
ansible/k3s/roles/k3s/tasks/master.yml
Normal file
19
ansible/k3s/roles/k3s/tasks/master.yml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
- name: Create rancher folder
|
||||
file:
|
||||
state: directory
|
||||
path: /etc/rancher/k3s
|
||||
owner: root
|
||||
group: root
|
||||
mode: 755
|
||||
|
||||
- name: Copy k3s config file
|
||||
template:
|
||||
src: master.config.yaml.j2
|
||||
dest: /etc/rancher/k3s/config.yaml
|
||||
mode: 600
|
||||
vars:
|
||||
etcd_snapshot_dir: "/nfs/nas1/backups/{{ short_hostname }}"
|
||||
|
||||
- name: Install k3s master
|
||||
command: bash /tmp/k3s.install.sh
|
||||
Loading…
Add table
Add a link
Reference in a new issue