Created
November 17, 2008 23:12
-
-
Save deadprogram/25952 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
virtual_resource(:virtualhost) do | |
def listen(port="80") | |
has_variable(:name => "port", :value => port) | |
port port | |
end | |
def virtual_host_entry(file) | |
if ::File.file?(file) | |
template file | |
else | |
options.merge!(:content => file) | |
end | |
end | |
def ssl(cert, key) | |
has_variable(:name => "ssl_cert_file", :value => cert) | |
has_variable(:name => "ssl_private_key_file", :value => key) | |
template ::File.join(File.dirname(__FILE__), "templates/webserver", "ssl.conf.erb") | |
end | |
def loaded(opts={}, parent=self) | |
has_directory(:name => "/var/www") | |
has_directory(:name => "/var/www/#{name}/logs", :owner => "www-data") | |
has_variable(:name => "sitename", :value => "#{name}") | |
has_file(options.merge(:name => "/etc/apache2/sites-available/#{name}", :ensures => 'present')) | |
has_exec(:name => "insert-site-#{name}", :command => "/usr/sbin/a2ensite #{name}", :notify => get_exec("reload-apache2"), :requires => get_file("/etc/apache2/sites-available/#{name}")) do | |
requires get_package("apache2") | |
ifnot "/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 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment