Sha256: f86568e05d1217aa682129cea83ac969ec8d686954f206cf9bb468c18d371599

Contents?: true

Size: 1.77 KB

Versions: 26

Compression:

Stored size: 1.77 KB

Contents

module PoolParty
  module Resources
    class VirtualHost < Apache
      
      default_options(
        :port     => 80,
        :www_dir  => "/var/www",
        :www_user => "www-data"
      )
      
      def listen(port="80")
        has_variable(:name => "port", :value => port)
        self.port = port
      end

      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


      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
      
    end
    
  end
  
end

Version data entries

26 entries across 26 versions & 3 rubygems

Version Path
auser-poolparty-1.3.0 lib/poolparty/plugins/apache2/virtual_host.rb
auser-poolparty-1.3.1 lib/poolparty/plugins/apache2/virtual_host.rb
auser-poolparty-1.3.10 lib/poolparty/plugins/apache2/virtual_host.rb
auser-poolparty-1.3.11 lib/poolparty/plugins/apache2/virtual_host.rb
auser-poolparty-1.3.12 lib/poolparty/plugins/apache2/virtual_host.rb
auser-poolparty-1.3.13 lib/poolparty/plugins/apache2/virtual_host.rb
auser-poolparty-1.3.14 lib/poolparty/plugins/apache2/virtual_host.rb
auser-poolparty-1.3.15 lib/poolparty/plugins/apache2/virtual_host.rb
auser-poolparty-1.3.16 lib/poolparty/plugins/apache2/virtual_host.rb
auser-poolparty-1.3.2 lib/poolparty/plugins/apache2/virtual_host.rb
auser-poolparty-1.3.3 lib/poolparty/plugins/apache2/virtual_host.rb
auser-poolparty-1.3.4 lib/poolparty/plugins/apache2/virtual_host.rb
auser-poolparty-1.3.5 lib/poolparty/plugins/apache2/virtual_host.rb
auser-poolparty-1.3.6 lib/poolparty/plugins/apache2/virtual_host.rb
auser-poolparty-1.3.7 lib/poolparty/plugins/apache2/virtual_host.rb
auser-poolparty-1.3.8 lib/poolparty/plugins/apache2/virtual_host.rb
fairchild-poolparty-1.3.5 lib/poolparty/plugins/apache2/virtual_host.rb
poolparty-1.3.15 lib/poolparty/plugins/apache2/virtual_host.rb
poolparty-1.3.14 lib/poolparty/plugins/apache2/virtual_host.rb
poolparty-1.3.13 lib/poolparty/plugins/apache2/virtual_host.rb