Skip to content

Commit

Permalink
Merge branch 'vhost_nopriority' of https://github.com/jbrunner/puppet…
Browse files Browse the repository at this point in the history
…labs-apache into jbrunner-vhost_nopriority

Conflicts:
	manifests/vhost.pp
  • Loading branch information
Morgan Haskel committed Feb 11, 2015
2 parents 0c032c7 + fb729a0 commit 9566fdb
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,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 @@ -1270,6 +1272,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
17 changes: 17 additions & 0 deletions spec/acceptance/custom_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,21 @@ class { 'apache': }
it { is_expected.to contain '# just a comment' }
end
end

describe 'custom_config without priority prefix' do
it 'applies cleanly' do
pp = <<-EOS
class { 'apache': }
apache::custom_config { 'prefix_test':
priority => false,
content => '# just a comment',
}
EOS
apply_manifest(pp, :catch_failures => true)
end

describe file("#{$vhost_dir}/prefix_test.conf") do
it { is_expected.to be_file }
end
end
end
16 changes: 16 additions & 0 deletions spec/acceptance/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1251,4 +1251,20 @@ class { 'apache': }
end
end

describe 'virtualhost without priority prefix' do
it 'applies cleanly' do
pp = <<-EOS
class { 'apache': }
apache::vhost { 'test.server':
priority => false,
docroot => '/tmp'
}
EOS
apply_manifest(pp, :catch_failures => true)
end

describe file("#{$vhost_dir}/test.server.conf") do
it { is_expected.to be_file }
end
end
end

0 comments on commit 9566fdb

Please sign in to comment.