Skip to content

Commit c2103f6

Browse files
authored
Merge pull request #2164 from hunner/patch/alt_userdir
Allow custom userdir directives
2 parents a0416c3 + 9ca3773 commit c2103f6

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

REFERENCE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6670,6 +6670,7 @@ The following parameters are available in the `apache::mod::userdir` class:
66706670

66716671
* [`home`](#home)
66726672
* [`dir`](#dir)
6673+
* [`userdir`](#userdir)
66736674
* [`disable_root`](#disable_root)
66746675
* [`apache_version`](#apache_version)
66756676
* [`path`](#path)
@@ -6694,6 +6695,14 @@ Data type: `Any`
66946695

66956696
Default value: ``undef``
66966697

6698+
##### <a name="userdir"></a>`userdir`
6699+
6700+
Data type: `Optional[String[1]]`
6701+
6702+
Path or directory name to be used as the UserDir.
6703+
6704+
Default value: ``undef``
6705+
66976706
##### <a name="disable_root"></a>`disable_root`
66986707

66996708
Data type: `Any`

manifests/mod/userdir.pp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
#
77
# @param dir
88
# *Deprecated* Path from user's home directory to public directory.
9-
#
9+
#
10+
# @param userdir
11+
# Path or directory name to be used as the UserDir.
12+
#
1013
# @param disable_root
1114
# Toggles whether to allow use of root directory.
1215
#
@@ -33,6 +36,7 @@
3336
class apache::mod::userdir (
3437
$home = undef,
3538
$dir = undef,
39+
Optional[String[1]] $userdir = undef,
3640
$disable_root = true,
3741
$apache_version = undef,
3842
$path = '/home/*/public_html',
@@ -59,6 +63,8 @@
5963
$_path = $path
6064
}
6165

66+
$_userdir = pick($userdir, $_path)
67+
6268
::apache::mod { 'userdir': }
6369

6470
# Template uses $home, $dir, $disable_root, $_apache_version

spec/classes/mod/userdir_spec.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,23 @@
3939
context 'with path set to something' do
4040
let :params do
4141
{
42-
path: 'public_html /usr/web http://www.example.com/',
42+
path: '/home/*/*/public_html',
4343
}
4444
end
4545

46-
it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*UserDir\s+public_html /usr/web http://www\.example\.com/$}) }
47-
it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*\<Directory\s+\"public_html /usr/web http://www\.example\.com/\"\>$}) }
46+
it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*UserDir\s+/home/\*/\*/public_html$}) }
47+
it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*\<Directory\s+\"/home/\*/\*/public_html\"\>$}) }
48+
end
49+
context 'with userdir set to something' do
50+
let :params do
51+
{
52+
path: '/home/*/*/public_html',
53+
userdir: 'public_html',
54+
}
55+
end
56+
57+
it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*UserDir\s+public_html$}) }
58+
it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*\<Directory\s+\"/home/\*/\*/public_html\"\>$}) }
4859
end
4960
context 'with unmanaged_path set to true' do
5061
let :params do

templates/mod/userdir.conf.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<% if @disable_root -%>
33
UserDir disabled root
44
<% end -%>
5-
UserDir <%= @_path %>
5+
UserDir <%= @_userdir %>
66

77
<%- if ! @unmanaged_path -%>
88
<Directory "<%= @_path %>">

0 commit comments

Comments
 (0)