From 147304f7b1a3d0de4b0e45d5bf8c4fff02a346cd Mon Sep 17 00:00:00 2001 From: djpbessems Date: Mon, 25 Apr 2022 21:07:24 +0200 Subject: [PATCH] Parse var reference into json;Debugging between plays --- playbook.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/playbook.yml b/playbook.yml index 5c62cc9..5babd1b 100644 --- a/playbook.yml +++ b/playbook.yml @@ -120,12 +120,9 @@ cmd: kubectl config view --raw register: k3s_kubeconfig - - ansible.builtin.debug: - var: k3s_kubeconfig.stdout - - name: Initial node -- Store token ansible.builtin.set_fact: - cluster: "{{ cluster | combine( { 'token': ( k3s_token.content | b64decode | trim ) }, { 'config': ( k3s_kubeconfig.stdout ) } ) }}" + cluster: "{{ cluster | combine( { 'token': ( k3s_token.content | b64decode | trim ) }, { 'kubeconfig': ( k3s_kubeconfig.stdout | from_json ) } ) }}" - block: @@ -172,16 +169,11 @@ ansible.builtin.shell: cmd: "curl -sfL https://get.k3s.io | sh -s - server --disable local-storage" executable: /bin/bash - register: foo environment: K3S_TOKEN: "{{ cluster.token }}" # (hostvars[ansible_play_hosts[0]]).cluster.token K3S_URL: "{{ 'https://' + ( cluster.virtualip | ansible.utils.ipaddr('address') ) + ':6443' }}" throttle: 1 - rescue: - - ansible.builtin.debug: - var: foo - when: inventory_hostname != ansible_play_hosts[0] - name: Deploy applications @@ -191,6 +183,11 @@ - applications.k3s.yml tasks: + - ansible.builtin.debug: + var: cluster + - ansible.builtin.debug: + var: hostvars + - name: Add Helm chart repositories kubernetes.core.helm_repository: name: "{{ item.name }}" @@ -212,6 +209,7 @@ namespace: fleet-system create_namespace: yes wait: yes + kubeconfig: "{{ cluster.kubeconfig }}" loop: - name: fleet-crd url: "https://github.com/rancher/fleet/releases/download/{{ latest_release.json.tag_name }}/fleet-crd-{{ latest_release.json.tag_name }}.tgz"