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