Class: PoolParty::Resources::Apache
Instance Attribute Summary
#exists, #graph_index, #meta_not_if, #meta_notifies, #meta_only_if, #meta_subscribes
Attributes inherited from Base
#base_name, #init_opts
Instance Method Summary
collapse
#after_compile, #after_loaded_requires_parent, #before_compile, #case_of, #cloud, #compile, define_resource, define_resource_methods, defined, defined_resources, #does_not_exist!, #exists!, #has_method_name, has_method_name, inherited, #initialize, is_base_resource_class?, method_defined!, method_defined?, #not_if, #notifies, #only_if, #pool, #print_to_chef, #print_variable, #requires, #subscribes
Methods inherited from Base
#add_ordered_resources_to_result, #after_loaded, #all_resources, clouds_dot_rb_dir, #clouds_dot_rb_dir, clouds_dot_rb_file, #clouds_dot_rb_file, #compile_opts, #create_graph, #dependencies, #get_resource, #has_searchable_paths, #initialize, #method_missing, #ordered_resources, #output_resources_graph, #resources, #resources_graph, #run_in_context, #run_with_callbacks, #to_s, #valid?, #validations
Methods included from Delayed
included
Methods included from Callbacks
included
included
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class PoolParty::Base
Instance Method Details
#absent_apache_module(*names) ⇒ Object
209
210
211
212
213
214
215
216
217
218
|
# File 'lib/poolparty/plugins/apache.rb', line 209
def absent_apache_module(*names)
names.each do |name|
has_exec({:name => "no-mod-#{name}"}, :command => "/usr/sbin/a2dismod #{name}") do
requires get_package("apache2")
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 ]\'"
notifies get_exec("force-reload-apache2"), :run
requires get_exec("force-reload-apache2")
end
end
end
|
#apache_configs ⇒ Object
143
144
145
|
# File 'lib/poolparty/plugins/apache.rb', line 143
def apache_configs
has_chef_attributes_file PoolParty.lib_dir/"vendor"/"chef"/"apache2"/"attributes"/"apache.rb"
end
|
#base_install ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'lib/poolparty/plugins/apache.rb', line 29
def base_install
unless @base_install
has_exec({:name => "restart-apache2", :command => "/etc/init.d/apache2 restart", :action => :nothing})
has_exec({:name => "reload-apache2", :command => "/etc/init.d/apache2 reload", :action => :nothing, :requires => get_package("apache2")})
has_exec({:name => "force-reload-apache2", :command => "/etc/init.d/apache2 force-reload", :action => :nothing})
@base_install = true
end
end
|
#before_load ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/poolparty/plugins/apache.rb', line 12
def before_load
installed_as_worker
configs
has_service("apache2", :requires => get_package("apache2"))
has_user "www-data"
apache_configs
end
|
#config(name, temp) ⇒ Object
152
153
154
155
156
157
158
|
# File 'lib/poolparty/plugins/apache.rb', line 152
def config(name, temp)
has_file(:name => "/etc/apache2/conf.d/#{name}.conf") do
template File.dirname(__FILE__)/temp
notifies get_exec("reload-apache2"), :run
requires get_exec("reload-apache2")
end
end
|
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
# File 'lib/poolparty/plugins/apache.rb', line 110
def configs
unless @configs
listen(port) unless @listen
has_directory("#{www_dir}", :mode => "0755")
has_directory("/etc/apache2")
has_directory("/etc/apache2/conf.d")
has_directory("/etc/apache2/site-includes")
has_file("/etc/apache2/apache2.conf") do
mode 0644
requires get_directory("/etc/apache2/conf.d")
requires get_package("apache2")
template File.dirname(__FILE__)/"apache2"/"apache2.conf.erb"
end
has_exec("/usr/sbin/a2dissite default") do
only_if "/usr/bin/test -L /etc/apache2/sites-enabled/000-default"
notifies get_exec("reload-apache2"), :run
requires get_exec("reload-apache2")
end
config("base", "apache2"/"base.conf.erb")
config("mime", "apache2"/"mime-minimal.conf.erb")
config("browser_fixes", "apache2"/"browser_fixes.conf.erb")
present_apache_module("mime", "rewrite")
@configs = true
end
end
|
#enable_default ⇒ Object
147
148
149
150
|
# File 'lib/poolparty/plugins/apache.rb', line 147
def enable_default
listen 80 site "default-site", :template => File.dirname(__FILE__)/:apache2/"default-site.conf.erb"
end
|
#enable_passenger ⇒ Object
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/poolparty/plugins/apache.rb', line 50
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", :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 -e \#{node[:passenger_site][:passenger_module_path]}"
end
@enable_passenger = true
end
end
|
#install_passenger ⇒ Object
39
40
41
|
# File 'lib/poolparty/plugins/apache.rb', line 39
def install_passenger
enable_passenger
end
|
#install_site(name, opts = {}) ⇒ Object
178
179
180
181
182
183
184
185
186
187
188
189
190
|
# File 'lib/poolparty/plugins/apache.rb', line 178
def install_site(name, opts={})
sitename = name
opts.merge!(:name => "/etc/apache2/sites-available/#{sitename}", :requires => get_package("apache2"))
has_directory(:name => "/etc/apache2/sites-available")
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} ]'"
end
end
|
#installed_as_worker ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/poolparty/plugins/apache.rb', line 20
def installed_as_worker
unless @installed_as_worker
has_package("apache2")
base_install
@installed_as_worker = true
end
end
|
#listen(p = "80") ⇒ Object
160
161
162
163
164
|
# File 'lib/poolparty/plugins/apache.rb', line 160
def listen(p="80")
has_variable(:name => "port", :value => [p])
self.port = p
@listen = true
end
|
#passenger_configs ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/poolparty/plugins/apache.rb', line 73
def passenger_configs
unless @passenger_configs
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", "\#{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, {:requires => get_file("/etc/apache2/mods-available/passenger.load")})
@passenger_configs = true
end
end
|
#present_apache_module(*names) ⇒ Object
196
197
198
199
200
201
202
203
204
205
206
207
|
# File 'lib/poolparty/plugins/apache.rb', line 196
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
|
#site(name, opts = {}) ⇒ Object
166
167
168
169
170
171
172
173
174
175
176
|
# File 'lib/poolparty/plugins/apache.rb', line 166
def site(name, opts={})
if exists?
install_site(name, opts)
else
has_exec(:command => "/usr/sbin/a2dissite #{name}") do
notifies get_exec("reload-apache2"), :run
requires get_package("apache2")
only_if "/bin/sh -c \"[ -L /etc/apache2/sites-enabled/#{name} ] && [ /etc/apache2/sites-enabled/#{name} -ef /etc/apache2/sites-available/#{name}]\""
end
end
end
|
#site_include(name, content, ensureer = "present") ⇒ Object
192
193
194
|
# File 'lib/poolparty/plugins/apache.rb', line 192
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
|