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