Skip to content

Commit cbedd40

Browse files
feat: download rke2.yaml once first server is ready
1 parent 9656aa7 commit cbedd40

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

tasks/download_kubeconfig.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
- name: Download RKE2 kubeconfig to localhost
3+
ansible.builtin.fetch:
4+
src: /etc/rancher/rke2/rke2.yaml
5+
dest: "{{ rke2_download_kubeconf_path }}/{{ rke2_download_kubeconf_file_name }}"
6+
flat: yes
7+
when:
8+
- rke2_download_kubeconf | bool
9+
- inventory_hostname == groups[rke2_servers_group_name].0
10+
11+
- name: Replace loopback IP by master server IP
12+
ansible.builtin.replace:
13+
path: "{{ rke2_download_kubeconf_path }}/{{ rke2_download_kubeconf_file_name }}"
14+
mode: '0600'
15+
regexp: '127\.0\.0\.1|\[::1\]'
16+
replace: "{{ rke2_api_ip | default(hostvars[groups[rke2_servers_group_name].0].ansible_host) | ansible.utils.ipwrap }}"
17+
delegate_to: localhost
18+
become: false
19+
when:
20+
- not ansible_check_mode
21+
- rke2_download_kubeconf | bool
22+
- inventory_hostname == groups[rke2_servers_group_name].0

tasks/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@
5858
- inventory_hostname == active_server or inventory_hostname == groups[rke2_servers_group_name].0
5959
- do_etcd_restore is defined or do_etcd_restore_from_s3 is defined
6060

61+
- name: Download kubeconfig to ansible localhost
62+
ansible.builtin.include_tasks: download_kubeconfig.yaml
63+
when:
64+
- rke2_download_kubeconf | bool
65+
- inventory_hostname == groups[rke2_servers_group_name].0
66+
6167
- name: Prepare and join remaining nodes of the cluster
6268
ansible.builtin.include_tasks: remaining_nodes.yml
6369
when:

tasks/summary.yml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,4 @@
11
---
2-
3-
- name: Download RKE2 kubeconfig to localhost
4-
ansible.builtin.fetch:
5-
src: /etc/rancher/rke2/rke2.yaml
6-
dest: "{{ rke2_download_kubeconf_path }}/{{ rke2_download_kubeconf_file_name }}"
7-
flat: yes
8-
when:
9-
- rke2_download_kubeconf | bool
10-
- inventory_hostname == groups[rke2_servers_group_name].0
11-
12-
- name: Replace loopback IP by master server IP
13-
ansible.builtin.replace:
14-
path: "{{ rke2_download_kubeconf_path }}/{{ rke2_download_kubeconf_file_name }}"
15-
mode: '0600'
16-
regexp: '127\.0\.0\.1|\[::1\]'
17-
replace: "{{ rke2_api_ip | default(hostvars[groups[rke2_servers_group_name].0].ansible_host) | ansible.utils.ipwrap }}"
18-
delegate_to: localhost
19-
become: false
20-
when:
21-
- not ansible_check_mode
22-
- rke2_download_kubeconf | bool
23-
- inventory_hostname == groups[rke2_servers_group_name].0
24-
252
- name: Summary
263
when: inventory_hostname == groups[rke2_servers_group_name].0
274
block:

0 commit comments

Comments
 (0)