Use NetworkManager to manage resolv.conf in FedoraCoreOS (#6291)

This commit is contained in:
bozzo 2020-06-29 09:26:17 +02:00 committed by GitHub
parent 56f389a9f3
commit 09b23f96d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 66 additions and 5 deletions

View file

@ -16,11 +16,22 @@
notify: notify:
- Preinstall | apply resolvconf cloud-init - Preinstall | apply resolvconf cloud-init
- Preinstall | reload kubelet - Preinstall | reload kubelet
when: ansible_os_family in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"] or is_fedora_coreos when: ansible_os_family in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"]
- name: Preinstall | apply resolvconf cloud-init - name: Preinstall | apply resolvconf cloud-init
command: /usr/bin/coreos-cloudinit --from-file {{ resolveconf_cloud_init_conf }} command: /usr/bin/coreos-cloudinit --from-file {{ resolveconf_cloud_init_conf }}
when: ansible_os_family in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"] or is_fedora_coreos when: ansible_os_family in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"]
- name: Preinstall | update resolvconf for Fedora CoreOS
command: /bin/true
notify:
- Preinstall | reload NetworkManager
- Preinstall | reload kubelet
when: is_fedora_coreos
- name: Preinstall | reload NetworkManager
command: systemctl restart NetworkManager.service
when: is_fedora_coreos
- name: Preinstall | reload kubelet - name: Preinstall | reload kubelet
service: service:

View file

@ -1,7 +1,7 @@
--- ---
- name: create temporary resolveconf cloud init file - name: create temporary resolveconf cloud init file
command: cp -f /etc/resolv.conf "{{ resolvconffile }}" command: cp -f /etc/resolv.conf "{{ resolvconffile }}"
when: ansible_os_family in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"] or is_fedora_coreos when: ansible_os_family in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"]
- name: Add domain/search/nameservers/options to resolv.conf - name: Add domain/search/nameservers/options to resolv.conf
blockinfile: blockinfile:
@ -47,7 +47,7 @@
- name: get temporary resolveconf cloud init file content - name: get temporary resolveconf cloud init file content
command: cat {{ resolvconffile }} command: cat {{ resolvconffile }}
register: cloud_config register: cloud_config
when: ansible_os_family in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"] or is_fedora_coreos when: ansible_os_family in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"]
- name: persist resolvconf cloud init file - name: persist resolvconf cloud init file
template: template:
@ -56,4 +56,4 @@
owner: root owner: root
mode: 0644 mode: 0644
notify: Preinstall | update resolvconf for Container Linux by CoreOS and Flatcar notify: Preinstall | update resolvconf for Container Linux by CoreOS and Flatcar
when: ansible_os_family in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"] or is_fedora_coreos when: ansible_os_family in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"]

View file

@ -0,0 +1,40 @@
---
- 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

View file

@ -33,6 +33,7 @@
- dns_mode != 'none' - dns_mode != 'none'
- resolvconf_mode == 'host_resolvconf' - resolvconf_mode == 'host_resolvconf'
- systemd_resolved_enabled.rc != 0 - systemd_resolved_enabled.rc != 0
- not is_fedora_coreos
tags: tags:
- bootstrap-os - bootstrap-os
- resolvconf - resolvconf
@ -46,6 +47,15 @@
- bootstrap-os - bootstrap-os
- resolvconf - resolvconf
- import_tasks: 0062-networkmanager.yml
when:
- dns_mode != 'none'
- resolvconf_mode == 'host_resolvconf'
- is_fedora_coreos
tags:
- bootstrap-os
- resolvconf
- import_tasks: 0070-system-packages.yml - import_tasks: 0070-system-packages.yml
when: when:
- not dns_late - not dns_late