summaryrefslogtreecommitdiffstats
path: root/xci/playbooks/roles/configure-network
diff options
context:
space:
mode:
authorMarkos Chandras <mchandras@suse.de>2018-03-08 19:51:51 +0000
committerMarkos Chandras <mchandras@suse.de>2018-03-09 14:00:52 +0000
commita40badcb175a6be138985ff17de06198097a5b16 (patch)
tree2a468bc9291f9b204778c452f23181b50b3a1fcf /xci/playbooks/roles/configure-network
parent20b01a6b7163971201a5aa0d6db354d80657d17f (diff)
xci: roles: configure-network: Wait for connection when configuring the network
Ansible some times loses connection with the host after we configure its network interface. This shouldn't happen since the host is actually up and running. As a result of which, we need to fire-and-forget the restart of the network service and then try to reach the SSH port. We also need to make sure that all required packages are installed. Finally, we drop the 'ignore_errors' parameter since we really need to know when the networking configuration has failed. Change-Id: I366192737b5c4e01964eaf187396eababbdc808e Signed-off-by: Markos Chandras <mchandras@suse.de>
Diffstat (limited to 'xci/playbooks/roles/configure-network')
-rw-r--r--xci/playbooks/roles/configure-network/tasks/main.yml41
1 files changed, 35 insertions, 6 deletions
diff --git a/xci/playbooks/roles/configure-network/tasks/main.yml b/xci/playbooks/roles/configure-network/tasks/main.yml
index adcb8669..21f213cb 100644
--- a/xci/playbooks/roles/configure-network/tasks/main.yml
+++ b/xci/playbooks/roles/configure-network/tasks/main.yml
@@ -12,6 +12,19 @@
path: "/etc/udev/rules.d/99-glean.rules"
state: absent
+- name: Determine required packages
+ set_fact:
+ network_packages:
+ - bridge-utils
+ - "{{ (ansible_pkg_mgr in ['zypper', 'apt']) | ternary('iproute2', 'iproute') }}"
+ - "{{ (ansible_pkg_mgr == 'apt') | ternary('vlan', '') }}"
+ - iptables
+
+- name: Ensure networking packages are present
+ package:
+ name: "{{ network_packages }}"
+ state: present
+
- block:
- name: configure modules
lineinfile:
@@ -31,6 +44,8 @@
dest: "/etc/network/interfaces"
- name: restart network service
shell: "/sbin/ifconfig {{ ansible_default_ipv4.interface }} 0 && /sbin/ifdown -a && /sbin/ifup -a"
+ async: 15
+ poll: 0
when: ansible_os_family | lower == "debian"
- block:
@@ -68,9 +83,12 @@
dest: "/etc/sysconfig/network/ifroute-{{ item.name }}"
with_items:
- { name: "br-vlan", gateway: "192.168.122.1", route: "default" }
-
- name: restart network service
- shell: "/usr/sbin/wicked ifreload all"
+ service:
+ name: network
+ state: restarted
+ async: 15
+ poll: 0
when: ansible_os_family | lower == "suse"
- block:
@@ -96,8 +114,19 @@
lineinfile:
path: "/etc/sysconfig/network-scripts/ifcfg-br-vlan"
line: "GATEWAY=192.168.122.1"
- - name: Restart networking
- command: "systemctl restart network"
- - name: wait for the server to come back
- wait_for_connection:
+ - name: restart network service
+ service:
+ name: network
+ state: restarted
+ async: 15
+ poll: 0
when: ansible_os_family | lower == "redhat"
+
+- local_action:
+ module: wait_for
+ host: "{{ ansible_host }}"
+ delay: 15
+ state: started
+ port: 22
+ connect_timeout: 10
+ timeout: 180