Skip to content

Commit

Permalink
Add option to add comments to the header of a vhost file
Browse files Browse the repository at this point in the history
You can pass

```puppet
comment => 'My comment',
```

or
```puppet
comment => [
  'comment 1',
  'comment 2',
],
```

Each element from the array will be added as a separate line.
  • Loading branch information
jovandeginste committed Nov 3, 2018
1 parent f2e41e4 commit 3ba1ccb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
$cas_validate_saml = undef,
Optional[String] $shib_compat_valid_user = undef,
Optional[Enum['On', 'on', 'Off', 'off', 'DNS', 'dns']] $use_canonical_name = undef,
Optional[Variant[String,Array[String]]] $comment = undef,
) {

# The base class must be included first because it is used by parameter defaults
Expand Down
10 changes: 9 additions & 1 deletion spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,10 @@
'keepalive' => 'on',
'keepalive_timeout' => '100',
'max_keepalive_requests' => '1000',
'comment' => [
'Comment 1',
'Comment 2',
],
}
end
let :facts do
Expand Down Expand Up @@ -554,7 +558,11 @@
is_expected.to contain_file('30-rspec.example.com.conf symlink').with('ensure' => 'link',
'path' => '/etc/apache2/sites-enabled/30-rspec.example.com.conf')
}
it { is_expected.to contain_concat__fragment('rspec.example.com-apache-header') }
it {
is_expected.to contain_concat__fragment('rspec.example.com-apache-header').with(
content: %r{^# Comment 1$},
)
}
it { is_expected.to contain_concat__fragment('rspec.example.com-docroot') }
it { is_expected.to contain_concat__fragment('rspec.example.com-aliases') }
it { is_expected.to contain_concat__fragment('rspec.example.com-itk') }
Expand Down
1 change: 1 addition & 0 deletions templates/vhost/_file_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Vhost template in module puppetlabs-apache
# Managed by Puppet
# ************************************
<%= [@comment].flatten.collect{|c| "# #{c}"}.join("\n") -%>

<VirtualHost <%= [@nvh_addr_port].flatten.compact.join(' ') %>>
<% if @servername and not @servername.empty? -%>
Expand Down

0 comments on commit 3ba1ccb

Please sign in to comment.