From 7f16b46ed50204d1697af23b6a06721fb64ebfae Mon Sep 17 00:00:00 2001 From: Erwan Miran Date: Thu, 16 Aug 2018 17:34:33 +0200 Subject: [PATCH] Reset tasks specific to a network_plugin moved inside its role directory + Reset tasks specific to cilium --- roles/network_plugin/cilium/tasks/reset.yml | 9 ++++++ .../cilium/tasks/reset_iface.yml | 9 ++++++ roles/network_plugin/flannel/tasks/reset.yml | 18 +++++++++++ roles/reset/tasks/main.yml | 30 +++---------------- 4 files changed, 40 insertions(+), 26 deletions(-) create mode 100644 roles/network_plugin/cilium/tasks/reset.yml create mode 100644 roles/network_plugin/cilium/tasks/reset_iface.yml create mode 100644 roles/network_plugin/flannel/tasks/reset.yml diff --git a/roles/network_plugin/cilium/tasks/reset.yml b/roles/network_plugin/cilium/tasks/reset.yml new file mode 100644 index 000000000..65b6e9a78 --- /dev/null +++ b/roles/network_plugin/cilium/tasks/reset.yml @@ -0,0 +1,9 @@ +--- +- name: reset | check and remove devices if still present + include_tasks: reset_iface.yml + vars: + iface: "{{ item }}" + with_items: + - cilium_host + - cilium_net + - cilium_vxlan diff --git a/roles/network_plugin/cilium/tasks/reset_iface.yml b/roles/network_plugin/cilium/tasks/reset_iface.yml new file mode 100644 index 000000000..d4a5aad90 --- /dev/null +++ b/roles/network_plugin/cilium/tasks/reset_iface.yml @@ -0,0 +1,9 @@ +--- +- name: "reset | check if network device {{ iface }} is present" + stat: + path: "/sys/class/net/{{ iface }}" + register: device_remains + +- name: "reset | remove network device {{ iface }}" + command: "ip link del {{ iface }}" + when: device_remains.stat.exists diff --git a/roles/network_plugin/flannel/tasks/reset.yml b/roles/network_plugin/flannel/tasks/reset.yml new file mode 100644 index 000000000..b2777b4ef --- /dev/null +++ b/roles/network_plugin/flannel/tasks/reset.yml @@ -0,0 +1,18 @@ +--- +- name: reset | check cni network device + stat: + path: /sys/class/net/cni0 + register: cni + +- name: reset | remove the network device created by the flannel + command: ip link del cni0 + when: cni.stat.exists + +- name: reset | check flannel network device + stat: + path: /sys/class/net/flannel.1 + register: flannel + +- name: reset | remove the network device created by the flannel + command: ip link del flannel.1 + when: flannel.stat.exists diff --git a/roles/reset/tasks/main.yml b/roles/reset/tasks/main.yml index f190dbee8..85977d1f2 100644 --- a/roles/reset/tasks/main.yml +++ b/roles/reset/tasks/main.yml @@ -167,33 +167,11 @@ - files - dns -- name: reset | check cni network device - stat: - path: /sys/class/net/cni0 - register: cni - when: kube_network_plugin == 'flannel' +- name: reset | include file with reset tasks specific to the network_plugin if exists + include_tasks: "{{ (role_path + '/../network_plugin/' + kube_network_plugin + '/tasks/reset.yml') | realpath }}" + when: kube_network_plugin in ['flannel', 'cilium'] tags: - - flannel - -- name: reset | remove the network device created by the flannel - command: ip link del cni0 - when: kube_network_plugin == 'flannel' and cni.stat.exists - tags: - - flannel - -- name: reset | check flannel network device - stat: - path: /sys/class/net/flannel.1 - register: flannel - when: kube_network_plugin == 'flannel' - tags: - - flannel - -- name: reset | remove the network device created by the flannel - command: ip link del flannel.1 - when: kube_network_plugin == 'flannel' and flannel.stat.exists - tags: - - flannel + - network - name: reset | Restart network service: