Group conditional tasks
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
Danny Bessems 2022-04-20 13:17:12 +02:00
parent f8046868bf
commit 5c5e3558de

View File

@ -100,33 +100,36 @@
- cluster.k3s.yml - cluster.k3s.yml
tasks: tasks:
- name: Install K3s binary (initial node) - name: Initial node
ansible.builtin.shell: block:
cmd: "curl -sfL https://get.k3s.io | sh -s - server --cluster-init --disable local-storage,traefik --tls-san {{ cluster.virtualip | ansible.utils.ipaddr('address') }}"
- name: Install K3s binary
ansible.builtin.shell:
cmd: "curl -sfL https://get.k3s.io | sh -s - server --cluster-init --disable local-storage,traefik --tls-san {{ cluster.virtualip | ansible.utils.ipaddr('address') }}"
- name: Retrieve token
ansible.builtin.slurp:
src: /var/lib/rancher/k3s/server/token
register: k3s_token
- name: Store in dictionary
ansible.builtin.set_fact:
cluster: "{{ cluster | combine( { 'token': ( k3s_token.content | b64decode | trim ) } ) }}"
when: inventory_hostname == ansible_play_hosts[0] when: inventory_hostname == ansible_play_hosts[0]
- name: Retrieve token (from initial node)
ansible.builtin.slurp:
src: /var/lib/rancher/k3s/server/token
register: k3s_token
when: inventory_hostname == ansible_play_hosts[0]
- ansible.builtin.debug:
var: k3s_token
- ansible.builtin.debug:
var: cluster
- name: Store in dictionary
ansible.builtin.set_fact:
cluster: "{{ cluster | combine( { 'token': ( k3s_token.content | b64decode | trim ) } ) }}"
- ansible.builtin.debug: - ansible.builtin.debug:
var: cluster var: cluster
- name: Install K3s binary (additional nodes) - name: Additional nodes
ansible.builtin.shell: block:
cmd: "curl -sfL https://get.k3s.io | sh -s - server --disable local-storage,traefik"
environment: - name: Install K3s binary
K3S_TOKEN: "{{ cluster.token }}" ansible.builtin.shell:
K3S_URL: "{{ 'https://' + ( cluster.virtualip | ansible.utils.ipaddr('address') ) + ':6443' }}" cmd: "curl -sfL https://get.k3s.io | sh -s - server --disable local-storage,traefik"
environment:
K3S_TOKEN: "{{ cluster.token }}"
K3S_URL: "{{ 'https://' + ( cluster.virtualip | ansible.utils.ipaddr('address') ) + ':6443' }}"
when: inventory_hostname != ansible_play_hosts[0] when: inventory_hostname != ansible_play_hosts[0]