From 4185592f6dbbd1920347bdaac9261b300db299b1 Mon Sep 17 00:00:00 2001 From: Anderson Vinicius <andersonvaf@gmail.com> Date: Wed, 29 Sep 2021 18:29:05 -0300 Subject: [PATCH] Bugfix: on Debian, when restart_all_nic parameter is set to false it will restart the interface if it has a configuration change --- manifests/init.pp | 3 +-- manifests/interface.pp | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 9333bc4..3156e88 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -310,9 +310,8 @@ class network ( } # Command that triggers network restart - exec { $service_restart_exec : + exec { 'network_restart' : command => $service_restart_exec, - alias => 'network_restart', refreshonly => true, path => '/bin:/sbin:/usr/bin:/usr/sbin', } diff --git a/manifests/interface.pp b/manifests/interface.pp index fd0cd3e..2de043b 100644 --- a/manifests/interface.pp +++ b/manifests/interface.pp @@ -759,10 +759,9 @@ define network::interface ( } else { if ! defined(Concat['/etc/network/interfaces']) { concat { '/etc/network/interfaces': - mode => '0644', - owner => 'root', - group => 'root', - notify => $network_notify, + mode => '0644', + owner => 'root', + group => 'root', } } @@ -772,13 +771,19 @@ define network::interface ( order => $manage_order, } + if $restart_all_nic == true and $network::manage_config_file_notify != undef { + Concat['/etc/network/interfaces'] ~> Exec['network_restart'] + } else { + Concat['/etc/network/interfaces'] ~> Exec <| title == "network_restart_${name}" |> + } } if ! defined(Network::Interface['lo']) { network::interface { 'lo': - address => '127.0.0.1', - method => 'loopback', - manage_order => '05', + address => '127.0.0.1', + method => 'loopback', + manage_order => '05', + restart_all_nic => $restart_all_nic, } } } -- GitLab