Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 # == Class: adblockplus::web::static | |
2 # | |
3 # Manage a simple Nginx-based webserver for static content | |
4 # that uses a customizable deployment script to e.g. fetch the content | |
5 # from a repository server (ref. http://hub.eyeo.com/issues/4523) | |
6 # | |
7 # === Parameters: | |
8 # | |
9 # [*domain*] | |
10 # The domain name for the website. | |
11 # | |
12 # [*ssl_certificate*] | |
13 # The name of the SSL certificate file within modules/private/files, if any. | |
14 # Requires a private_key as well. | |
15 # | |
16 # [*ssl_private_key*] | |
17 # The name of the private key file within modules/private/files, if any. | |
18 # Requires a certificate as well. | |
19 # | |
20 # [*ensure*] | |
21 # Whether to set up the website or not. | |
mathias
2018/04/17 15:57:13
This should mention possible values, e.g. "absent"
f.lopez
2018/04/17 18:02:22
Acknowledged.
| |
22 # | |
23 # [*deploy_user*] | |
24 # User that will be used to issue commands. | |
25 # | |
26 # [*deploy_user_authorized_keys*] | |
27 # Array of public keys that will have access to ssh commands | |
28 # | |
29 # [*hooks*] | |
30 # Hash of adblockplus::web::static::hook items to set up in this context. | |
31 # | |
32 # === Examples: | |
33 # | |
34 # class {'adblockplus::web::static': | |
35 # domain => 'help.eyeo.com', | |
36 # hooks => { | |
37 # own-uname => { | |
38 # file => { | |
39 # content => 'uname -a', | |
40 # } | |
41 # } | |
42 # }, | |
43 # } | |
44 # | |
45 class adblockplus::web::static ( | |
46 $domain, | |
47 $ssl_certificate = undef, | |
48 $ssl_private_key = undef, | |
49 $ensure = 'present', | |
50 $deploy_user = 'web-deploy', | |
51 $deploy_user_authorized_keys = [], | |
52 $hooks = {}, | |
53 ) { | |
54 | |
55 include adblockplus::web | |
56 include nginx | |
57 include geoip | |
mathias
2018/04/17 15:57:13
Why?
f.lopez
2018/04/17 18:02:22
you are right, there is no need for this just yet.
| |
58 include ssh | |
59 | |
60 File { | |
61 mode => '0755', | |
62 owner => $deploy_user, | |
63 group => $deploy_user, | |
64 } | |
65 | |
66 ensure_resource('file', "/var/www/$domain", { | |
67 ensure => ensure_directory_state($ensure), | |
68 owner => 'www-data', | |
69 group => 'www-data', | |
70 }) | |
71 | |
72 ensure_resource('nginx::hostconfig', $title, { | |
73 content => template('adblockplus/web/static.conf.erb'), | |
74 certificate => $ssl_certificate, | |
75 domain => $domain, | |
76 is_default => true, | |
77 private_key => $ssl_private_key, | |
78 log => 'web.access.log', | |
79 }) | |
80 | |
81 $content = [ | |
82 "Match User ${deploy_user}", | |
83 'AllowTcpForwarding no', | |
84 'X11Forwarding no', | |
85 'AllowAgentForwarding no', | |
86 'GatewayPorts no', | |
87 'ForceCommand /usr/local/bin/hooks_wrapper $SSH_ORIGINAL_COMMAND', | |
88 ] | |
89 | |
90 ensure_resource('concat::fragment', 'helpcenter', { | |
91 content => join($content, "\n\t"), | |
92 ensure => 'present', | |
93 target => 'sshd_config', | |
94 order => '20', | |
95 }) | |
96 | |
97 ensure_resource('adblockplus::user', $deploy_user, { | |
98 authorized_keys => $deploy_user_authorized_keys, | |
99 ensure => $ensure, | |
100 shell => '/bin/bash', | |
101 groups => ['www-data'], | |
102 }) | |
103 | |
104 $wrapper_path = "/home/${deploy_user}/bin" | |
105 ensure_resource('file', 'commands_dir', { | |
106 path => $wrapper_path, | |
107 ensure => ensure_directory_state($ensure), | |
108 }) | |
109 | |
110 ensure_resource('file', '/usr/local/bin/hooks_wrapper', { | |
111 ensure => ensure_file_state($ensure), | |
112 content => template('adblockplus/web/hooks_wrapper.sh.erb'), | |
113 }) | |
114 | |
115 # https://docs.puppet.com/puppet/latest/function.html#createresources | |
116 create_resources('adblockplus::web::static::hook', $hooks) | |
117 } | |
118 | |
OLD | NEW |