--- # Annotate each worker node with its Longhorn disk config BEFORE helm install. # Longhorn reads node.longhorn.io/default-disks-config on first node discovery # and automatically registers the listed mountpoints as storage disks. - name: Annotate | Set Longhorn disk config on worker nodes ansible.builtin.command: argv: - kubectl - annotate - node - "{{ item }}" - node.longhorn.io/create-default-disk=config - "node.longhorn.io/default-disks-config={{ _disk_config }}" - --overwrite vars: _disk_config: >- {{ '[' + (hostvars[item].longhorn_disks | map(attribute='mountpoint') | map('regex_replace', '(.+)', '{"path":"\1","allowScheduling":true,"diskType":"filesystem"}') | list | join(',')) + ']' }} environment: KUBECONFIG: "{{ longhorn_kubeconfig }}" PATH: "/usr/local/bin:/usr/bin:/bin" loop: "{{ groups['workers'] }}" register: _annotate changed_when: "'annotated' in _annotate.stdout" failed_when: _annotate.rc != 0