15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'manifests/site.pp', line 15
define nginx::site (
String $proxy_target,
String $aws_access_key_id,
String $aws_secret_access_key,
String $email,
Integer $port = 443,
Array[String] $bind_addresses = ['*', '[::]'],
Array[String] $allow_ranges = [],
String $csp = "default-src 'self' http: https: ws: wss: data: blob: 'unsafe-inline'; frame-ancestors 'self';",
Hash[String, String] $proxy_params = {},
Optional[String] $custom_file = undef,
String $site = $title,
Hash[String, String] $users = {},
) {
include nginx
$contents = $custom_file ? {
undef => template('nginx/site.conf.erb'),
default => $custom_file,
}
$hook_script = "#!/usr/bin/env bash
cp \$LEGO_CERT_PATH /etc/nginx/ssl/${site}.crt
cp \$LEGO_CERT_KEY_PATH /etc/nginx/ssl/${site}.key
/usr/bin/systemctl reload nginx"
acme::certificate { $site:
hook_script => $hook_script,
aws_access_key_id => $aws_access_key_id,
aws_secret_access_key => $aws_secret_access_key,
email => $email,
}
-> file { "/etc/nginx/sites/${site}.conf":
ensure => file,
owner => 'root',
group => 'http',
mode => '0640',
content => $contents,
notify => Service['nginx'],
}
if length($users) > 0 {
file { "/etc/nginx/creds/${site}.htpasswd":
ensure => file,
owner => 'root',
group => 'http',
mode => '0640',
content => template('nginx/htpasswd.erb'),
notify => Service['nginx'],
}
}
}
|