diff --git a/playbook.yml b/playbook.yml index d5408b4..8c107eb 100644 --- a/playbook.yml +++ b/playbook.yml @@ -95,7 +95,7 @@ - name: Provision Kubernetes hosts: k3s_ha - gather_facts: false + gather_facts: true vars_files: - cluster.k3s.yml tasks: @@ -112,9 +112,9 @@ src: /var/lib/rancher/k3s/server/token register: k3s_token - - name: Store in dictionary + - name: Store token ansible.builtin.set_fact: - cluster: "{{ cluster | combine( { 'token': ( k3s_token.content | b64decode | trim ) } ) }}" + clustertoken: "{{ k3s_token.content | b64decode | trim }}" - name: Pull 'kube-vip' image ansible.builtin.shell: @@ -137,7 +137,7 @@ ansible.builtin.shell: cmd: "curl -sfL https://get.k3s.io | sh -s - server --disable local-storage,traefik" environment: - K3S_TOKEN: "{{ hostvars[ansible_play_hosts[0]].cluster.token }}" + K3S_TOKEN: "{{ hostvars[ansible_play_hosts[0]]['clustertoken'] }}" K3S_URL: "{{ 'https://' + ( cluster.virtualip | ansible.utils.ipaddr('address') ) + ':6443' }}" when: inventory_hostname != ansible_play_hosts[0]