From a7bd53fb6ecc62ad6b5a62058626cf6c892ff60e Mon Sep 17 00:00:00 2001 From: djpbessems Date: Wed, 20 Apr 2022 17:46:59 +0200 Subject: [PATCH] Revert to dictionary --- playbook.yml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/playbook.yml b/playbook.yml index c63f705..cf37d52 100644 --- a/playbook.yml +++ b/playbook.yml @@ -111,17 +111,13 @@ src: /var/lib/rancher/k3s/server/token register: k3s_token - # testing - - ansible.builtin.set_fact: - cluster: "{{ cluster | combine( { 'token': ( k3s_token.content | b64decode | trim ) } ) }}" - - name: Initial node -- Store token ansible.builtin.set_fact: - clustertoken: "{{ k3s_token.content | b64decode | trim }}" + cluster: "{{ cluster | combine( { 'token': ( k3s_token.content | b64decode | trim ) } ) }}" - block: - - name: Install 'kube-vip' -- Retrieve manifest for RBAC + - name: Install 'kube-vip' -- Retrieve RBAC-manifest ansible.builtin.uri: url: https://kube-vip.io/manifests/rbac.yaml return_content: yes @@ -131,12 +127,12 @@ ansible.builtin.shell: cmd: ctr image pull ghcr.io/kube-vip/kube-vip:latest - - name: Install 'kube-vip' -- Generate manifest for daemonSet + - name: Install 'kube-vip' -- Generate daemonSet-manifest ansible.builtin.shell: cmd: "ctr run --rm --net-host ghcr.io/kube-vip/kube-vip:latest vip /kube-vip manifest daemonset --interface {{ ansible_default_ipv4.interface }} --address {{ cluster.virtualip | ansible.utils.ipaddr('address') }} --inCluster --taint --controlplane --services --arp --leaderElection" register: manifest_daemonset - - name: Install 'kube-vip' -- Inject manifest for installation + - name: Install 'kube-vip' -- Inject manifest ansible.builtin.template: src: kube-vip.j2 dest: /var/lib/rancher/k3s/server/manifests/kube-vip.yml @@ -145,20 +141,17 @@ - block: - - name: Wait for API to become available on virtual IP + - name: Additional nodes -- Wait for available API ansible.builtin.wait_for: host: "{{ cluster.virtualip | ansible.utils.ipaddr('address') }}" port: 6443 timeout: 300 - # testing - - ansible.builtin.debug: - msg: "{{ (hostvars[ansible_play_hosts[0]]).cluster }}" - name: Additional nodes -- Install K3s binary 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]]['clustertoken'] }}" + K3S_TOKEN: "{{ (hostvars[ansible_play_hosts[0]]).cluster.token }}" K3S_URL: "{{ 'https://' + ( cluster.virtualip | ansible.utils.ipaddr('address') ) + ':6443' }}" when: inventory_hostname != ansible_play_hosts[0]