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