Revert to dictionary
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Danny Bessems 2022-04-20 17:46:59 +02:00
parent d6842eff96
commit a7bd53fb6e
1 changed files with 6 additions and 13 deletions

View File

@ -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]