From c30f714c60ac7e5de84b15b4e9ba347e6c9d2044 Mon Sep 17 00:00:00 2001 From: Thomas Goirand Date: Wed, 4 Nov 2015 15:11:14 +0100 Subject: [PATCH] Prepare $::os_package_type We need this to be able to make decision of what style of package we are working with: Debian style package (for example, it uses a nova-consoleproxy package and not nova-novncproxy, or it has a openstack-dashboard-apache, etc.), or just the Ubuntu style package. This is needed, because in some cases, we are using the Debian style packages but running under Ubuntu. For example, that's the case when running with MOS over Ubuntu. For this case, a manual override is provided, in the form of a /etc/facter/facts.d/os_package_type.txt containing: os_package_type=debian In all other cases, we can consider that we're using vanilia (ie: unmodified) distribution packages, and we can set $::os_package_type depending on the value of $::operatingsystem. Having the below snipets helps simplifying checks within individual project manifests, so that we can just reuse $::os_package_type directly without having to also check if it contains a value, then check for the content of $::operatingsystem (ie: what's below factors the check once and for all). Change-Id: I0a009c0a60062d40c558c1f8de95386ce253f930 --- lib/facter/os_package_type.rb | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 lib/facter/os_package_type.rb diff --git a/lib/facter/os_package_type.rb b/lib/facter/os_package_type.rb new file mode 100644 index 00000000..134509ea --- /dev/null +++ b/lib/facter/os_package_type.rb @@ -0,0 +1,38 @@ +# +# We need this to be able to make decision of what style of package we are +# working with: Debian style package (for example, it uses a nova-consoleproxy +# package and not nova-novncproxy, or it has a openstack-dashboard-apache, +# etc.), or just the Ubuntu style package. +# +# This is needed, because in some cases, we are using the Debian style packages +# but running under Ubuntu. For example, that's the case when running with MOS +# over Ubuntu. For this case, a manual override is provided, in the form of a +# /etc/facter/facts.d/os_package_type.txt containing: +# os_package_type=debian +# +# In all other cases, we can consider that we're using vanilia (ie: unmodified) +# distribution packages, and we can set $::os_package_type depending on the +# value of $::operatingsystem. +# +# Having the below snipets helps simplifying checks within individual project +# manifests, so that we can just reuse $::os_package_type directly without +# having to also check if it contains a value, then check for the content of +# $::operatingsystem (ie: what's below factors the check once and for all). +Facter.add('os_package_type') do + setcode do + case Facter.value(:osfamily) + when 'Debian' + if Facter.value(:operatingsystem) == 'Debian' then + 'debian' + else + 'ubuntu' + end + when 'RedHat' + 'rpm' + when 'Solaris' + 'solaris' + else + 'unknown' + end + end +end