Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use NetworkManager to manage resolv.conf for Fedora CoreOS #6291

Merged
merged 1 commit into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions roles/kubernetes/preinstall/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,22 @@
notify:
- Preinstall | apply resolvconf cloud-init
- 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
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
service:
Expand Down
6 changes: 3 additions & 3 deletions roles/kubernetes/preinstall/tasks/0060-resolvconf.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: create temporary resolveconf cloud init file
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
blockinfile:
Expand Down Expand Up @@ -47,7 +47,7 @@
- name: get temporary resolveconf cloud init file content
command: cat {{ resolvconffile }}
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
template:
Expand All @@ -56,4 +56,4 @@
owner: root
mode: 0644
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"]
40 changes: 40 additions & 0 deletions roles/kubernetes/preinstall/tasks/0062-networkmanager.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions roles/kubernetes/preinstall/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- dns_mode != 'none'
- resolvconf_mode == 'host_resolvconf'
- systemd_resolved_enabled.rc != 0
- not is_fedora_coreos
tags:
- bootstrap-os
- resolvconf
Expand All @@ -46,6 +47,15 @@
- bootstrap-os
- 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
when:
- not dns_late
Expand Down