bb836b
From ccc75c1be3ae08d813193071c798fc905b5c03e5 Mon Sep 17 00:00:00 2001
2b0ae0
From: Eduardo Otubo <otubo@redhat.com>
bb836b
Date: Fri, 7 May 2021 13:36:12 +0200
18322d
Subject: DataSourceAzure.py: use hostnamectl to set hostname
18322d
18322d
RH-Author: Vitaly Kuznetsov <vkuznets@redhat.com>
18322d
Message-id: <20180417130754.12918-3-vkuznets@redhat.com>
18322d
Patchwork-id: 79659
18322d
O-Subject: [RHEL7.6/7.5.z cloud-init PATCH 2/2] DataSourceAzure.py: use hostnamectl to set hostname
18322d
Bugzilla: 1568717
18322d
RH-Acked-by: Eduardo Otubo <otubo@redhat.com>
18322d
RH-Acked-by: Mohammed Gamal <mgamal@redhat.com>
18322d
RH-Acked-by: Cathy Avery <cavery@redhat.com>
18322d
18322d
The right way to set hostname in RHEL7 is:
18322d
18322d
 $ hostnamectl set-hostname HOSTNAME
18322d
18322d
DataSourceAzure, however, uses:
18322d
 $ hostname HOSTSNAME
18322d
18322d
instead and this causes problems. We can't simply change
18322d
'BUILTIN_DS_CONFIG' in DataSourceAzure.py as 'hostname' is being used
18322d
for both getting and setting the hostname.
18322d
18322d
Long term, this should be fixed in a different way. Cloud-init
18322d
has distro-specific hostname setting/getting (see
18322d
cloudinit/distros/rhel.py) and DataSourceAzure.py needs to be switched
18322d
to use these.
18322d
18322d
Resolves: rhbz#1434109
18322d
18322d
X-downstream-only: yes
18322d
2b0ae0
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
18322d
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
18322d
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
18322d
---
18322d
 cloudinit/sources/DataSourceAzure.py | 2 +-
18322d
 1 file changed, 1 insertion(+), 1 deletion(-)
18322d
18322d
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
bb836b
index cee630f7..553b5a7e 100755
18322d
--- a/cloudinit/sources/DataSourceAzure.py
18322d
+++ b/cloudinit/sources/DataSourceAzure.py
bb836b
@@ -296,7 +296,7 @@ def get_hostname(hostname_command='hostname'):
18322d
 
18322d
 
18322d
 def set_hostname(hostname, hostname_command='hostname'):
2b0ae0
-    subp.subp([hostname_command, hostname])
18322d
+    util.subp(['hostnamectl', 'set-hostname', str(hostname)])
18322d
 
18322d
 
8a7340
 @azure_ds_telemetry_reporter
18322d
-- 
bb836b
2.27.0
18322d