Class: Baton::Server
- Inherits:
-
Object
- Object
- Baton::Server
- Defined in:
- lib/baton/server.rb
Instance Attribute Summary collapse
-
#app_names ⇒ Object
Returns the value of attribute app_names.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#fqdn ⇒ Object
Returns the value of attribute fqdn.
Instance Method Summary collapse
-
#attributes ⇒ Object
Public: Method that provides an hash of attributes for a server.
-
#configure ⇒ Object
Public: Method that configures the server.
-
#facts ⇒ Object
Public: Method that reads facts from the file specified by facts_file.
-
#initialize ⇒ Server
constructor
Public: Initializes a server.
Constructor Details
#initialize ⇒ Server
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_names ⇒ Object
Returns the value of attribute app_names.
6 7 8 |
# File 'lib/baton/server.rb', line 6 def app_names @app_names end |
#environment ⇒ Object
Returns the value of attribute environment.
6 7 8 |
# File 'lib/baton/server.rb', line 6 def environment @environment end |
#fqdn ⇒ Object
Returns the value of attribute fqdn.
6 7 8 |
# File 'lib/baton/server.rb', line 6 def fqdn @fqdn end |
Instance Method Details
#attributes ⇒ Object
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 |
#configure ⇒ Object
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 |
#facts ⇒ Object
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 |