Module: Facter::Util::RhsmEnvironment

Defined in:
lib/facter/rhsm_environment.rb

Overview

current environement

Constant Summary collapse

CACHE_TTL =

24 * 60 * 60 seconds

86_400
CACHE_FILE =
'/var/cache/rhsm/environment.yaml'

Class Method Summary collapse

Class Method Details

.rhsm_environmentObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/facter/rhsm_environment.rb', line 31

def rhsm_environment
  value = nil
  begin
    output = Facter::Core::Execution.execute(
      '/usr/sbin/subscription-manager identity',
      on_fail: Facter::Core::Execution::ExecutionFailure,
    )
    unless output.nil?
      output.split("\n").each do |line|
        if line =~ %r{.* environment name(?: is)?: (.+)(?:/.*)?}
          value = Regexp.last_match(1)
        end
      end
    end
  rescue UncaughtThrowError, Facter::Core::Execution::ExecutionFailure => e
    if $ERROR_INFO !~ %r{This system is not yet registered}
      Facter.debug("#{e.backtrace[0]}: #{$ERROR_INFO}.")
    end
  end
  value
end