Class: PoolParty::Resources::VirtualHost
- Defined in:
- lib/poolparty/plugins/apache2/virtual_host.rb
Instance Attribute Summary
Attributes inherited from PoolParty::Resource
#exists, #graph_index, #meta_not_if, #meta_notifies, #meta_only_if, #meta_subscribes
Attributes inherited from Base
Instance Method Summary collapse
- #after_loaded(opts = {}, parent = self) ⇒ Object
- #listen(port = "80") ⇒ Object
- #virtual_host_entry(file) ⇒ Object
Methods inherited from Apache
#absent_apache_module, #apache_configs, #base_install, #before_load, #config, #configs, #enable_default, #enable_passenger, #install_passenger, #install_site, #installed_as_worker, #passenger_configs, #present_apache_module, #site, #site_include
Methods inherited from PoolParty::Resource
#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, #all_resources, #before_load, 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
Methods included from Callbacks
Methods included from SearchablePaths
Constructor Details
This class inherits a constructor from PoolParty::Resource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class PoolParty::Base
Instance Method Details
#after_loaded(opts = {}, parent = self) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/poolparty/plugins/apache2/virtual_host.rb', line 30 def after_loaded(opts={}, parent=self) has_directory(:name => "#{www_dir}/#{name}", :owner => www_user, :mode=>'0744') has_directory(:name => "#{www_dir}/#{name}/logs", :owner => www_user, :mode=>'0744') has_variable(:name => "sitename", :value => "#{name}") unless @virtual_host_entry vf = <<-eof <VirtualHost *:#{port}> ServerName #{name} DocumentRoot /var/www/#{name} </VirtualHost> eof virtual_host_entry vf end has_exec(:name => "insert-site-#{name}", :command => "/usr/sbin/a2ensite #{name}", :requires => get_file("/etc/apache2/sites-available/#{name}")) do requires get_package("apache2") notifies get_exec("reload-apache2"), :run not_if "/bin/sh -c '[ -L /etc/apache2/sites-enabled/#{parent.name} ] && [ /etc/apache2/sites-enabled/#{parent.name} -ef /etc/apache2/sites-available/#{parent.name} ]'" end end |
#listen(port = "80") ⇒ Object
11 12 13 14 |
# File 'lib/poolparty/plugins/apache2/virtual_host.rb', line 11 def listen(port="80") has_variable(:name => "port", :value => port) self.port = port end |
#virtual_host_entry(file) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/poolparty/plugins/apache2/virtual_host.rb', line 16 def virtual_host_entry(file) @virtual_host_entry = true if File.file?(file) has_file( :name => "/etc/apache2/sites-available/#{name}", :template => file, :requires => get_package("apache2")) else has_file( :name => "/etc/apache2/sites-available/#{name}", :content => file, :requires => get_package("apache2")) end end |