From f8046868bf8c51f5330a51981ef96d381ba4c871 Mon Sep 17 00:00:00 2001 From: djpbessems Date: Wed, 20 Apr 2022 12:58:58 +0200 Subject: [PATCH] Store token as fact --- playbook.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/playbook.yml b/playbook.yml index f9ce187..d9b0c01 100644 --- a/playbook.yml +++ b/playbook.yml @@ -111,10 +111,22 @@ register: k3s_token when: inventory_hostname == ansible_play_hosts[0] + - ansible.builtin.debug: + var: k3s_token + - ansible.builtin.debug: + var: cluster + + - name: Store in dictionary + ansible.builtin.set_fact: + cluster: "{{ cluster | combine( { 'token': ( k3s_token.content | b64decode | trim ) } ) }}" + + - ansible.builtin.debug: + var: cluster + - name: Install K3s binary (additional nodes) ansible.builtin.shell: cmd: "curl -sfL https://get.k3s.io | sh -s - server --disable local-storage,traefik" environment: - K3S_TOKEN: "{{ k3s_token.content | b64decode | trim }}" + K3S_TOKEN: "{{ cluster.token }}" K3S_URL: "{{ 'https://' + ( cluster.virtualip | ansible.utils.ipaddr('address') ) + ':6443' }}" when: inventory_hostname != ansible_play_hosts[0]