Skip to content

Commit

Permalink
Omit priority prefix if {priority => false} passed to vhost/custom_co…
Browse files Browse the repository at this point in the history
…nfig

Do not prefix filenames in apache::vhost and apache::custom_config when
priority is set to false.
  • Loading branch information
Joshua Brunner committed Nov 20, 2014
1 parent 8a09b36 commit fb729a0
Show file tree
Hide file tree
Showing 5 changed files with 793 additions and 746 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ The content of the configuration file. Only one of `$content` and `$source` can

The priority of the configuration file, used for ordering. Defaults to '25'.

Pass priority `false` to omit the priority prefix in file names.

#####`source`

The source of the configuration file. Only one of `$content` and `$source` can be specified.
Expand Down Expand Up @@ -1170,6 +1172,8 @@ If nothing matches the priority, the first name-based vhost is used. Likewise, p

*Note:* You should not need to use this parameter. However, if you do use it, be aware that the `default_vhost` parameter for `apache::vhost` passes a priority of '15'.

Pass priority `false` to omit the priority prefix in file names.

#####`proxy_dest`

Specifies the destination address of a [ProxyPass](http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypass) configuration. Defaults to 'undef'.
Expand Down
13 changes: 10 additions & 3 deletions manifests/custom_config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@

validate_bool($verify_config)

if $priority {
$priority_prefix = "${priority}-"
} else {
$priority_prefix = ''
}

## Apache include does not always work with spaces in the filename
$filename = regsubst($name, ' ', '_', 'G')
$filename_middle = regsubst($name, ' ', '_', 'G')
$filename = "${priority_prefix}${filename_middle}.conf"

if ! $verify_config or $ensure == 'absent' {
$notifies = Service['httpd']
Expand All @@ -34,7 +41,7 @@

file { "apache_${name}":
ensure => $ensure,
path => "${confdir}/${priority}-${filename}.conf",
path => "${confdir}/${filename}",
content => $content,
source => $source,
require => Package['httpd'],
Expand All @@ -51,7 +58,7 @@
}

exec { "remove ${name} if invalid":
command => "/bin/rm ${confdir}/${priority}-${filename}.conf",
command => "/bin/rm ${confdir}/${filename}",
unless => $verify_command,
subscribe => File["apache_${name}"],
refreshonly => true,
Expand Down
Loading

0 comments on commit fb729a0

Please sign in to comment.