From 79a2e586fed0fc6cfe6ec2d2b4c080885c110b34 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Tue, 16 Sep 2014 09:53:13 -0700 Subject: [PATCH] Make systemd vs rht detection more robust for centos Centos 6.x and below use an old RHT style of configuring hostname. CentOS 7.x and better use systemd. Instead of depending on the distribution string which seems to have changed over the course of 6.x we need to explicitly check the version. Fixes #8997 --- library/system/hostname | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/library/system/hostname b/library/system/hostname index 50eaec12ff5..a426b59136b 100755 --- a/library/system/hostname +++ b/library/system/hostname @@ -367,12 +367,20 @@ class RedHatWorkstationHostname(Hostname): class CentOSHostname(Hostname): platform = 'Linux' distribution = 'Centos' - strategy_class = RedHatStrategy + distribution_version = _get_distribution_version() + if distribution_version and LooseVersion(distribution_version) >= LooseVersion("7"): + strategy_class = FedoraStrategy + else: + strategy_class = RedHatStrategy class CentOSLinuxHostname(Hostname): platform = 'Linux' distribution = 'Centos linux' - strategy_class = FedoraStrategy + distribution_version = _get_distribution_version() + if distribution_version and LooseVersion(distribution_version) >= LooseVersion("7"): + strategy_class = FedoraStrategy + else: + strategy_class = RedHatStrategy class ScientificHostname(Hostname): platform = 'Linux'