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