diff --git a/manifests/mod/userdir.pp b/manifests/mod/userdir.pp index ea6ee193dd..203b93dd11 100644 --- a/manifests/mod/userdir.pp +++ b/manifests/mod/userdir.pp @@ -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 diff --git a/spec/classes/mod/userdir_spec.rb b/spec/classes/mod/userdir_spec.rb new file mode 100644 index 0000000000..9f23ba274b --- /dev/null +++ b/spec/classes/mod/userdir_spec.rb @@ -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 diff --git a/templates/mod/userdir.conf.erb b/templates/mod/userdir.conf.erb index c02a9188d6..323a1af1da 100644 --- a/templates/mod/userdir.conf.erb +++ b/templates/mod/userdir.conf.erb @@ -2,7 +2,7 @@ <% if @disable_root -%> UserDir disabled root <% end -%> - UserDir <%= @home %>/*/<%= @dir %> + UserDir <%= @_path %> /*/<%= @dir %>"> AllowOverride <%= @overrides.join(' ') %>