---
- name: NetworkManager | Add nameservers to NM configuration
  ini_file:
    path: /etc/NetworkManager/conf.d/dns.conf
    section: global-dns-domain-*
    option: servers
    value: "{{ nameserverentries }}"
    mode: '0600'
    backup: yes
  notify: Preinstall | update resolvconf for networkmanager

- name: NetworkManager | Add DNS search to NM configuration
  ini_file:
    path: /etc/NetworkManager/conf.d/dns.conf
    section: global-dns
    option: searches
    value: "{{ ([ 'default.svc.' + dns_domain, 'svc.' + dns_domain ] + searchdomains|default([])) | join(',') }}"
    mode: '0600'
    backup: yes
  notify: Preinstall | update resolvconf for networkmanager

- name: NetworkManager | Add DNS options to NM configuration
  ini_file:
    path: /etc/NetworkManager/conf.d/dns.conf
    section: global-dns
    option: options
    value: "ndots:{{ ndots }};timeout:2;attempts:2;"
    mode: '0600'
    backup: yes
  notify: Preinstall | update resolvconf for networkmanager
