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:
Bogdan Dobrelya 2016-08-29 16:39:55 +02:00
parent e83010b739
commit 537b78da1d
2 changed files with 16 additions and 18 deletions

View file

@ -1,10 +1,14 @@
- name: Dnsmasq | restart network
service:
name: >-
{% if ansible_os_family == "RedHat" -%}
network
{%- elif ansible_os_family == "Debian" -%}
networking
{%- endif %}
state: restarted
- name: Dnsmasq | apply resolvconf
command: /bin/true
notify:
- Dnsmasq | kill dhclient
- Dnsmasq | update resolvconf
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

View file

@ -110,16 +110,10 @@
- name: disable resolv.conf modification by dhclient
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"
- 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"
- name: update resolvconf
command: resolvconf -u
changed_when: False
when: resolvconf.rc == 0
- meta: flush_handlers