Fix network restart
In order to apply dhclient hooks, drop network restarting as it is a too heavy operation and may sometimes hang as well. Instead, kill dhclient then refresh resolvconf. This postpones application of changes to dhclient conf and hooks unless it is restarted, eventually. Signed-off-by: Bogdan Dobrelya <bdobrelia@mirantis.com>
This commit is contained in:
parent
e83010b739
commit
537b78da1d
2 changed files with 16 additions and 18 deletions
|
@ -1,10 +1,14 @@
|
||||||
- name: Dnsmasq | restart network
|
- name: Dnsmasq | apply resolvconf
|
||||||
service:
|
command: /bin/true
|
||||||
name: >-
|
notify:
|
||||||
{% if ansible_os_family == "RedHat" -%}
|
- Dnsmasq | kill dhclient
|
||||||
network
|
- Dnsmasq | update resolvconf
|
||||||
{%- elif ansible_os_family == "Debian" -%}
|
|
||||||
networking
|
|
||||||
{%- endif %}
|
|
||||||
state: restarted
|
|
||||||
when: ansible_os_family != "CoreOS"
|
when: ansible_os_family != "CoreOS"
|
||||||
|
|
||||||
|
- name: Dnsmasq | kill dhclient
|
||||||
|
shell: kill -11 $(pidof dhclient)
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Dnsmasq | update resolvconf
|
||||||
|
command: resolvconf -u
|
||||||
|
ignore_errors: true
|
||||||
|
|
|
@ -110,16 +110,10 @@
|
||||||
|
|
||||||
- name: disable resolv.conf modification by dhclient
|
- name: disable resolv.conf modification by dhclient
|
||||||
copy: src=dhclient_nodnsupdate dest=/etc/dhcp/dhclient-enter-hooks.d/znodnsupdate mode=0755
|
copy: src=dhclient_nodnsupdate dest=/etc/dhcp/dhclient-enter-hooks.d/znodnsupdate mode=0755
|
||||||
notify: Dnsmasq | restart network
|
notify: Dnsmasq | apply resolvconf
|
||||||
when: ansible_os_family == "Debian"
|
when: ansible_os_family == "Debian"
|
||||||
|
|
||||||
- name: disable resolv.conf modification by dhclient
|
- name: disable resolv.conf modification by dhclient
|
||||||
copy: src=dhclient_nodnsupdate dest=/etc/dhcp/dhclient.d/nodnsupdate mode=u+x
|
copy: src=dhclient_nodnsupdate dest=/etc/dhcp/dhclient.d/znodnsupdate mode=u+x
|
||||||
|
notify: Dnsmasq | apply resolvconf
|
||||||
when: ansible_os_family == "RedHat"
|
when: ansible_os_family == "RedHat"
|
||||||
|
|
||||||
- name: update resolvconf
|
|
||||||
command: resolvconf -u
|
|
||||||
changed_when: False
|
|
||||||
when: resolvconf.rc == 0
|
|
||||||
|
|
||||||
- meta: flush_handlers
|
|
||||||
|
|
Loading…
Reference in a new issue