From cf9e4121f61fe3fbeaa4cd89951d26c6225ce990 Mon Sep 17 00:00:00 2001 From: Radek Zajic Date: Tue, 5 May 2020 13:50:36 +0200 Subject: [PATCH] Debian: avoid misconfigured interfaces on up/down script errors In Debian, if you bring up dual-stack interfaces, the pre/post-up/down scripts are run on the configuration of each stack. I.e. if you bring up the IPv4 config on an interface, the ifupdown scripts launch scripts in the post-up directory. These scripts are common for IPv4 and IPv6 in current version of puppet-network. At the moment IPv6 is not yet configured, but IPv6 commands are called - and fail. If an IPv6 command (e.g. `ip -6 route add`) is the last one in the post-up script, the overall post-up script fails. When the post-up script fails when bringing up the IPv4 configuration, ifupdown no longer attempts to bring up the IPv6 configuration on that interface and leaves the interface misconfigured (IPv4 is configured, IPv6 is not). This situation can be avoided by adding the `exit 0` command at the very end of the script files. It is okay if the IPv6 commands in the common script fail when only IPv4 is brought up, as ifupdown will re-run them after IPv6 is brought up. --- templates/interface/Debian.erb | 1 + templates/route_down-Debian.erb | 2 ++ templates/route_up-Debian.erb | 2 ++ templates/rule_down-Debian.erb | 2 ++ templates/rule_up-Debian.erb | 2 ++ 5 files changed, 9 insertions(+) diff --git a/templates/interface/Debian.erb b/templates/interface/Debian.erb index 6c2b3e3..2aebec2 100644 --- a/templates/interface/Debian.erb +++ b/templates/interface/Debian.erb @@ -1,3 +1,4 @@ +# File Managed by Puppet # Interface <%= @name %> <% if @description and ! @description.empty? -%> # <%= @description %> diff --git a/templates/route_down-Debian.erb b/templates/route_down-Debian.erb index 7c06013..f4f4301 100644 --- a/templates/route_down-Debian.erb +++ b/templates/route_down-Debian.erb @@ -10,3 +10,5 @@ if [ "$IFACE" = "<%= @interface -%>" ] || [ "$IFACE" = "--all" ]; then fi <%- end -%> fi +# non-zero exit code causes ifupdown to leave the interface partly configured, which may result in connectivity loss +exit 0 diff --git a/templates/route_up-Debian.erb b/templates/route_up-Debian.erb index 7dcfbc0..c4733c6 100644 --- a/templates/route_up-Debian.erb +++ b/templates/route_up-Debian.erb @@ -10,3 +10,5 @@ if [ "$IFACE" = "<%= @interface -%>" ] || [ "$IFACE" = "--all" ]; then fi <%- end -%> fi +# non-zero exit code causes ifupdown to leave the interface partly configured, which may result in connectivity loss +exit 0 diff --git a/templates/rule_down-Debian.erb b/templates/rule_down-Debian.erb index 20e6b15..26fa6dd 100644 --- a/templates/rule_down-Debian.erb +++ b/templates/rule_down-Debian.erb @@ -10,3 +10,5 @@ if [ "$IFACE" = "<%= @interface -%>" ] || [ "$IFACE" = "--all" ]; then fi <%- end -%> fi +# non-zero exit code causes ifupdown to leave the interface partly configured, which may result in connectivity loss +exit 0 diff --git a/templates/rule_up-Debian.erb b/templates/rule_up-Debian.erb index 0ba92be..f1f1626 100644 --- a/templates/rule_up-Debian.erb +++ b/templates/rule_up-Debian.erb @@ -10,3 +10,5 @@ if [ "$IFACE" = "<%= @interface -%>" ] || [ "$IFACE" = "--all" ]; then fi <%- end -%> fi +# non-zero exit code causes ifupdown to leave the interface partly configured, which may result in connectivity loss +exit 0