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