Skip to content

Commit 3d8dbe4

Browse files
committed
Add alias_path possibility
1 parent 359cece commit 3d8dbe4

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

manifests/resource/location.pp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
$auth_basic = undef,
4040
$www_root = undef,
4141
$create_www_root = false,
42+
$alias_path = false,
4243
$owner = '',
4344
$groupowner = '',
4445
$redirect = undef,
@@ -99,21 +100,33 @@
99100
}
100101

101102
## Check for various error condtiions
103+
# Check vhost
102104
if ($vhost == undef) {
103105
fail('Cannot create a location reference without attaching to a virtual host')
104106
}
105-
if (($www_root == undef) and ($proxy == undef) and ($redirect == undef)) {
106-
fail('Cannot create a location reference without a www_root, proxy or redirect defined')
107+
# Check www_root/proxy/redirect/alias_path
108+
if (($www_root == undef) and ($proxy == undef) and ($redirect == undef) and ($alias_path == undef)) {
109+
fail('Cannot create a location reference without a www_root, proxy, redirect, or alias_path defined')
107110
}
108-
if (($www_root != undef) and ($proxy != undef)) {
109-
fail('Cannot define both directory and proxy in a virtual host')
111+
$mutual_exclusive = 0
112+
if ($www_root != undef) {
113+
$mutual_exclusive += 1;
110114
}
111-
if (($www_root != undef) and ($redirect != undef)) {
112-
fail('Cannot define both directory and redirect in a virtual host')
115+
if ($redirect != undef) {
116+
$mutual_exclusive += 1;
113117
}
114-
if (($proxy != undef) and ($redirect != undef)) {
115-
fail('Cannot define both proxy and redirect in a virtual host')
118+
if ($proxy != undef) {
119+
$mutual_exclusive += 1;
120+
}
121+
if ($alias_path != undef) {
122+
$mutual_exclusive += 1;
116123
}
124+
125+
if ($mutual_exclusive != 1) {
126+
fail("Cannot define more than one of the following values: www_root: '$www_root', redirect: '$redirect', proxy: '$proxy', and alias_path: '$alias_path'!")
127+
}
128+
129+
# Check auth
117130
if (($auth_basic_user_file != undef) and ($auth_basic == undef)) {
118131
fail('Cannot define auth_basic_user_file without auth_basic')
119132
}

templates/vhost/vhost_location_directory.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
location <%= @location %> {
2+
<% unless @www_root.nil? || @www_root.empty? -%>
23
root <%= @www_root %>;
4+
<% end -%>
5+
<% unless @alias_path.nil? || @alias_path.empty? -%>
6+
alias_path <%= @alias_path %>;
7+
<% end -%>
38
index <% @index_files.each do |i| %> <%= i %> <% end %>;
49
<% unless @auth_basic.nil? || @auth_basic.empty? -%>
510
auth_basic <%= @auth_basic %>;

0 commit comments

Comments
 (0)