Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions playbook.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
- name: Setup local filesystem
hosts: localhost
tags: [never, kubeconfig]
tasks:
- name: Create outputs directory
file:
path: outputs
state: directory

- name: Setup RKE
hosts: rke_cluster
roles:
Expand Down
22 changes: 22 additions & 0 deletions roles/rke/tasks/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,28 @@
state: link
force: true

- name: Get a local copy of the kubeconfig
tags: [ never, kubeconfig ]
block:
- name: Copy kubeconfig file for patching and download
copy:
src: /etc/rancher/rke2/rke2.yaml
dest: /tmp/rke2.yaml
mode: 0600
remote_src: yes

- name: Patch the server address in the original kubeconfig
lineinfile:
path: /tmp/rke2.yaml
regexp: 'server: https://127\.0\.0\.1:6443'
line: " server: https://{{ ansible_ssh_host }}:6443"

- name: Download the kubeconfig
fetch:
src: /tmp/rke2.yaml
dest: outputs/{{ ansible_hostname }}.kube.config
flat: yes

- name: Check whether kubectl exists
shell: "which kubectl"
register: kubectl_result
Expand Down
1 change: 1 addition & 0 deletions roles/rke/templates/rke2_config.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ write-kubeconfig-mode: "0600"
disable: rke2-ingress-nginx
tls-san:
- {{ cluster_hostname }}
- {{ ansible_ssh_host }}
{% endif %}

{% if not is_rke_registration_server %}
Expand Down