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