Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added unmanaged_path and custom_fragment options to userdir #1931

Merged
merged 3 commits into from
Jun 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions manifests/mod/userdir.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
#
# @param options
# Configures what features are available in a particular directory.
#
# @param unmanaged_path
# Toggles whether to manage path in userdir.conf
#
# @param custom_fragment
# Custom configuration to be added to userdir.conf
#
# @see https://httpd.apache.org/docs/current/mod/mod_userdir.html for additional documentation.
#
Expand All @@ -32,6 +38,8 @@
$path = '/home/*/public_html',
$overrides = [ 'FileInfo', 'AuthConfig', 'Limit', 'Indexes' ],
$options = [ 'MultiViews', 'Indexes', 'SymLinksIfOwnerMatch', 'IncludesNoExec' ],
$unmanaged_path = false,
$custom_fragment = undef,
) {
include ::apache
$_apache_version = pick($apache_version, $apache::apache_version)
Expand Down
19 changes: 19 additions & 0 deletions spec/classes/mod/userdir_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,24 @@
it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*UserDir\s+public_html /usr/web http://www\.example\.com/$}) }
it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*\<Directory\s+\"public_html /usr/web http://www\.example\.com/\"\>$}) }
end
context 'with unmanaged_path set to true' do
let :params do
{
unmanaged_path: true,
}
end

it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*UserDir\s+/home/\*/public_html$}) }
it { is_expected.not_to contain_file('userdir.conf').with_content(%r{^\s*\<Directory }) }
end
context 'with custom_fragment set to something' do
let :params do
{
custom_fragment: 'custom_test_string',
}
end

it { is_expected.to contain_file('userdir.conf').with_content(%r{custom_test_string}) }
end
end
end
5 changes: 5 additions & 0 deletions templates/mod/userdir.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<% end -%>
UserDir <%= @_path %>

<%- if ! @unmanaged_path -%>
<Directory "<%= @_path %>">
AllowOverride <%= @overrides.join(' ') %>
Options <%= @options.join(' ') %>
Expand All @@ -24,4 +25,8 @@
<%- end -%>
</LimitExcept>
</Directory>
<%- end -%>
<%- if @custom_fragment -%>
<%= @custom_fragment %>
<%- end -%>
</IfModule>