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

(MODULES-4933) Allow custom UserDir string #1650

Merged
merged 1 commit into from
Jul 19, 2017
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
20 changes: 18 additions & 2 deletions manifests/mod/userdir.pp
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
class apache::mod::userdir (
$home = '/home',
$dir = 'public_html',
$home = undef,
$dir = undef,
$disable_root = true,
$apache_version = undef,
$path = '/home/*/public_html',
$overrides = [ 'FileInfo', 'AuthConfig', 'Limit', 'Indexes' ],
$options = [ 'MultiViews', 'Indexes', 'SymLinksIfOwnerMatch', 'IncludesNoExec' ],
) {
include ::apache
$_apache_version = pick($apache_version, $apache::apache_version)

if $home or $dir {
$_home = $home ? {
undef => '/home',
default => $home,
}
$_dir = $dir ? {
undef => 'public_html',
default => $dir,
}
warning('home and dir are deprecated; use path instead')
$_path = "${_home}/*/${_dir}"
} else {
$_path = $path
}

::apache::mod { 'userdir': }

# Template uses $home, $dir, $disable_root, $_apache_version
Expand Down
53 changes: 53 additions & 0 deletions spec/classes/mod/userdir_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
require 'spec_helper'

describe 'apache::mod::userdir', :type => :class do
context "on a Debian OS" do
let :pre_condition do
'class { "apache":
default_mods => false,
mod_dir => "/tmp/junk",
}'
end
let :facts do
{
:lsbdistcodename => 'squeeze',
:osfamily => 'Debian',
:operatingsystemrelease => '6',
:operatingsystemmajrelease => '6',
:concat_basedir => '/dne',
:operatingsystem => 'Debian',
:id => 'root',
:kernel => 'Linux',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:is_pe => false,
}
end
context "default parameters" do
it { should compile }
end
context "with dir set to something" do
let :params do
{
:dir => 'hi',
}
end
it { should contain_file("userdir.conf").with_content(%r{^\s*UserDir\s+/home/\*/hi$})}
end
context "with home set to something" do
let :params do
{
:home => '/u',
}
end
it { should contain_file("userdir.conf").with_content(%r{^\s*UserDir\s+/u/\*/public_html$})}
end
context "with path set to something" do
let :params do
{
:path => 'public_html /usr/web http://www.example.com/',
}
end
it { should contain_file("userdir.conf").with_content(%r{^\s*UserDir\s+public_html /usr/web http://www\.example\.com/$})}
end
end
end
2 changes: 1 addition & 1 deletion templates/mod/userdir.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<% if @disable_root -%>
UserDir disabled root
<% end -%>
UserDir <%= @home %>/*/<%= @dir %>
UserDir <%= @_path %>

<Directory "<%= @home %>/*/<%= @dir %>">
AllowOverride <%= @overrides.join(' ') %>
Expand Down