|
|
|
- name: Install K3s-server for 1st-node
|
|
|
|
command: /root/k3s_install.sh {{ type }}
|
|
|
|
when: "inventory_hostname == groups['kubernetes'][0]"
|
|
|
|
register: command
|
|
|
|
changed_when: "'No change detected' not in command.stdout"
|
|
|
|
|
|
|
|
- name: Make sure service is started / restarted on config change
|
|
|
|
service:
|
|
|
|
name: k3s
|
|
|
|
state: "{{ 'restarted' if not command.changed and config.changed else 'started' }}"
|
|
|
|
when: "inventory_hostname == groups['kubernetes'][0]"
|
|
|
|
|
|
|
|
- name: Waiting for K3s-server to accept connections
|
|
|
|
ansible.builtin.wait_for:
|
|
|
|
host: "{{ inventory_hostname }}"
|
|
|
|
port: 6443
|
|
|
|
state: started
|
|
|
|
when: "inventory_hostname == groups['kubernetes'][0]"
|
|
|
|
|
|
|
|
- name: Install K3s-server for other nodes
|
|
|
|
command: /root/k3s_install.sh {{ type }}
|
|
|
|
when: "inventory_hostname != groups['kubernetes'][0]"
|
|
|
|
register: command
|
|
|
|
changed_when: "'No change detected' not in command.stdout"
|
|
|
|
until: "command is not failed"
|
|
|
|
retries: 2
|
|
|
|
delay: 10
|
|
|
|
|
|
|
|
- name: Make sure service is started / restarted on config change
|
|
|
|
service:
|
|
|
|
name: k3s
|
|
|
|
state: "{{ 'restarted' if not command.changed and config.changed else 'started' }}"
|
|
|
|
when: "inventory_hostname != groups['kubernetes'][0]"
|
|
|
|
|
|
|
|
- name: Waiting for K3s-server to accept connections on other nodes
|
|
|
|
ansible.builtin.wait_for:
|
|
|
|
host: "{{ inventory_hostname }}"
|
|
|
|
port: 6443
|
|
|
|
state: started
|
|
|
|
when: "inventory_hostname != groups['kubernetes'][0]"
|
|
|
|
|
|
|
|
#- name: Add Kubernetes environment-vars to /etc/profile.d/
|
|
|
|
# blockinfile:
|
|
|
|
# path: /etc/profile.d/k3s-bin.sh
|
|
|
|
# marker: "# {mark} ANSIBLE MANAGED BLOCK | k3s"
|
|
|
|
# block: |
|
|
|
|
# export KUBECONFIG="/etc/rancher/k3s/k3s.yaml"
|
|
|
|
# create: true
|
|
|
|
|
|
|
|
- name: Deploy calico
|
|
|
|
import_tasks: ./roles/kubernetes/tasks/install/server/network-plugin/deploy_calico.yml
|
|
|
|
when: "kubernetes.network.plugin == 'calico'"
|
|
|
|
|
|
|
|
- name: Deploy network-helpers
|
|
|
|
import_tasks: ./roles/kubernetes/tasks/install/server/network-plugin/deploy_network_helper.yml
|