LEFT | RIGHT |
1 # == Type: adblockplus::web::fileserver::repository | 1 # == Type: adblockplus::web::fileserver::repository |
2 # | 2 # |
3 # Manage a repository on a fileserver. | 3 # Manage a repository on a fileserver. |
4 # | 4 # |
5 # A repository is a site where a group of people can upload and artifacts. | 5 # A repository is a site where a group of people can upload and artifacts. |
6 # | 6 # |
7 # In its current form, a repository is simply a directory exposed on a web | 7 # In its current form, a repository is simply a directory exposed on a web |
8 # server. | 8 # server. This may evolve to make use of more advanced repositories in the |
9 # | 9 # future (proxy to repository manager, or 3rd-party service, etc). |
10 # The contents of a repository is served on a subdomain of the fileserver. | |
11 # | 10 # |
12 # === parameters: | 11 # === parameters: |
13 # | 12 # |
14 # [*ensure*] | 13 # [*ensure*] |
15 # Whether to set up the repository or not. Removing repositories is not | 14 # Whether to set up the repository or not. Removing repositories is not |
16 # supported. | 15 # supported. |
17 # | 16 # |
18 # [*fileserver_domain*] | 17 # Members are handled manually on the target server for now. |
19 # A string which is the name of the fileserver domain, under which | 18 # Figure out how to provision them some day. |
20 # each repository has a subdomain. | |
21 # | |
22 # [*certificate*] | |
23 # The name of the SSL certificate file within modules/private/files, if any. | |
24 # Requires a private_key as well. | |
25 # | |
26 # [*fileserver_domain*] | |
27 # A string which is the name of the fileserver domain, under which | |
28 # each repository has a subdomain. | |
29 # | |
30 # TODO Figure out how to inherit and use the parent's class domain instead of | |
31 # having to duplicate it here. | |
32 # | |
33 # [*members*] | |
34 # An array of usernames that should have write access to the repository. | |
35 # | |
36 # TODO Members are handled manually on the target server for now. | |
37 # Figure out how to provision them. | |
38 # | 19 # |
39 define adblockplus::web::fileserver::repository ( | 20 define adblockplus::web::fileserver::repository ( |
40 $ensure = 'present', | 21 $ensure = 'present', |
41 $certificate = $::certificate, | |
42 $private_key = $::private_key, | |
43 $fileserver_domain = "$::fileserver_domain", | |
44 $members = [], | |
45 ){ | 22 ){ |
46 | 23 |
47 $repositories_directory = "$adblockplus::directory/fileserver/repositories" | 24 $repositories_directory = "$adblockplus::directory/fileserver" |
48 $repository_domain = "$name.$fileserver_domain" | |
49 $repository_directory = "$repositories_directory/$name" | 25 $repository_directory = "$repositories_directory/$name" |
| 26 $repository_host = "$name.$adblockplus::web::fileserver::domain" |
50 | 27 |
51 if $ensure !~ /^(absent|purged)$/ { | 28 group {"www-$name": |
52 group {"www-$name": | 29 ensure => $ensure, |
53 ensure => present, | 30 } |
54 } | |
55 | 31 |
56 file {"$repositories_directory/$name": | 32 file {"$repository_directory": |
57 ensure => directory, | 33 ensure => ensure_directory_state($ensure), |
58 group => "www-$name", | 34 group => "www-$name", |
59 mode => '0775', | 35 mode => '0775', |
60 require => [ | 36 require => [ |
61 File["$repositories_directory"], | 37 File["$repositories_directory"], |
62 Group["www-$name"], | 38 Group["www-$name"], |
63 ], | 39 ], |
64 } | 40 } |
65 | 41 |
66 realize(File[$adblockplus::directory]) | 42 realize(File[$adblockplus::directory]) |
67 | 43 |
68 # TODO Figure out how to use $adblockplus::web::directory insetad of hardcod
ed path | 44 file {"/var/www/$repository_host": |
69 file {"/var/www/$name": | 45 ensure => ensure_symlink_state($ensure), |
70 ensure => link, | 46 target => "$repository_directory", |
71 target => "$repositories_directory/$name", | 47 require => File["$repository_directory"], |
72 require => [ | |
73 File["$repositories_directory/$name"], | |
74 Package['nginx'], | |
75 ], | |
76 } | |
77 | |
78 nginx::hostconfig{ "$repository_domain": | |
79 content => template('adblockplus/web/fileserver/repository.conf.erb'), | |
80 is_default => $is_default, | |
81 certificate => $certificate, | |
82 private_key => $private_key, | |
83 domain => $repository_domain, | |
84 log => "access_log_fileserver_repository_$repository_domain", | |
85 } | |
86 } | 48 } |
87 } | 49 } |
| 50 |
LEFT | RIGHT |