ad9e5f
From ffa647e83efd4293bd027e9e390274aad8a12d94 Mon Sep 17 00:00:00 2001
c1c26e
From: Eduardo Otubo <otubo@redhat.com>
fc6e82
Date: Fri, 7 May 2021 13:36:13 +0200
c1c26e
Subject: include 'NOZEROCONF=yes' in /etc/sysconfig/network
c1c26e
c1c26e
RH-Author: Eduardo Otubo <otubo@redhat.com>
c1c26e
Message-id: <20190320114559.23708-1-otubo@redhat.com>
c1c26e
Patchwork-id: 84937
c1c26e
O-Subject: [RHEL-7.7 cloud-init PATCH] include 'NOZEROCONF=yes' in /etc/sysconfig/network
c1c26e
Bugzilla: 1653131
c1c26e
RH-Acked-by: Cathy Avery <cavery@redhat.com>
c1c26e
RH-Acked-by: Mohammed Gamal <mgamal@redhat.com>
c1c26e
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
c1c26e
c1c26e
The option NOZEROCONF=yes is not included by default in
c1c26e
/etc/sysconfig/network, which is required by Overcloud instances. The
c1c26e
patch also includes tests for the modifications.
c1c26e
c1c26e
X-downstream-only: yes
c1c26e
Resolves: rhbz#1653131
c1c26e
c1c26e
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
c1c26e
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
c1c26e
---
ad9e5f
 cloudinit/net/sysconfig.py | 11 ++++++++++-
ad9e5f
 1 file changed, 10 insertions(+), 1 deletion(-)
c1c26e
c1c26e
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
ad9e5f
index e06ddee7..362e8d19 100644
c1c26e
--- a/cloudinit/net/sysconfig.py
c1c26e
+++ b/cloudinit/net/sysconfig.py
ad9e5f
@@ -1038,7 +1038,16 @@ class Renderer(renderer.Renderer):
c1c26e
         # Distros configuring /etc/sysconfig/network as a file e.g. Centos
ad9e5f
         if sysconfig_path.endswith("network"):
c1c26e
             util.ensure_dir(os.path.dirname(sysconfig_path))
ad9e5f
-            netcfg = [_make_header(), "NETWORKING=yes"]
c1c26e
+            netcfg = []
ad9e5f
+            for line in util.load_file(sysconfig_path, quiet=True).split("\n"):
ad9e5f
+                if "cloud-init" in line:
c1c26e
+                    break
ad9e5f
+                if not line.startswith(("NETWORKING=",
ad9e5f
+                                        "IPV6_AUTOCONF=",
ad9e5f
+                                        "NETWORKING_IPV6=")):
c1c26e
+                    netcfg.append(line)
c1c26e
+            # Now generate the cloud-init portion of sysconfig/network
ad9e5f
+            netcfg.extend([_make_header(), "NETWORKING=yes"])
c1c26e
             if network_state.use_ipv6:
ad9e5f
                 netcfg.append("NETWORKING_IPV6=yes")
ad9e5f
                 netcfg.append("IPV6_AUTOCONF=no")
c1c26e
-- 
ad9e5f
2.31.1
c1c26e