Defined Type: apache::vhost::fragment

Defined in:
manifests/vhost/fragment.pp

Summary

Define a fragment within a vhost

Overview

Examples:

With a vhost without priority

include apache
apache::vhost { 'myvhost':
}
apache::vhost::fragment { 'myfragment':
  vhost   => 'myvhost',
  content => '# Foo',
}

With a vhost with priority

include apache
apache::vhost { 'myvhost':
  priority => '42',
}
apache::vhost::fragment { 'myfragment':
  vhost    => 'myvhost',
  priority => '42',
  content  => '# Foo',
}

With a vhost with default vhost

include apache
apache::vhost { 'myvhost':
  default_vhost => true,
}
apache::vhost::fragment { 'myfragment':
  vhost    => 'myvhost',
  priority => '10', # default_vhost implies priority 10
  content  => '# Foo',
}

Adding a fragment to the built in default vhost

include apache
apache::vhost::fragment { 'myfragment':
  vhost    => 'default',
  priority => '15',
  content  => '# Foo',
}

Parameters:

  • vhost (String[1])

    The title of the vhost resource to append to

  • priority (Any) (defaults to: undef)

    Set the priority to match the one ‘apache::vhost` sets. This must match the one `apache::vhost` sets or else the concat fragment won’t be found.

  • content (Optional[String]) (defaults to: undef)

    The content to put in the fragment. Only when it’s non-empty the actual fragment will be created.

  • order (Integer[0]) (defaults to: 900)

    The order to insert the fragment at

  • port (Optional[Integer[0]]) (defaults to: undef)


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'manifests/vhost/fragment.pp', line 56

define apache::vhost::fragment (
  String[1] $vhost,
  Optional[Integer[0]] $port = undef,
  $priority = undef,
  Optional[String] $content = undef,
  Integer[0] $order = 900,
) {
  # This copies the logic from apache::vhost
  if $priority {
    $priority_real = "${priority}-"
  } elsif $priority == false {
    $priority_real = ''
  } else {
    $priority_real = '25-'
  }

  $filename = $port ? {
    Integer => regsubst("${vhost}-${port}", ' ', '_', 'G'),
    Undef   => regsubst($vhost, ' ', '_', 'G'),
  }

  if $content =~ String[1] {
    concat::fragment { "${vhost}-${title}":
      target  => "${priority_real}${filename}.conf",
      order   => $order,
      content => $content,
    }
  }
}