summaryrefslogtreecommitdiff
path: root/manifests/vhost/redirect.pp
blob: 250d42a1279368e19b57db8d2e0c7aef17c2a510 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Define: httpd::vhost::redirect
#
# This class will create a vhost that does nothing more than redirect to a
# given location
#
# Parameters:
#   $port:
#       Which port to list on
#   $dest:
#       Where to redirect to
# - $vhost_name
#
# Actions:
#   Installs apache and creates a vhost
#
# Requires:
#
# Sample Usage:
#
define httpd::vhost::redirect (
    $port,
    $dest,
    $priority      = '10',
    $serveraliases = '',
    $template      = 'httpd/vhost-redirect.conf.erb',
    $vhost_name    = '*'
  ) {

  include httpd

  $srvname = $name

  file { "${priority}-${name}":
    path    => "${httpd::params::vdir}/${priority}-${name}",
    content => template($template),
    owner   => 'root',
    group   => 'root',
    mode    => '0755',
    require => Package['httpd'],
    notify  => Service['httpd'],
  }

  if ! defined(Firewall["0100-INPUT ACCEPT ${port}"]) {
    @firewall {
      "0100-INPUT ACCEPT ${port}":
        jump  => 'ACCEPT',
        dport => '$port',
        proto => 'tcp'
    }
  }
}