This commit is contained in:
parent
d6842eff96
commit
a7bd53fb6e
19
playbook.yml
19
playbook.yml
@ -111,17 +111,13 @@
|
|||||||
src: /var/lib/rancher/k3s/server/token
|
src: /var/lib/rancher/k3s/server/token
|
||||||
register: k3s_token
|
register: k3s_token
|
||||||
|
|
||||||
# testing
|
|
||||||
- ansible.builtin.set_fact:
|
|
||||||
cluster: "{{ cluster | combine( { 'token': ( k3s_token.content | b64decode | trim ) } ) }}"
|
|
||||||
|
|
||||||
- name: Initial node -- Store token
|
- name: Initial node -- Store token
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
clustertoken: "{{ k3s_token.content | b64decode | trim }}"
|
cluster: "{{ cluster | combine( { 'token': ( k3s_token.content | b64decode | trim ) } ) }}"
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
|
|
||||||
- name: Install 'kube-vip' -- Retrieve manifest for RBAC
|
- name: Install 'kube-vip' -- Retrieve RBAC-manifest
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
url: https://kube-vip.io/manifests/rbac.yaml
|
url: https://kube-vip.io/manifests/rbac.yaml
|
||||||
return_content: yes
|
return_content: yes
|
||||||
@ -131,12 +127,12 @@
|
|||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
cmd: ctr image pull ghcr.io/kube-vip/kube-vip:latest
|
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:
|
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"
|
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
|
register: manifest_daemonset
|
||||||
|
|
||||||
- name: Install 'kube-vip' -- Inject manifest for installation
|
- name: Install 'kube-vip' -- Inject manifest
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: kube-vip.j2
|
src: kube-vip.j2
|
||||||
dest: /var/lib/rancher/k3s/server/manifests/kube-vip.yml
|
dest: /var/lib/rancher/k3s/server/manifests/kube-vip.yml
|
||||||
@ -145,20 +141,17 @@
|
|||||||
|
|
||||||
- block:
|
- block:
|
||||||
|
|
||||||
- name: Wait for API to become available on virtual IP
|
- name: Additional nodes -- Wait for available API
|
||||||
ansible.builtin.wait_for:
|
ansible.builtin.wait_for:
|
||||||
host: "{{ cluster.virtualip | ansible.utils.ipaddr('address') }}"
|
host: "{{ cluster.virtualip | ansible.utils.ipaddr('address') }}"
|
||||||
port: 6443
|
port: 6443
|
||||||
timeout: 300
|
timeout: 300
|
||||||
|
|
||||||
# testing
|
|
||||||
- ansible.builtin.debug:
|
|
||||||
msg: "{{ (hostvars[ansible_play_hosts[0]]).cluster }}"
|
|
||||||
- name: Additional nodes -- Install K3s binary
|
- name: Additional nodes -- Install K3s binary
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
cmd: "curl -sfL https://get.k3s.io | sh -s - server --disable local-storage,traefik"
|
cmd: "curl -sfL https://get.k3s.io | sh -s - server --disable local-storage,traefik"
|
||||||
environment:
|
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' }}"
|
K3S_URL: "{{ 'https://' + ( cluster.virtualip | ansible.utils.ipaddr('address') ) + ':6443' }}"
|
||||||
|
|
||||||
when: inventory_hostname != ansible_play_hosts[0]
|
when: inventory_hostname != ansible_play_hosts[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user