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"]