mirror of
https://github.com/PyratLabs/ansible-role-k3s
synced 2024-11-10 07:23:30 +01:00
Fix joining nodes to an existing cluster
This commit is contained in:
parent
141b6f2018
commit
9524b07df0
4 changed files with 17 additions and 13 deletions
|
@ -10,10 +10,10 @@
|
|||
- software-properties-common
|
||||
state: present
|
||||
register: ensure_docker_prerequisites_installed
|
||||
become: "{{ k3s_become_for_package_install | ternary(true, false, k3s_become_for_all) }}"
|
||||
until: ensure_docker_prerequisites_installed is succeeded
|
||||
retries: 3
|
||||
delay: 10
|
||||
become: "{{ k3s_become_for_package_install | ternary(true, false, k3s_become_for_all) }}"
|
||||
|
||||
- name: Ensure Docker APT key is present
|
||||
apt_key:
|
||||
|
|
|
@ -49,16 +49,18 @@
|
|||
loop: "{{ play_hosts }}"
|
||||
when: hostvars[item].k3s_control_node is defined
|
||||
|
||||
- name: Lookup control node from file
|
||||
command: "grep '{{ 'P_True' if (k3s_controller_count | length > 1) else 'C_True' }}' /tmp/inventory.txt"
|
||||
changed_when: false
|
||||
register: k3s_control_delegate_raw
|
||||
- name: Delegate a master control plane node
|
||||
block:
|
||||
- name: Lookup control node from file
|
||||
command: "grep '{{ 'P_True' if (k3s_controller_count | length > 1) else 'C_True' }}' /tmp/inventory.txt"
|
||||
changed_when: false
|
||||
register: k3s_control_delegate_raw
|
||||
|
||||
- name: Ensure control node is delegated to for obtaining a token
|
||||
set_fact:
|
||||
k3s_control_delegate: "{{ k3s_control_delegate_raw.stdout.split(' @@@ ')[0] }}"
|
||||
- name: Ensure control node is delegated to for obtaining a token
|
||||
set_fact:
|
||||
k3s_control_delegate: "{{ k3s_control_delegate_raw.stdout.split(' @@@ ')[0] }}"
|
||||
|
||||
- name: Ensure the control node address is registered in Ansible
|
||||
set_fact:
|
||||
k3s_control_node_address: "{{ hostvars[k3s_control_delegate].ansible_host | default(hostvars[k3s_control_delegate].ansible_fqdn) }}"
|
||||
- name: Ensure the control node address is registered in Ansible
|
||||
set_fact:
|
||||
k3s_control_node_address: "{{ hostvars[k3s_control_delegate].ansible_host | default(hostvars[k3s_control_delegate].ansible_fqdn) }}"
|
||||
when: k3s_control_node_address is not defined
|
||||
|
|
|
@ -44,5 +44,6 @@
|
|||
- import_tasks: build/install-k3s.yml
|
||||
|
||||
- import_tasks: build/configure-k3s-cluster.yml
|
||||
when: play_hosts | length > 1
|
||||
and k3s_build_cluster is defined and k3s_build_cluster
|
||||
when: k3s_build_cluster is defined and k3s_build_cluster
|
||||
and k3s_control_node_address is defined
|
||||
and k3s_control_token is defined
|
||||
|
|
|
@ -40,3 +40,4 @@
|
|||
|
||||
when: k3s_check_kubectl.stat.exists is defined
|
||||
and k3s_check_kubectl.stat.exists
|
||||
and k3s_control_delegate is defined
|
||||
|
|
Loading…
Reference in a new issue