diff --git a/CHANGELOG.md b/CHANGELOG.md index 9508e7d..b023eca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 0.1.22 * added **eypconf_location** +* added **eypconf_sg** fact (servergroup shortname) ## 0.1.21 diff --git a/lib/facter/eypconf_sg.rb b/lib/facter/eypconf_sg.rb new file mode 100644 index 0000000..14776bb --- /dev/null +++ b/lib/facter/eypconf_sg.rb @@ -0,0 +1,25 @@ +if File.exists?('/opt/eypconf/id/sg.sh') then + sg = Facter::Util::Resolution.exec('bash /opt/eypconf/id/sg.sh').to_s +else + sg = Facter::Util::Resolution.exec('bash -c \'if [ -f /opt/eypconf/id/sg ]; then cat /opt/eypconf/id/server; fi\'') +end + +unless sg.nil? or sg.empty? + Facter.add('eypconf_sg') do + setcode do + sg + end + end + + Facter.add('eypconf_sg_uppercase') do + setcode do + sg.upcase + end + end + + Facter.add('eypconf_sg_lowercase') do + setcode do + sg.downcase + end + end +end