Created
September 12, 2012 20:29
-
-
Save pccowboy/3709651 to your computer and use it in GitHub Desktop.
Weird behavior of facter in a custom fact
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@ops-jenkins01-use1 facter]# facter --puppet operatingsystemrelease | |
6.3 | |
[root@ops-jenkins01-use1 facter]# facter --puppet operatingsystem | |
CentOS | |
[root@ops-jenkins01-use1 facter]# facter --puppet operatingsystemmajor | |
2.6.32-279.5.2.el6.x86_64 | |
[root@ops-jenkins01-use1 facter]# cat operatingsystemmajor.rb | |
# | |
# Custom fact to: | |
# return the major release number of the client OS | |
# allow AWS instances based upon the Amazon AMIs to return a sane value | |
# | |
# | |
Facter.add('operatingsystemmajor') do | |
has_weight 50 | |
setcode do | |
if Facter.value('operatingsystem') == 'Amazon' | |
%x[cat /etc/system-release | awk \{'print $5'\}].chomp | |
else | |
f = Facter.value('operatingsystemrelease') | |
u = f.split('.') | |
f | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment