2b0ae0
From 9c6562c6d3516df8d11aa7cf7cd9cc62e5c91a70 Mon Sep 17 00:00:00 2001
2b0ae0
From: Eduardo Otubo <otubo@redhat.com>
2b0ae0
Date: Mon, 5 Oct 2020 13:51:37 +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
2b0ae0
index f3c6452..1c214db 100755
18322d
--- a/cloudinit/sources/DataSourceAzure.py
18322d
+++ b/cloudinit/sources/DataSourceAzure.py
2b0ae0
@@ -258,7 +258,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
-- 
8a7340
1.8.3.1
18322d