lib/poolparty/plugins/apache.rb in auser-poolparty-1.3.13 vs lib/poolparty/plugins/apache.rb in auser-poolparty-1.3.14
- old
+ new
@@ -5,11 +5,11 @@
class Apache < Resource
default_options :port => 80,
:www_user => 'www-data',
:www_dir => "/var/www",
- :passenger_version => "2.2.4"
+ :passenger_version => "2.2.5"
def before_load
installed_as_worker
configs
has_service("apache2", :requires => get_package("apache2"))
@@ -37,55 +37,74 @@
def install_passenger
enable_passenger
end
+
+
+ # LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so
+ # PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5
+ # PassengerRuby /usr/bin/ruby1.8
+ #
+ # creating this thing below may not be being run b/c it checks for the passenger.conf which isn't really a good test
def enable_passenger
unless @enable_passenger
installed_as_worker
has_package "build-essential"
has_package "apache2-prefork-dev"
has_gem_package "fastthread"
- has_gem_package "passenger"
+ has_gem_package "passenger", :version => passenger_version
passenger_configs
has_exec "install_passenger_script" do
command "passenger-install-apache2-module --auto"
notifies get_exec("restart-apache2"), :run
requires get_exec("restart-apache2")
requires get_package("apache2")
requires get_gem_package("passenger")
- not_if "test -f /etc/apache2/mods-available/passenger.conf && test -s /etc/apache2/mods-available/passenger.conf "
- creates lambda { "@node[:apache][:passenger_module_path]" }
+ not_if "test -e \#{node[:passenger_site][:passenger_module_path]}"
+ # creates lambda { "passenger_site[:passenger_module_path]" }
end
@enable_passenger = true
end
end
def passenger_configs
unless @passenger_configs
+
+ # requires doesn't work for has_variable?
+ # has_variable("passenger_version", passenger_version)
+ # has_variable("passenger_root_path", "\#{languages[:ruby][:gems_dir]}/gems/passenger-#{passenger_version}",
+ # :requires => get_variable("passenger_version"))
+ # has_variable("passenger_module_path", "\#{passenger_site[:passenger_root_path]}/ext/apache2/mod_passenger.so",
+ # :requires => get_variable("passenger_root_path"))
+
has_variable("passenger_version", passenger_version)
- has_variable("passenger_root_path", "\#{languages[:ruby][:gems_dir]}/gems/passenger-#{passenger_version}")
- has_variable("passenger_module_path", "\#{passenger_site[:passenger_root_path]}/ext/apache2/mod_passenger.so")
+ has_variable("passenger_root_path", "\#{languages[:ruby][:gems_dir]}/gems/passenger-#{passenger_version}",
+ :requires => get_variable("passenger_version"))
+ has_variable("passenger_module_path", "\#{languages[:ruby][:gems_dir]}/gems/passenger-#{passenger_version}/ext/apache2/mod_passenger.so",
+ :requires => get_variable("passenger_root_path"))
has_file(:name => "/etc/apache2/mods-available/passenger.load") do
content <<-eof
LoadModule passenger_module <%= @node[:passenger_site][:passenger_module_path] %>
eof
+ requires get_exec("install_passenger_script")
end
has_file(:name => "/etc/apache2/mods-available/passenger.conf") do
content <<-eof
PassengerRoot <%= @node[:passenger_site][:passenger_root_path] %>
PassengerRuby <%= @node[:languages][:ruby][:ruby_bin] %>
eof
+ requires get_exec("install_passenger_script")
end
- present_apache_module(:passenger)
+ present_apache_module(:passenger, {:requires => get_file("/etc/apache2/mods-available/passenger.load")})
@passenger_configs = true
end
end
def configs
@@ -157,13 +176,13 @@
end
def install_site(name, opts={})
sitename = name
- opts.merge!(:name => "/etc/apache2/sites-available/#{sitename}")
+ opts.merge!(:name => "/etc/apache2/sites-available/#{sitename}", :requires => get_package("apache2"))
has_directory(:name => "/etc/apache2/sites-available")
- has_file(opts) unless opts[:no_file]
+ has_file(opts, :requires => get_package("apache2")) unless opts[:no_file]
has_exec(:name => "/usr/sbin/a2ensite #{sitename}") do
notifies get_exec("reload-apache2"), :run
requires get_exec("reload-apache2")
requires get_file("/etc/apache2/sites-available/#{sitename}")
not_if "/bin/sh -c '[ -L /etc/apache2/sites-enabled/#{sitename} ] && [ /etc/apache2/sites-enabled/#{sitename} -ef /etc/apache2/sites-available/#{sitename} ]'"
@@ -173,15 +192,17 @@
def site_include(name, content, ensureer="present")
has_file(:name => "/etc/apache2/site-includes/#{name}.inc", :ensures => ensureer, :content => content, :requires => get_file("/etc/apache2/site-includes"))
end
def present_apache_module(*names)
+ opts = names.pop if names.last.kind_of?(::Hash)
names.each do |name|
has_exec(:name => "mod-#{name}", :command => "/usr/sbin/a2enmod #{name}") do
not_if "/bin/sh -c \'[ -L /etc/apache2/mods-enabled/#{name}.load ] && [ /etc/apache2/mods-enabled/#{name}.load -ef /etc/apache2/mods-available/#{name}.load ]\'"
requires get_package("apache2")
notifies get_exec("force-reload-apache2"), :run
requires get_exec("force-reload-apache2")
+ requires opts[:requires] if opts && opts[:requires]
end
end
end
def absent_apache_module(*names)