summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-01-12 02:22:16 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-01-12 02:23:03 +0100
commitedf6ffe8b399679ba28cc5e558a6838919dd1ee8 (patch)
tree2c1a94da14e543e9f281a2302a243e9b75d528eb
parentRemove gandalf web. (diff)
downloadwebdav_server-edf6ffe8b399679ba28cc5e558a6838919dd1ee8.tar.gz
webdav_server-edf6ffe8b399679ba28cc5e558a6838919dd1ee8.tar.xz
Move webdav into profiles.
-rw-r--r--modules/profiles/manifests/webdav.pp75
-rw-r--r--modules/webdav_server/manifests/init.pp73
2 files changed, 70 insertions, 78 deletions
diff --git a/modules/profiles/manifests/webdav.pp b/modules/profiles/manifests/webdav.pp
index 88b2668..bd586f6 100644
--- a/modules/profiles/manifests/webdav.pp
+++ b/modules/profiles/manifests/webdav.pp
@@ -1,8 +1,73 @@
class profiles::webdav (
- Hash[String,Hash] $servers,
- Array[Array[String,2,2]] $users,
+ String $nginx_server,
+ String $file_path,
+ String $location,
+ String $passwd_file = "${file_path}/.htpasswd",
+ String $owner = 'http',
+ String $group = 'share',
+ Array[Array[String,2,2]] $users = [],
+ Array[String] $dav_methods = ['PUT', 'DELETE', 'MKCOL', 'COPY', 'MOVE'],
+ # Array[String] $dav_ext_methods = ['PROPFIND', 'OPTIONS'],
+ Hash[String,String] $dav_access = {
+ 'user' => 'rw',
+ 'group' => 'rw',
+ }
) {
- create_resources(webdav_server, $servers, {
- users => $users
- })
+
+ # TODO install this module somehow
+ # AUR: nginx-mainline-mod-dav-ext
+
+ require ::nginx
+
+ # $modname = 'ngx_http_dav_ext_module'
+ # # This assumes that the directory exists, and that
+ # # nginx::include_modules_enabled => true
+ # file { "/etc/nginx/modules-enabled/${modname}.conf":
+ # ensure => file,
+ # content => @("EOF")
+ # load_module /usr/lib/nginx/modules/${modname}.so;
+ # | EOF
+ # }
+
+ $lines = $users.map |$pair| { $pair.join(':') }.join("\n")
+
+ file {
+ default:
+ owner => $owner,
+ group => $group,
+ ;
+ $file_path:
+ ensure => 'directory',
+ mode => '0770',
+ recurse => 'false',
+ ;
+ $passwd_file:
+ ensure => 'file',
+ mode => '0660',
+ content => @("EOF")
+ # File managed by puppet
+ ${lines}
+ | EOF
+ ;
+ }
+
+ nginx::resource::location { $location:
+ server => $nginx_server,
+ location_alias => $file_path,
+ ssl => true,
+ ssl_only => true,
+
+ auth_basic => 'Enter password for dav access',
+ auth_basic_user_file => $passwd_file,
+
+ location_cfg_append => {
+ 'dav_methods' => $dav_methods.join(' '),
+ # 'dav_ext_methods' => $dav_ext_methods.join(' '),
+ 'dav_access' => $dav_access.map |$k, $v| { "${k}:${v}" }.join(' '),
+ 'client_body_temp_path' => "${file_path}/tmp",
+ 'create_full_put_path' => 'on',
+ 'autoindex' => 'on',
+ 'allow' => 'all',
+ }
+ }
}
diff --git a/modules/webdav_server/manifests/init.pp b/modules/webdav_server/manifests/init.pp
deleted file mode 100644
index f1a836c..0000000
--- a/modules/webdav_server/manifests/init.pp
+++ /dev/null
@@ -1,73 +0,0 @@
-define webdav_server (
- String $nginx_server,
- String $file_path,
- String $location = $name,
- String $passwd_file = "${file_path}/.htpasswd",
- String $owner = 'http',
- String $group = 'share',
- Array[Array[String,2,2]] $users = [],
- Array[String] $dav_methods = ['PUT', 'DELETE', 'MKCOL', 'COPY', 'MOVE'],
- Array[String] $dav_ext_methods = ['PROPFIND', 'OPTIONS'],
- Hash[String,String] $dav_access = {
- 'user' => 'rw',
- 'group' => 'rw',
- }
-) {
-
- # TODO install this module somehow
- # AUR: nginx-mainline-mod-dav-ext
-
- require ::nginx
-
- $modname = 'ngx_http_dav_ext_module'
- # This assumes that the directory exists, and that
- # nginx::include_modules_enabled => true
- file { "/etc/nginx/modules-enabled/${modname}.conf":
- ensure => file,
- content => @("EOF")
- load_module /usr/lib/nginx/modules/${modname}.so;
- | EOF
- }
-
- $lines = $users.map |$pair| { $pair.join(':') }.join("\n")
-
- file {
- default:
- owner => $owner,
- group => $group,
- ;
- $file_path:
- ensure => 'directory',
- mode => '0770',
- recurse => 'false',
- ;
- $passwd_file:
- ensure => 'file',
- mode => '0660',
- content => @("EOF")
- # File managed by puppet
- ${lines}
- | EOF
- ;
- }
-
- nginx::resource::location { $location:
- server => $nginx_server,
- location_alias => $file_path,
- ssl => true,
- ssl_only => true,
-
- auth_basic => 'Enter password for dav access',
- auth_basic_user_file => $passwd_file,
-
- location_cfg_append => {
- 'dav_methods' => $dav_methods.join(' '),
- 'dav_ext_methods' => $dav_ext_methods.join(' '),
- 'dav_access' => $dav_access.map |$k, $v| { "${k}:${v}" }.join(' '),
- 'client_body_temp_path' => "${file_path}/tmp",
- 'create_full_put_path' => 'on',
- 'autoindex' => 'on',
- 'allow' => 'all',
- }
- }
-}