Puppet modules for deploying Apache in OpenStack infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vhost.pp 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # Definition: httpd::vhost
  2. #
  3. # This class installs Apache Virtual Hosts
  4. #
  5. # Parameters:
  6. # - The $port to configure the host on
  7. # - The $docroot provides the DocumentationRoot variable
  8. # - The $ssl option is set true or false to enable SSL for this Virtual Host
  9. # - The $configure_firewall option is set to true or false to specify if
  10. # a firewall should be configured.
  11. # - The $template option specifies whether to use the default template or
  12. # override
  13. # - The $priority of the site
  14. # - The $serveraliases of the site
  15. # - The $options for the given vhost
  16. # - The $vhost_name for name based virtualhosting, defaulting to *
  17. #
  18. # Actions:
  19. # - Install Apache Virtual Hosts
  20. #
  21. # Requires:
  22. # - The httpd class
  23. #
  24. # Sample Usage:
  25. # httpd::vhost { 'site.name.fqdn':
  26. # priority => '20',
  27. # port => '80',
  28. # docroot => '/path/to/docroot',
  29. # }
  30. #
  31. define httpd::vhost(
  32. $port,
  33. $docroot,
  34. $configure_firewall = true,
  35. $ssl = $httpd::params::ssl,
  36. $template = $httpd::params::template,
  37. $priority = $httpd::params::priority,
  38. $servername = $httpd::params::servername,
  39. $serveraliases = $httpd::params::serveraliases,
  40. $auth = $httpd::params::auth,
  41. $redirect_ssl = $httpd::params::redirect_ssl,
  42. $options = $httpd::params::options,
  43. $apache_name = $httpd::params::apache_name,
  44. $vhost_name = $httpd::params::vhost_name
  45. ) {
  46. include ::httpd
  47. if $servername == undef {
  48. $srvname = $name
  49. } else {
  50. $srvname = $servername
  51. }
  52. if $ssl == true {
  53. include ::httpd::ssl
  54. }
  55. # Since the template will use auth, redirect to https requires mod_rewrite
  56. if $redirect_ssl == true {
  57. case $::operatingsystem {
  58. 'debian','ubuntu': {
  59. Httpd_mod <| title == 'rewrite' |>
  60. }
  61. default: { }
  62. }
  63. }
  64. file { "${priority}-${name}.conf":
  65. path => "${httpd::params::vdir}/${priority}-${name}.conf",
  66. content => template($template),
  67. owner => 'root',
  68. group => 'root',
  69. mode => '0755',
  70. require => Package['httpd'],
  71. notify => Service['httpd'],
  72. }
  73. if $configure_firewall {
  74. if ! defined(Firewall["0100-INPUT ACCEPT ${port}"]) {
  75. @firewall {
  76. "0100-INPUT ACCEPT ${port}":
  77. action => 'accept',
  78. dport => '$port',
  79. proto => 'tcp'
  80. }
  81. }
  82. }
  83. }