Full k3s server installation done
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
This commit is contained in:
@@ -1,6 +1,59 @@
|
||||
---
|
||||
- name: Install k3s
|
||||
command: "curl -sfL https://get.k3s.io | sh -s - server --node-taint CriticalAddonsOnly=true:NoExecute --tls-san {{ k3s.loadbalancer.ip }}"
|
||||
# - name: Download K3s install script to /tmp/
|
||||
# ansible.builtin.get_url:
|
||||
# url: https://get.k3s.io
|
||||
# dest: /tmp/k3s_install.sh
|
||||
# mode: "0755"
|
||||
#
|
||||
# - name: Install K3s server with node taint and TLS SAN
|
||||
# when: host.ip == k3s.server.ips[0]
|
||||
# command: |
|
||||
# /tmp/k3s_install.sh server \
|
||||
# --node-taint CriticalAddonsOnly=true:NoExecute \
|
||||
# --tls-san {{ k3s.loadbalancer.ip }}
|
||||
# environment:
|
||||
# K3S_DATASTORE_ENDPOINT: "{{ k3s_db_connection_string }}"
|
||||
# become: true
|
||||
# async: 300
|
||||
# poll: 0
|
||||
# register: k3s_primary_install
|
||||
#
|
||||
# - name: Wait for K3s to be installed
|
||||
# when: host.ip == k3s.server.ips[0]
|
||||
# async_status:
|
||||
# jid: "{{ k3s_primary_install.ansible_job_id }}"
|
||||
# register: k3s_primary_install_status
|
||||
# until: k3s_primary_install_status.finished
|
||||
# retries: 60
|
||||
# delay: 5
|
||||
# become: true
|
||||
|
||||
- name: Get K3s token from the first server
|
||||
when: host.ip == k3s.server.ips[0]
|
||||
slurp:
|
||||
src: /var/lib/rancher/k3s/server/node-token
|
||||
register: k3s_token
|
||||
become: true
|
||||
|
||||
- name: Set fact on k3s.server.ips[0]
|
||||
when: host.ip == k3s.server.ips[0]
|
||||
set_fact: k3s_token="{{ k3s_token['content'] | b64decode | trim }}"
|
||||
|
||||
- name: showdata
|
||||
when: host.ip != k3s.server.ips[0]
|
||||
debug:
|
||||
msg: "{{a}} {{k3s_datastore_endpoint}}"
|
||||
vars:
|
||||
k3s_datastore_endpoint: "{{ k3s_db_connection_string }}"
|
||||
a: "{{ hostvars[(hostvars | dict2items | map(attribute='value') | map('dict2items') | map('selectattr', 'key', 'match', 'host') | map('selectattr', 'value.ip', 'match', k3s.server.ips[0] ) | select() | first | items2dict).host.hostname].k3s_token }}"
|
||||
|
||||
- name: Install K3s on the secondary servers
|
||||
when: host.ip != k3s.server.ips[0]
|
||||
command: |
|
||||
/tmp/k3s_install.sh server \
|
||||
--node-taint CriticalAddonsOnly=true:NoExecute \
|
||||
--tls-san {{ k3s.loadbalancer.ip }}
|
||||
environment:
|
||||
K3S_DATASTORE_ENDPOINT: "{{ k3s_db_connection_string }}"
|
||||
K3S_TOKEN: "{{ hostvars[(hostvars | dict2items | map(attribute='value') | map('dict2items') | map('selectattr', 'key', 'match', 'host') | map('selectattr', 'value.ip', 'match', k3s.server.ips[0] ) | select() | first | items2dict).host.hostname].k3s_token }}"
|
||||
become: true
|
||||
|
||||
Reference in New Issue
Block a user