Add vars_file to second playbook; Retrieve K3s token for subsequent nodes
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is failing
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	continuous-integration/drone/push Build is failing
				
			This commit is contained in:
		
							
								
								
									
										19
									
								
								playbook.yml
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								playbook.yml
									
									
									
									
									
								
							@@ -68,17 +68,26 @@
 | 
			
		||||
- name: Provision Kubernetes
 | 
			
		||||
  hosts: k3s_ha
 | 
			
		||||
  gather_facts: false
 | 
			
		||||
  # vars_files:
 | 
			
		||||
  # - hypervisor.vcenter.yml
 | 
			
		||||
  # - cluster.k3s.yml
 | 
			
		||||
  vars_files:
 | 
			
		||||
  - cluster.k3s.yml
 | 
			
		||||
  tasks:
 | 
			
		||||
 | 
			
		||||
  - name: Iterate over hosts
 | 
			
		||||
    block:
 | 
			
		||||
 | 
			
		||||
    - name: Install K3s binary
 | 
			
		||||
      ansible.builtin.command:
 | 
			
		||||
        cmd: "curl -sfL https://get.k3s.io | sh -s - server --cluster-init --disable local-storage,traefik --tls-san {{ cluster.virtualip | ansible.utils.ipaddr('address') }}"
 | 
			
		||||
      environment:
 | 
			
		||||
        K3S_TOKEN: env.k3s_token | default('', true)
 | 
			
		||||
        K3S_URL: env.k3s_url | default('', true)
 | 
			
		||||
        K3S_TOKEN: cluster.mastertoken | default('', true)
 | 
			
		||||
        K3S_URL: cluster.apiurl | default('', true)
 | 
			
		||||
 | 
			
		||||
    - name: Retrieve token & reference new cluster
 | 
			
		||||
      ansible.builtin.set_fact:
 | 
			
		||||
        cluster: "{{ cluster | combine( { mastertoken: lookup('file', /var/lib/rancher/k3s/server/token) }, { apiurl: 'https://{{ cluster.virtualip | ansible.utils.ipaddr('address') }}:6443' } ) }}"
 | 
			
		||||
      when: cluster.mastertoken is not defined
 | 
			
		||||
 | 
			
		||||
    - ansible.builtin.debug:
 | 
			
		||||
        var: cluster
 | 
			
		||||
 | 
			
		||||
    throttle: 1
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user