Skip to content

Commit 9566fdb

Browse files
author
Morgan Haskel
committed
Merge branch 'vhost_nopriority' of https://github.com/jbrunner/puppetlabs-apache into jbrunner-vhost_nopriority
Conflicts: manifests/vhost.pp
2 parents 0c032c7 + fb729a0 commit 9566fdb

4 files changed

Lines changed: 47 additions & 3 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,8 @@ The content of the configuration file. Only one of `$content` and `$source` can
482482

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

485+
Pass priority `false` to omit the priority prefix in file names.
486+
485487
#####`source`
486488

487489
The source of the configuration file. Only one of `$content` and `$source` can be specified.
@@ -1270,6 +1272,8 @@ If nothing matches the priority, the first name-based vhost is used. Likewise, p
12701272

12711273
*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'.
12721274

1275+
Pass priority `false` to omit the priority prefix in file names.
1276+
12731277
#####`proxy_dest`
12741278

12751279
Specifies the destination address of a [ProxyPass](http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypass) configuration. Defaults to 'undef'.

manifests/custom_config.pp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@
2323

2424
validate_bool($verify_config)
2525

26+
if $priority {
27+
$priority_prefix = "${priority}-"
28+
} else {
29+
$priority_prefix = ''
30+
}
31+
2632
## Apache include does not always work with spaces in the filename
27-
$filename = regsubst($name, ' ', '_', 'G')
33+
$filename_middle = regsubst($name, ' ', '_', 'G')
34+
$filename = "${priority_prefix}${filename_middle}.conf"
2835

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

3542
file { "apache_${name}":
3643
ensure => $ensure,
37-
path => "${confdir}/${priority}-${filename}.conf",
44+
path => "${confdir}/${filename}",
3845
content => $content,
3946
source => $source,
4047
require => Package['httpd'],
@@ -51,7 +58,7 @@
5158
}
5259

5360
exec { "remove ${name} if invalid":
54-
command => "/bin/rm ${confdir}/${priority}-${filename}.conf",
61+
command => "/bin/rm ${confdir}/${filename}",
5562
unless => $verify_command,
5663
subscribe => File["apache_${name}"],
5764
refreshonly => true,

spec/acceptance/custom_config_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,21 @@ class { 'apache': }
3535
it { is_expected.to contain '# just a comment' }
3636
end
3737
end
38+
39+
describe 'custom_config without priority prefix' do
40+
it 'applies cleanly' do
41+
pp = <<-EOS
42+
class { 'apache': }
43+
apache::custom_config { 'prefix_test':
44+
priority => false,
45+
content => '# just a comment',
46+
}
47+
EOS
48+
apply_manifest(pp, :catch_failures => true)
49+
end
50+
51+
describe file("#{$vhost_dir}/prefix_test.conf") do
52+
it { is_expected.to be_file }
53+
end
54+
end
3855
end

spec/acceptance/vhost_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,4 +1251,20 @@ class { 'apache': }
12511251
end
12521252
end
12531253

1254+
describe 'virtualhost without priority prefix' do
1255+
it 'applies cleanly' do
1256+
pp = <<-EOS
1257+
class { 'apache': }
1258+
apache::vhost { 'test.server':
1259+
priority => false,
1260+
docroot => '/tmp'
1261+
}
1262+
EOS
1263+
apply_manifest(pp, :catch_failures => true)
1264+
end
1265+
1266+
describe file("#{$vhost_dir}/test.server.conf") do
1267+
it { is_expected.to be_file }
1268+
end
1269+
end
12541270
end

0 commit comments

Comments
 (0)