--- - name: Write dhcpcd configuration ansible.builtin.copy: dest: /mnt/etc/dhcpcd.conf mode: "0644" content: | {% for iface in system_cfg.network.interfaces %} {% set inv_name = iface.name | default('') | string %} {% set det_name = configuration_detected_interfaces[loop.index0] | default('eth' ~ loop.index0) %} {% set iface_name = inv_name if inv_name | length > 0 else det_name %} {% set has_static = (iface.ip | default('') | string | length) > 0 %} {% if has_static %} interface {{ iface_name }} static ip_address={{ iface.ip }}/{{ iface.prefix }} {% if iface.gateway | default('') | string | length %} static routers={{ iface.gateway }} {% endif %} {% if loop.index0 == 0 and configuration_dns_list | length > 0 %} static domain_name_servers={{ configuration_dns_list | join(' ') }} {% endif %} {% if loop.index0 == 0 and configuration_dns_search | length > 0 %} static domain_search={{ configuration_dns_search | join(' ') }} {% endif %} {% endif %} {% endfor %}