46 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
| ```jsx title="2-create-initial-controlplane.yml"
 | |
| ---
 | |
| - name: Deploy Rancher on a Kubernetes cluster
 | |
|   hosts: your_target_host
 | |
|   become: true
 | |
|   gather_facts: yes
 | |
|   tasks:
 | |
|     - name: Download and install the RKE2 server deployment script
 | |
|       ansible.builtin.shell: |
 | |
|         curl -sfL https://get.rke2.io | INSTALL_RKE2_TYPE=server sh -
 | |
| 
 | |
|     - name: Enable and start the RKE2 server service
 | |
|       ansible.builtin.systemd:
 | |
|         name: rke2-server
 | |
|         enabled: yes
 | |
|         state: started
 | |
| 
 | |
|     - name: Create symlink for kubectl
 | |
|       ansible.builtin.command: |
 | |
|         ln -s $(find /var/lib/rancher/rke2/data/ -name kubectl) /usr/local/bin/kubectl
 | |
| 
 | |
|     - name: Temporarily export the Kubeconfig
 | |
|       ansible.builtin.shell: |
 | |
|         export KUBECONFIG=/etc/rancher/rke2/rke2.yaml
 | |
| 
 | |
|     - name: Install Helm
 | |
|       ansible.builtin.shell: |
 | |
|         curl -#L https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
 | |
| 
 | |
|     - name: Add Helm repos for Rancher and Jetstack
 | |
|       ansible.builtin.shell: |
 | |
|         helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
 | |
|         helm repo add jetstack https://charts.jetstack.io
 | |
| 
 | |
|     - name: Install Cert-Manager CRDs
 | |
|       ansible.builtin.shell: |
 | |
|         kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.6.1/cert-manager.crds.yaml
 | |
| 
 | |
|     - name: Install Jetstack cert-manager via Helm
 | |
|       ansible.builtin.shell: |
 | |
|         helm upgrade -i cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace
 | |
| 
 | |
|     - name: Install Rancher via Helm
 | |
|       ansible.builtin.shell: |
 | |
|         helm upgrade -i rancher rancher-latest/rancher --create-namespace --namespace cattle-system --set hostname=rancher.cyberstrawberry.net --set bootstrapPassword=bootStrapAllTheThings --set replicas=1
 | |
| ``` |