Refactor "multi" handlers to use listen (#10542)

* containerd: refactor handlers to use 'listen'

* cri-dockerd: refactor handlers to use 'listen'

* cri-o: refactor handlers to use 'listen'

* docker: refactor handlers to use 'listen'

* etcd: refactor handlers to use 'listen'

* control-plane: refactor handlers to use 'listen'

* kubeadm: refactor handlers to use 'listen'

* node: refactor handlers to use 'listen'

* preinstall: refactor handlers to use 'listen'

* calico: refactor handlers to use 'listen'

* kube-router: refactor handlers to use 'listen'

* macvlan: refactor handlers to use 'listen'
This commit is contained in:
Max Gautier
2023-11-08 12:28:30 +01:00
committed by GitHub
parent c9d685833b
commit 8ebeb88e57
14 changed files with 85 additions and 158 deletions

View File

@@ -1,16 +1,10 @@
---
- name: Reset_calico_cni
command: /bin/true
when: calico_cni_config is defined
notify:
- Delete 10-calico.conflist
- Calico | delete calico-node docker containers
- Calico | delete calico-node crio/containerd containers
- name: Delete 10-calico.conflist
file:
path: /etc/cni/net.d/10-calico.conflist
state: absent
listen: Reset_calico_cni
when: calico_cni_config is defined
- name: Calico | delete calico-node docker containers
shell: "set -o pipefail && {{ docker_bin_dir }}/docker ps -af name=k8s_POD_calico-node* -q | xargs --no-run-if-empty {{ docker_bin_dir }}/docker rm -f"
@@ -19,7 +13,10 @@
register: docker_calico_node_remove
until: docker_calico_node_remove is succeeded
retries: 5
when: container_manager in ["docker"]
when:
- container_manager in ["docker"]
- calico_cni_config is defined
listen: Reset_calico_cni
- name: Calico | delete calico-node crio/containerd containers
shell: 'set -o pipefail && {{ bin_dir }}/crictl pods --name calico-node-* -q | xargs -I% --no-run-if-empty bash -c "{{ bin_dir }}/crictl stopp % && {{ bin_dir }}/crictl rmp %"'
@@ -28,4 +25,7 @@
register: crictl_calico_node_remove
until: crictl_calico_node_remove is succeeded
retries: 5
when: container_manager in ["crio", "containerd"]
when:
- container_manager in ["crio", "containerd"]
- calico_cni_config is defined
listen: Reset_calico_cni

View File

@@ -1,10 +1,4 @@
---
- name: Reset_kube_router
command: /bin/true
notify:
- Kube-router | delete kube-router docker containers
- Kube-router | delete kube-router crio/containerd containers
- name: Kube-router | delete kube-router docker containers
shell: "set -o pipefail && {{ docker_bin_dir }}/docker ps -af name=k8s_POD_kube-router* -q | xargs --no-run-if-empty docker rm -f"
args:
@@ -13,6 +7,7 @@
until: docker_kube_router_remove is succeeded
retries: 5
when: container_manager in ["docker"]
listen: Reset_kube_router
- name: Kube-router | delete kube-router crio/containerd containers
shell: 'set -o pipefail && {{ bin_dir }}/crictl pods --name kube-router* -q | xargs -I% --no-run-if-empty bash -c "{{ bin_dir }}/crictl stopp % && {{ bin_dir }}/crictl rmp %"'
@@ -22,3 +17,4 @@
until: crictl_kube_router_remove is succeeded
retries: 5
when: container_manager in ["crio", "containerd"]
listen: Reset_kube_router

View File

@@ -1,10 +1,4 @@
---
- name: Macvlan | restart network
command: /bin/true
notify:
- Macvlan | reload network
when: not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
- name: Macvlan | reload network
service:
# noqa: jinja[spacing]
@@ -18,3 +12,4 @@
{%- endif %}
state: restarted
when: not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"] and kube_network_plugin not in ['calico']
listen: Macvlan | restart network