From d9b07235ebed47968cee268f47b5e1c5d59630db Mon Sep 17 00:00:00 2001 From: djpbessems Date: Wed, 20 Apr 2022 15:13:04 +0200 Subject: [PATCH] Avoid dictionary for now; enable facts --- playbook.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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]