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, #resources_with_dependencies, #resources_without_dependencies, #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
214
215
216
217
218
219
220
221
222
223
|
# File 'lib/poolparty/plugins/apache.rb', line 214
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
148
149
150
|
# File 'lib/poolparty/plugins/apache.rb', line 148
def apache_configs
has_chef_attributes_file PoolParty.lib_dir/"vendor"/"chef"/"apache2"/"attributes"/"apache.rb"
end
|
#base_install ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/poolparty/plugins/apache.rb', line 34
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
17
18
19
20
21
22
23
|
# File 'lib/poolparty/plugins/apache.rb', line 17
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
157
158
159
160
161
162
163
|
# File 'lib/poolparty/plugins/apache.rb', line 157
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
|
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
142
143
144
145
146
|
# File 'lib/poolparty/plugins/apache.rb', line 115
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
152
153
154
155
|
# File 'lib/poolparty/plugins/apache.rb', line 152
def enable_default
listen 80
site "default-site", :template => File.dirname(__FILE__)/:apache2/"default-site.conf.erb", :notifies => get_exec("reload-apache2"), :requires => get_exec("reload-apache2")
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/poolparty/plugins/apache.rb', line 55
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
44
45
46
|
# File 'lib/poolparty/plugins/apache.rb', line 44
def install_passenger
enable_passenger
end
|
#install_site(name, opts = {}) ⇒ Object
183
184
185
186
187
188
189
190
191
192
193
194
195
|
# File 'lib/poolparty/plugins/apache.rb', line 183
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
25
26
27
28
29
30
31
32
|
# File 'lib/poolparty/plugins/apache.rb', line 25
def installed_as_worker
unless @installed_as_worker
has_package("apache2")
base_install
@installed_as_worker = true
end
end
|
#listen(p = "80") ⇒ Object
165
166
167
168
169
|
# File 'lib/poolparty/plugins/apache.rb', line 165
def listen(p="80")
has_variable(:name => "port", :value => [p])
self.port = p
@listen = true
end
|
13
14
15
|
# File 'lib/poolparty/plugins/apache.rb', line 13
def name
"apache"
end
|
#passenger_configs ⇒ Object
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
109
110
111
112
113
|
# File 'lib/poolparty/plugins/apache.rb', line 78
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 "LoadModule passenger_module <%= @node[:passenger_site][:passenger_module_path] %>\n eof\n requires get_exec(\"install_passenger_script\")\n end\n \n has_file(:name => \"/etc/apache2/mods-available/passenger.conf\") do\n content <<-eof\nPassengerRoot <%= @node[:passenger_site][:passenger_root_path] %>\nPassengerRuby <%= @node[:languages][:ruby][:ruby_bin] %>\n eof\n requires get_exec(\"install_passenger_script\")\n end\n \n present_apache_module(:passenger, {:requires => get_file(\"/etc/apache2/mods-available/passenger.load\")})\n @passenger_configs = true\n end\nend\n"
|
#present_apache_module(*names) ⇒ Object
201
202
203
204
205
206
207
208
209
210
211
212
|
# File 'lib/poolparty/plugins/apache.rb', line 201
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
171
172
173
174
175
176
177
178
179
180
181
|
# File 'lib/poolparty/plugins/apache.rb', line 171
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_exec("reload-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
197
198
199
|
# File 'lib/poolparty/plugins/apache.rb', line 197
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
|