From a81c6d5448fc66ee4aed786eedb820179ab6022d Mon Sep 17 00:00:00 2001 From: Romain <58464216+RomainMou@users.noreply.github.com> Date: Wed, 20 Sep 2023 11:28:01 +0200 Subject: [PATCH] Add a way to configure reseted networking service name. (#10428) --- roles/reset/defaults/main.yml | 15 +++++++++++++++ roles/reset/tasks/main.yml | 14 +------------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/roles/reset/defaults/main.yml b/roles/reset/defaults/main.yml index e45cee42e..3d58dd91b 100644 --- a/roles/reset/defaults/main.yml +++ b/roles/reset/defaults/main.yml @@ -1,3 +1,18 @@ --- flush_iptables: true reset_restart_network: true + +reset_restart_network_service_name: >- + {% if ansible_os_family == "RedHat" -%} + {%- + if ansible_distribution_major_version | int >= 8 + or is_fedora_coreos or ansible_distribution == "Fedora" -%} + NetworkManager + {%- else -%} + network + {%- endif -%} + {%- elif ansible_distribution == "Ubuntu" -%} + systemd-networkd + {%- elif ansible_os_family == "Debian" -%} + networking + {%- endif %} diff --git a/roles/reset/tasks/main.yml b/roles/reset/tasks/main.yml index ae74473ea..198b2c490 100644 --- a/roles/reset/tasks/main.yml +++ b/roles/reset/tasks/main.yml @@ -429,19 +429,7 @@ - name: Reset | Restart network service: - # noqa: jinja[spacing] - name: >- - {% if ansible_os_family == "RedHat" -%} - {%- if ansible_distribution_major_version | int >= 8 or is_fedora_coreos or ansible_distribution == "Fedora" -%} - NetworkManager - {%- else -%} - network - {%- endif -%} - {%- elif ansible_distribution == "Ubuntu" -%} - systemd-networkd - {%- elif ansible_os_family == "Debian" -%} - networking - {%- endif %} + name: "{{ reset_restart_network_service_name }}" state: restarted when: - ansible_os_family not in ["Flatcar", "Flatcar Container Linux by Kinvolk"]