Module: Facter::Util::RhsmAvailableRepos

Defined in:
lib/facter/rhsm_available_repos.rb

Overview

Available RHSM repos for this client.

Constant Summary collapse

CACHE_TTL =

24 * 60 * 60 seconds

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

Class Method Summary collapse

Class Method Details

.rhsm_available_reposObject



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

def rhsm_available_repos
  value = []
  begin
    output = Facter::Core::Execution.execute(
      '/usr/sbin/subscription-manager repos',
      on_fail: :raise,
    )
    unless output.nil? || !output.is_a?(String)
      output.split("\n").each do |line|
        if line =~ %r{Repo ID:\s+(\S+)}
          value.push(Regexp.last_match(1).chomp)
        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