--- # Drops a HelmChart CR for MetalLB, plus its IPAddressPool/L2Advertisement # config, into k3s's auto-deploying manifests directory; k3s's bundled # helm-controller and deploy controller reconcile them — same mechanism as # roles/k3s_monitoring (see its tasks/main.yml for why this needs no helm # binary or kubeconfig on the controller). # # The config manifest references CRDs that only exist once the HelmChart # above has actually installed the chart, so it's templated in the same # pass rather than gated behind a "wait for CRDs" step: k3s's deploy # controller retries a manifest referencing not-yet-existing CRDs until they # show up, instead of failing once and giving up. - name: Fail fast if no MetalLB address range is configured ansible.builtin.assert: that: - k3s_metallb_address_range | length > 0 fail_msg: >- k3s_metallb_address_range is empty — set it in inventory/group_vars/k3s_cluster.yml before running playbooks/k3s.yml. run_once: true - name: Deploy the MetalLB HelmChart manifest ansible.builtin.template: src: metallb.helmchart.yaml.j2 dest: /var/lib/rancher/k3s/server/manifests/metallb.yaml owner: root group: root mode: "0644" become: true - name: Deploy the MetalLB address pool config ansible.builtin.template: src: metallb-config.yaml.j2 dest: /var/lib/rancher/k3s/server/manifests/metallb-config.yaml owner: root group: root mode: "0644" become: true