Class: Vito::Recipes::Apache::Install

Inherits:
Vito::Recipe show all
Defined in:
lib/vito/recipes/apache/install.rb

Constant Summary collapse

APACHE_HOMEDIR =
"/etc/apache2"

Instance Method Summary collapse

Methods inherited from Vito::Recipe

#depends_on_recipe, #install_os_dependencies, #method_missing, #os, #program_version, #query, #remove, #run_command, #update, #with, #with?

Constructor Details

#initialize(options, connection) ⇒ Install

Returns a new instance of Install.



7
8
9
10
# File 'lib/vito/recipes/apache/install.rb', line 7

def initialize(options, connection)
  @vhosts = {}
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Vito::Recipe

Instance Method Details

#installObject



12
13
14
15
16
17
18
19
# File 'lib/vito/recipes/apache/install.rb', line 12

def install
  if installed?
    Vito::Log.write "Apache2 already installed."
  else
    Vito::Log.write "Installing Apache2"
    install_apache
  end
end

#vhosts(options = {}) ⇒ Object

Used in the Apache block

Raises:

  • (InvalidApacheVhosts)


22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vito/recipes/apache/install.rb', line 22

def vhosts(options = {})
  @vhosts[:rails_env]  = options[:rails_env]  || "production"
  @vhosts[:servername] = options[:servername] || "www.example.com"

  @vhosts[:ports] = options[:ports] || [80]
  @vhosts[:ports] << 443 if Array(options[:with]).include?(:ssl)

  @vhosts[:path] = options[:path]

  raise InvalidApacheVhosts, "VHosts' app path not specified" unless @vhosts[:path]
  raise InvalidApacheVhosts, "VHosts' app port not specified" unless @vhosts[:ports]
end