---
- name: NetworkManager | Add nameservers to NM configuration
  ini_file:
    path: /etc/NetworkManager/system-connections/default_connection.nmconnection
    section: ipv4
    option: dns
    value: "{{ ( coredns_server + nameservers|d([]) + cloud_resolver|d([])) | unique | join(';') }}"
    mode: '0600'
    backup: yes
  notify: Preinstall | update resolvconf for Fedora CoreOS

- name: NetworkManager | Add DNS search to NM configuration
  ini_file:
    path: /etc/NetworkManager/system-connections/default_connection.nmconnection
    section: ipv4
    option: dns-search
    value: "{{ ([ 'default.svc.' + dns_domain, 'svc.' + dns_domain ] + searchdomains|default([])) | join(';') }}"
    mode: '0600'
    backup: yes
  notify: Preinstall | update resolvconf for Fedora CoreOS

- name: NetworkManager | Add DNS options to NM configuration
  ini_file:
    path: /etc/NetworkManager/system-connections/default_connection.nmconnection
    section: ipv4
    option: dns-options
    value: "ndots:{{ ndots }};timeout:2;attempts:2;"
    mode: '0600'
    backup: yes
  notify: Preinstall | update resolvconf for Fedora CoreOS

- name: NetworkManager | Ignore DNS auto configuration
  ini_file:
    path: /etc/NetworkManager/system-connections/default_connection.nmconnection
    section: ipv4
    option: ignore-auto-dns
    value: 'true'
    mode: '0600'
    backup: yes
  notify: Preinstall | update resolvconf for Fedora CoreOS
