Sha256: beb89d6f9ccc5e923f816aac27c2b261239a64dc2fb74169e27767d3b7faf449
Contents?: true
Size: 1.69 KB
Versions: 2
Compression:
Stored size: 1.69 KB
Contents
require "json" module Baton class Server attr_accessor :environment, :fqdn, :app_names # Public: Initialize a Server. ALso, configures the server by reading Baton's configuration # file. def initialize configure end # 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. def configure @environment = facts.fetch("chef_environment"){"development"}.downcase @fqdn = facts.fetch("fqdn"){""} @app_names = facts.fetch("trebuchet"){[]} end # 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. def facts @facts ||= JSON.parse(facts_file.read) end # Public: Provides the content of the ohai file. # # Returns content of ohai facts file. def facts_file File.open(facts_path) end # Public: Provides the path to the ohai file # # Examples # # facts_path # # => "/path/to/file/facts.json" # # Returns the path of the ohai file def facts_path Baton.configuration.ohai_file end # 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. def attributes {environment: environment, fqdn: fqdn, app_names: app_names} end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
baton-0.3.7 | lib/baton/server.rb |
baton-0.3.6 | lib/baton/server.rb |