From 44e6a160aff7c100f3290a01d215052272d51adc Mon Sep 17 00:00:00 2001 From: djpbessems Date: Wed, 20 Apr 2022 11:43:02 +0200 Subject: [PATCH] Switch to slurp module --- playbook.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/playbook.yml b/playbook.yml index 3d75dc8..d573403 100644 --- a/playbook.yml +++ b/playbook.yml @@ -108,9 +108,19 @@ 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\" } ) }}" + - name: Reference new cluster + block: + + - name: Retrieve token + ansible.builtin.slurp: + src: /var/lib/rancher/k3s/server/token + register: k3s_token + + - ansible.builtin.debug: + var: k3s_token + + - name: Add to dictionary + cluster: "{{ cluster | combine( { 'mastertoken': k3s_token }, { 'apiurl': \"https://{{ cluster.virtualip | ansible.utils.ipaddr('address') }}:6443\" } ) }}" when: cluster.mastertoken is not defined - ansible.builtin.debug: