8a7340
From 9a09efb49c2d7cade1f0ac309293166c3c2d8d7b Mon Sep 17 00:00:00 2001
18322d
From: Vitaly Kuznetsov <vkuznets@redhat.com>
18322d
Date: Tue, 17 Apr 2018 13:07:54 +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
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
8a7340
index 24f448c..6fb889c 100755
18322d
--- a/cloudinit/sources/DataSourceAzure.py
18322d
+++ b/cloudinit/sources/DataSourceAzure.py
8a7340
@@ -256,7 +256,7 @@ def get_hostname(hostname_command='hostname'):
18322d
 
18322d
 
18322d
 def set_hostname(hostname, hostname_command='hostname'):
18322d
-    util.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