From e2ac75cf989a1c3e51806c835f4f4603dc91bbe1 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Mon, 29 Aug 2016 16:39:55 +0200 Subject: [PATCH] Fix network restart Restart network breaks ansible ssh workers. Fire and forget async network restart and wait for it. Add update resolvconf to the network restart handler to ensure changes applied to the /etc/resolv.conf. Signed-off-by: Bogdan Dobrelya --- roles/dnsmasq/handlers/main.yml | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/roles/dnsmasq/handlers/main.yml b/roles/dnsmasq/handlers/main.yml index 95cd80cfc..ff66e5e22 100644 --- a/roles/dnsmasq/handlers/main.yml +++ b/roles/dnsmasq/handlers/main.yml @@ -1,4 +1,14 @@ - name: Dnsmasq | restart network + command: /bin/true + notify: + - Dnsmasq | reload network + - Dnsmasq | Wait for network reloaded + - Dnsmasq | update resolvconf + when: ansible_os_family != "CoreOS" + +- name: Dnsmasq | reload network + vars: + ansible_ssh_pipelining: yes service: name: >- {% if ansible_os_family == "RedHat" -%} @@ -7,4 +17,19 @@ networking {%- endif %} state: restarted - when: ansible_os_family != "CoreOS" + register: network_runner + async: 600 + poll: 0 + +- name: Dnsmasq | Wait for network reloaded + vars: + ansible_ssh_pipelining: yes + async_status: jid={{ network_runner.ansible_job_id }} + register: network_jobs + until: network_jobs.finished + retries: 60 + delay: 10 + +- name: Dnsmasq | update resolvconf + command: /sbin/resolvconf -u + ignore_errors: true