OLD | NEW |
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. This may evolve to make use of more advanced repositories in the | 8 # server. This may evolve to make use of more advanced repositories in the |
9 # future (proxy to repository manager, or 3rd-party service, etc). | 9 # future (proxy to repository manager, or 3rd-party service, etc). |
10 # | 10 # |
11 # === parameters: | 11 # === parameters: |
12 # | 12 # |
13 # [*ensure*] | 13 # [*ensure*] |
14 # 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 |
15 # supported. | 15 # supported. |
16 # | 16 # |
17 # [*users*] | 17 # [*users*] |
18 # System users that should be created and added to the group that has | 18 # System users that should be created and added to the group that has |
19 # write permissions for the repository directory | 19 # write permissions for the repository directory |
20 # | 20 # |
21 define adblockplus::web::fileserver::repository ( | 21 define adblockplus::web::fileserver::repository ( |
22 $ensure = 'present', | 22 $ensure = 'present', |
23 $users = {}, | 23 $users = {}, |
24 ){ | 24 ){ |
25 | 25 |
26 $repositories_directory = "$adblockplus::directory/fileserver" | 26 $repositories_directory = "$adblockplus::directory/fileserver" |
27 $repository_directory = "$repositories_directory/$name" | 27 $repository_directory = "$repositories_directory/$name" |
28 $repository_host = "$name.$adblockplus::web::fileserver::domain" | 28 $repository_host = $name ? { |
| 29 'root' => "$adblockplus::web::fileserver::domain", |
| 30 default => "$name.$adblockplus::web::fileserver::domain", |
| 31 } |
| 32 $group_name = $name ? { |
| 33 'root' => 'www', |
| 34 default => "www-$name", |
| 35 } |
29 | 36 |
30 group {"www-$name": | 37 group {"$group_name": |
31 ensure => $ensure, | 38 ensure => $ensure, |
32 } | 39 } |
33 | 40 |
34 file {"$repository_directory": | 41 file {"$repository_directory": |
35 ensure => ensure_directory_state($ensure), | 42 ensure => ensure_directory_state($ensure), |
36 group => "www-$name", | 43 group => $group_name, |
37 mode => '0775', | 44 mode => '0775', |
38 require => [ | 45 require => [ |
39 File["$repositories_directory"], | 46 File["$repositories_directory"], |
40 Group["www-$name"], | 47 Group[$group_name], |
41 ], | 48 ], |
42 } | 49 } |
43 | 50 |
44 ensure_resources('adblockplus::user', $users, { | 51 ensure_resources('adblockplus::user', $users, { |
45 ensure => $ensure, | 52 ensure => $ensure, |
46 password_hash => '*', | 53 password_hash => '*', |
47 groups => ["www-$name"], | 54 groups => [$group_name], |
48 }) | 55 }) |
49 | 56 |
50 realize(File[$adblockplus::directory]) | 57 realize(File[$adblockplus::directory]) |
51 | 58 |
52 file {"/var/www/$repository_host": | 59 file {"/var/www/$repository_host": |
53 ensure => ensure_symlink_state($ensure), | 60 ensure => ensure_symlink_state($ensure), |
54 target => "$repository_directory", | 61 target => "$repository_directory", |
55 require => File["$repository_directory"], | 62 require => File["$repository_directory"], |
56 } | 63 } |
57 } | 64 } |
58 | 65 |
OLD | NEW |