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