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