define apache2::config (
- $source=undef,
- $content=undef,
- $nocontentok=undef,
- $ensure=present
+ $source=undef,
+ $content=undef,
+ $nocontentok=undef,
+ $ensure=present
) {
- include apache2
+ include apache2
- case $ensure {
- present: {
- if ! ($source or $content or $nocontentok) {
- fail ( "No configuration found for ${name}" )
- }
+ case $ensure {
+ present: {
+ if ! ($source or $content or $nocontentok) {
+ fail ( "No configuration found for ${name}" )
+ }
- if $content {
- file { "/etc/apache2/conf-available/${name}.conf":
- ensure => $ensure,
- content => $content,
- require => Package['apache2'],
- notify => Exec['service apache2 reload'],
- }
- } elsif $source {
- file { "/etc/apache2/conf-available/${name}.conf":
- ensure => $ensure,
- source => $source,
- require => Package['apache2'],
- notify => Exec['service apache2 reload'],
- }
- }
- }
- absent: {
- file { "/etc/apache2/conf-available/${name}.conf":
- ensure => $ensure,
- require => Package['apache2'],
- notify => Exec['service apache2 reload'],
- }
- }
- default: { fail ( "Unknown ensure value: '$ensure'" ) }
- }
- $link_ensure = $ensure ? {
- present => link,
- absent => absent
- }
+ if $content {
+ file { "/etc/apache2/conf-available/${name}.conf":
+ ensure => $ensure,
+ content => $content,
+ require => Package['apache2'],
+ notify => Exec['service apache2 reload'],
+ }
+ } elsif $source {
+ file { "/etc/apache2/conf-available/${name}.conf":
+ ensure => $ensure,
+ source => $source,
+ require => Package['apache2'],
+ notify => Exec['service apache2 reload'],
+ }
+ }
+ }
+ absent: {
+ file { "/etc/apache2/conf-available/${name}.conf":
+ ensure => $ensure,
+ require => Package['apache2'],
+ notify => Exec['service apache2 reload'],
+ }
+ }
+ default: { fail ( "Unknown ensure value: '$ensure'" ) }
+ }
+ $link_ensure = $ensure ? {
+ present => link,
+ absent => absent
+ }
- file { "/etc/apache2/conf-enabled/${name}.conf":
- ensure => $link_ensure,
- target => "../conf-available/${name}.conf",
- notify => Exec['service apache2 reload'],
- }
+ file { "/etc/apache2/conf-enabled/${name}.conf":
+ ensure => $link_ensure,
+ target => "../conf-available/${name}.conf",
+ notify => Exec['service apache2 reload'],
+ }
}
define apache2::module ($ensure = present) {
- case $ensure {
- present: {
- exec { "/usr/sbin/a2enmod ${name}":
- creates => "/etc/apache2/mods-enabled/${name}.load",
- require => Package['apache2'],
- notify => Service['apache2']
- }
- }
- absent: {
- exec { "/usr/sbin/a2dismod ${name}":
- onlyif => "test -L /etc/apache2/mods-enabled/${name}.load",
- require => Package['apache2'],
- notify => Service['apache2']
- }
- }
- default: { fail ( "Unknown ensure value: '$ensure'" ) }
- }
+ case $ensure {
+ present: {
+ exec { "/usr/sbin/a2enmod ${name}":
+ creates => "/etc/apache2/mods-enabled/${name}.load",
+ require => Package['apache2'],
+ notify => Service['apache2']
+ }
+ }
+ absent: {
+ exec { "/usr/sbin/a2dismod ${name}":
+ onlyif => "test -L /etc/apache2/mods-enabled/${name}.load",
+ require => Package['apache2'],
+ notify => Service['apache2']
+ }
+ }
+ default: { fail ( "Unknown ensure value: '$ensure'" ) }
+ }
}
define apache2::site (
- $source=undef,
- $content=undef,
- $ensure=present,
- $site=undef
+ $source=undef,
+ $content=undef,
+ $ensure=present,
+ $site=undef
) {
- include apache2
+ include apache2
- case $ensure {
- present: {
- if ! ($source or $content) {
- fail ( "No configuration found for ${name}" )
- }
- }
- absent: {}
- default: { fail ( "Unknown ensure value: '$ensure'" ) }
- }
+ case $ensure {
+ present: {
+ if ! ($source or $content) {
+ fail ( "No configuration found for ${name}" )
+ }
+ }
+ absent: {}
+ default: { fail ( "Unknown ensure value: '$ensure'" ) }
+ }
- if $site {
- $base = $site
- } else {
- $base = $name
- }
+ if $site {
+ $base = $site
+ } else {
+ $base = $name
+ }
- $target = "/etc/apache2/sites-available/${base}"
+ $target = "/etc/apache2/sites-available/${base}"
- $link_target = $ensure ? {
- present => $target,
- absent => absent
- }
+ $link_target = $ensure ? {
+ present => $target,
+ absent => absent
+ }
- if $content {
- file { $target:
- ensure => $ensure,
- content => $content,
- require => Package['apache2'],
- notify => Exec['service apache2 reload'],
- }
- } else {
- file { $target:
- ensure => $ensure,
- source => $source,
- require => Package['apache2'],
- notify => Exec['service apache2 reload'],
- }
- }
+ if $content {
+ file { $target:
+ ensure => $ensure,
+ content => $content,
+ require => Package['apache2'],
+ notify => Exec['service apache2 reload'],
+ }
+ } else {
+ file { $target:
+ ensure => $ensure,
+ source => $source,
+ require => Package['apache2'],
+ notify => Exec['service apache2 reload'],
+ }
+ }
- $symlink = "/etc/apache2/sites-enabled/${name}.conf"
+ $symlink = "/etc/apache2/sites-enabled/${name}.conf"
- file { "/etc/apache2/sites-enabled/${name}":
- ensure => absent,
- notify => Exec['service apache2 reload'],
- }
+ file { "/etc/apache2/sites-enabled/${name}":
+ ensure => absent,
+ notify => Exec['service apache2 reload'],
+ }
- if $ensure == present {
- file { $symlink:
- ensure => link,
- target => $link_target,
- notify => Exec['service apache2 reload'],
- }
- } else {
- file { $symlink:
- ensure => absent,
- notify => Exec['service apache2 reload'],
- }
- }
+ if $ensure == present {
+ file { $symlink:
+ ensure => link,
+ target => $link_target,
+ notify => Exec['service apache2 reload'],
+ }
+ } else {
+ file { $symlink:
+ ensure => absent,
+ notify => Exec['service apache2 reload'],
+ }
+ }
}