| Left: | ||
| Right: | 
| LEFT | RIGHT | 
|---|---|
| 1 # == Class: adblockplus::web::fileserver | 1 # == Class: adblockplus::web::fileserver | 
| 2 # | 2 # | 
| 3 # Serves files for different repositories over https. | 3 # A fileserver serves multiple file repositories. | 
| 4 # | 4 # | 
| 5 # === Parameters: | 5 # === Parameters: | 
| 6 # | 6 # | 
| 7 # [*domain*] | 7 # [*domain*] | 
| 8 # A string for the domain serving traffic. | 8 # A string which is the name of the fileserver domain, under which | 
| 
 
mathias
2017/09/22 07:00:14
Why would the domain want to have some string? And
 
f.nicolaisen
2017/09/22 07:57:44
Acknowledged.
 
 | |
| 9 # each repository has a subdomain. | |
| 9 # | 10 # | 
| 10 # [*certificate*] | 11 # [*certificate*] | 
| 11 # The name of the SSL certificate file within modules/private/files, if any. | 12 # The name of the SSL certificate file within modules/private/files, if any. | 
| 12 # Requires a private_key as well. | 13 # Requires a private_key as well. | 
| 13 # | 14 # | 
| 14 # [*private_key*] | 15 # [*private_key*] | 
| 15 # The name of the private key file within modules/private/files, if any. | 16 # The name of the private key file within modules/private/files, if any. | 
| 16 # Requires a certificate as well. | 17 # Requires a certificate as well. | 
| 17 # | 18 # | 
| 18 # [*is_default*] | 19 # [*is_default*] | 
| 
 
mathias
2017/09/22 07:00:14
The fileserver is a standalone HTTPd setup intende
 
f.nicolaisen
2017/09/22 07:57:44
Acknowledged.
 
 | |
| 19 # Passed on to nginx (whether or not the site config should be default). | 20 # Passed on to nginx (whether or not the site config should be default). | 
| 20 # | 21 # | 
| 21 # [*repository*] | 22 # [*repositories*] | 
| 
 
mathias
2017/09/22 07:00:14
The documentation of the $repository parameter doe
 
f.nicolaisen
2017/09/22 07:57:43
Acknowledged.
 
 | |
| 22 # A string that is the name of the repository to serve. A repository | 23 # A collection (hash) of repositories to serve. | 
| 23 # is a collection of files uploaded by a group of users. | 24 # The contents of a repository is served on a subdomain of the fileserver. | 
| 24 # | |
| 25 # TODO Convert this into a collection of *repositories* | |
| 26 # | 25 # | 
| 27 class adblockplus::web::fileserver( | 26 class adblockplus::web::fileserver( | 
| 27 $ensure = 'present', | |
| 28 $domain, | 28 $domain, | 
| 29 $certificate, | 29 $certificate = undef, | 
| 
 
mathias
2017/09/22 07:00:14
Both $certificate and $private_key should default
 
f.nicolaisen
2017/09/22 07:57:43
Acknowledged.
 
 | |
| 30 $private_key, | 30 $private_key = undef, | 
| 31 $is_default=false, | |
| 32 $repositories={}, | 31 $repositories={}, | 
| 33 ){ | 32 ){ | 
| 34 | 33 | 
| 35 include nginx | 34 include nginx | 
| 36 include adblockplus | 35 include adblockplus | 
| 37 include adblockplus::web | 36 include adblockplus::web | 
| 38 | 37 | 
| 39 nginx::hostconfig{$domain: | |
| 40 source => 'puppet:///modules/adblockplus/nginx/fileserver.conf', | |
| 41 is_default => $is_default, | |
| 42 certificate => $certificate, | |
| 43 private_key => $private_key, | |
| 44 log => 'access_log_files' | |
| 45 } | |
| 46 | |
| 47 # Root directory for serving repositories | |
| 48 realize(File[$adblockplus::directory]) | 38 realize(File[$adblockplus::directory]) | 
| 49 | 39 | 
| 50 | 40 file {"$adblockplus::directory/fileserver": | 
| 51 file {[ | |
| 52 "$adblockplus::directory/fileserver", | |
| 53 "$adblockplus::directory/fileserver/repositories" | |
| 54 ]: | |
| 55 ensure => directory, | 41 ensure => directory, | 
| 56 } | 42 } | 
| 57 | 43 | 
| 44 ensure_resources('adblockplus::web::fileserver::repository', $repositories, { | |
| 45 ensure => 'present', | |
| 46 }) | |
| 58 | 47 | 
| 59 if !empty($repositories) { | 48 nginx::hostconfig{ "$domain": | 
| 
 
mathias
2017/09/22 07:00:14
This conditional is not necessary: Iterating throu
 
f.nicolaisen
2017/09/22 07:57:44
Acknowledged.
 
 | |
| 60 ensure_resources('repository', $repositories, { | 49 source => 'puppet:///modules/adblockplus/nginx/fileserver.conf', | 
| 
 
mathias
2017/09/22 07:00:14
Please use the fully qualified name here, e.g. adb
 
f.nicolaisen
2017/09/22 07:57:43
Acknowledged.
 
 | |
| 61 ensure => 'present', | 50 is_default => true, | 
| 62 }) | 51 certificate => $certificate, | 
| 52 private_key => $private_key, | |
| 53 log => 'access_log_fileserver', | |
| 63 } | 54 } | 
| 64 | |
| 65 } | 55 } | 
| 66 | 56 | 
| LEFT | RIGHT |