diff --git a/Scripts/Ansible/Playbooks/Linux/Kubernetes/Deploy RKE2 Cluster/3A-deploy-additional-controlplane.yml.md b/Scripts/Ansible/Playbooks/Linux/Kubernetes/Deploy RKE2 Cluster/3A-deploy-additional-controlplane.yml.md new file mode 100644 index 0000000..a09abf6 --- /dev/null +++ b/Scripts/Ansible/Playbooks/Linux/Kubernetes/Deploy RKE2 Cluster/3A-deploy-additional-controlplane.yml.md @@ -0,0 +1,46 @@ +```jsx title="3A-deploy-additional-controlplane.yml" +--- +- name: RKE2 Kubernetes Cluster Deployment + hosts: all + become: yes + tasks: + - name: Download and install RKE2 server + shell: "curl -sfL https://get.rke2.io | INSTALL_RKE2_TYPE=server sh -" + + - name: Symlink the Kubectl Management Command + command: "ln -s {{ item }} /usr/local/bin/kubectl" + args: + creates: "/usr/local/bin/kubectl" + with_items: + - "{{ find_kubectl.stdout }}" + vars: + find_kubectl: + cmd: "find /var/lib/rancher/rke2/data/ -name kubectl" + + - name: Create Rancher-Kubernetes-specific config directory + file: + path: "/etc/rancher/rke2/" + state: directory + + - name: Inject IP of Primary Cluster Host (First Node) into Config File + lineinfile: + path: "/etc/rancher/rke2/config.yaml" + line: "server: https://192.168.3.21:9345" + + - name: Get the node token from the first node in the cluster + shell: "cat /var/lib/rancher/rke2/server/node-token" + register: node_token + run_once: true + when: "'first_node' in group_names" + + - name: Inject the Primary Cluster Host trust token into the config file + lineinfile: + path: "/etc/rancher/rke2/config.yaml" + line: "token: {{ node_token.stdout }}" + + - name: Enable and start the RKE2 server service + systemd: + name: rke2-server.service + state: started + enabled: yes +``` \ No newline at end of file