Class: Baton::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/baton/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeServer

Public: Initializes a server. Loads Ohai plugins and sets up basic server info, such as environment, fqdn and app names.



10
11
12
13
# File 'lib/baton/server.rb', line 10

def initialize
  setup_ohai
  configure
end

Instance Attribute Details

#app_namesObject

Returns the value of attribute app_names.



6
7
8
# File 'lib/baton/server.rb', line 6

def app_names
  @app_names
end

#environmentObject

Returns the value of attribute environment.



6
7
8
# File 'lib/baton/server.rb', line 6

def environment
  @environment
end

#fqdnObject

Returns the value of attribute fqdn.



6
7
8
# File 'lib/baton/server.rb', line 6

def fqdn
  @fqdn
end

Instance Method Details

#attributesObject

Public: Method that provides an hash of attributes for a server.

Examples

attributes
# => {environment: "production", fqdn: "server.dsci.it", app_names: ["app1","app2"]}

Returns Output depends on the implementation.



45
46
47
# File 'lib/baton/server.rb', line 45

def attributes
  {environment: environment, fqdn: fqdn, app_names: app_names}
end

#configureObject

Public: Method that configures the server. It sets the fqdn, environment and a list of app names specified by the ohai config file.

Returns nothing.



19
20
21
22
23
# File 'lib/baton/server.rb', line 19

def configure
  @environment = facts.fetch("chef_environment"){"development"}.downcase
  @fqdn        = facts.fetch("fqdn"){""}
  @app_names   = facts.fetch("trebuchet"){[]}
end

#factsObject

Public: Method that reads facts from the file specified by facts_file.

Examples

facts
# => {"fqdn" => "server.dsci.it", "chef_environment" => "production", "trebuchet" => []}

Returns a hash with server information.



33
34
35
# File 'lib/baton/server.rb', line 33

def facts
  @facts ||= @ohai.data
end