Module: Beaker::DSL::Helpers::FacterHelpers

Included in:
Beaker::DSL::Helpers
Defined in:
lib/beaker/dsl/helpers/facter_helpers.rb

Overview

Methods that help you interact with your facter installation, facter must be installed for these methods to execute correctly

Instance Method Summary collapse

Instance Method Details

#fact(name, opts = {}) ⇒ Object

Get a facter fact from the default host

See Also:



41
42
43
# File 'lib/beaker/dsl/helpers/facter_helpers.rb', line 41

def fact(name, opts = {})
  fact_on(default, name, opts)
end

#fact_on(host, name, opts = {}) ⇒ Object

Get a facter fact from a provided host

Parameters:

  • host (Host, Array<Host>, String, Symbol)

    One or more hosts to act upon, or a role (String or Symbol) that identifies one or more hosts.

  • name (String)

    The name of the fact to query for

  • opts (Hash{Symbol=>String}) (defaults to: {})

    Options to alter execution.

Options Hash (opts):

  • :silent (Boolean) — default: false

    Do not produce log output

  • :acceptable_exit_codes (Array<Fixnum>) — default: [0]

    An array (or range) of integer exit codes that should be considered acceptable. An error will be thrown if the exit code does not match one of the values in this list.

  • :environment (Hash{String=>String}) — default: {}

    These will be treated as extra environment variables that should be set before running the command.

Returns:

  • String The value of the fact ‘name’ on the provided host

Raises:

  • (FailTest)

    Raises an exception if call to facter fails



30
31
32
33
34
35
36
37
# File 'lib/beaker/dsl/helpers/facter_helpers.rb', line 30

def fact_on(host, name, opts = {})
  result = on host, facter(name, opts)
  if result.kind_of?(Array)
    result.map { |res| res.stdout.chomp }
  else
    result.stdout.chomp
  end
end