--- - name: Cluster Installation hosts: kubernetes become: true gather_facts: true any_errors_fatal: true pre_tasks: - name: Pausing for 5 seconds... ansible.builtin.pause: seconds: 5 tasks: - name: Check if cluster is installed check_mode: false ansible.builtin.stat: path: /etc/rancher/k3s/config.yaml register: k3s_installed - name: Ignore manifests templates and urls if the cluster is already installed when: k3s_installed.stat.exists ansible.builtin.set_fact: k3s_server_manifests_templates: [] k3s_server_manifests_urls: [] - name: Prevent downgrades when: k3s_installed.stat.exists ansible.builtin.include_tasks: tasks/version-check.yaml - name: Ensure that the /opt/cni directory exists ansible.builtin.file: path: /opt/cni mode: '755' state: directory - name: Ensure that the /opt/cni/bin is a link to /var/lib/rancher/k3s/data/current/bin ansible.builtin.file: src: /var/lib/rancher/k3s/data/current/bin dest: /opt/cni/bin follow: false force: true state: link - name: Ensure that the /etc/cni directory exists ansible.builtin.file: path: /etc/cni mode: '755' state: directory - name: Ensure that the /var/lib/rancher/k3s/agent/etc/cni/net.d directory exists ansible.builtin.file: path: /var/lib/rancher/k3s/agent/etc/cni/net.d mode: '755' state: directory - name: Ensure that the /etc/cni/net.d is a link to /var/lib/rancher/k3s/agent/etc/cni/net.d ansible.builtin.file: src: /var/lib/rancher/k3s/agent/etc/cni/net.d dest: /etc/cni/net.d force: true state: link - name: Install Kubernetes ansible.builtin.include_role: name: xanmanning.k3s public: true vars: k3s_state: installed - name: Kubeconfig ansible.builtin.include_tasks: tasks/kubeconfig.yaml - name: Wait for custom manifests to rollout when: - k3s_primary_control_node - (k3s_server_manifests_templates | length > 0 or k3s_server_manifests_urls | length > 0) kubernetes.core.k8s_info: kubeconfig: /etc/rancher/k3s/k3s.yaml kind: "{{ item.kind }}" name: "{{ item.name }}" namespace: "{{ item.namespace | default('') }}" wait: true wait_sleep: 10 wait_timeout: 360 loop: - { name: cilium, kind: HelmChart, namespace: kube-system } - { name: kube-vip, kind: DaemonSet, namespace: kube-system } - name: Cilium when: k3s_primary_control_node ansible.builtin.include_tasks: tasks/cilium.yaml - name: Cruft when: k3s_primary_control_node ansible.builtin.include_tasks: tasks/cruft.yaml