Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: modules/adblockplus/manifests/web/static.pp

Issue 29733731: #7320 - Introduce helpcenter role (Closed)
Left Patch Set: For comments 2 to 4 Created April 2, 2018, 10:36 p.m.
Right Patch Set: Make documentation right Created April 17, 2018, 8:03 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « hiera/roles/web/static/helpcenter.yaml ('k') | modules/adblockplus/manifests/web/static/hook.pp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # == Class: adblockplus::web::static 1 # == Class: adblockplus::web::static
2 # 2 #
3 # Manage a simple Nginx-based webserver for static content 3 # Manage a simple Nginx-based webserver for static content
4 # that uses a customizable deployment script to e.g. fetch the 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) 5 # from a repository server (ref. http://hub.eyeo.com/issues/4523)
6 #
mathias 2018/04/05 01:12:30 There's one empty line too many here.
f.lopez 2018/04/10 02:45:39 Acknowledged.
7 # 6 #
8 # === Parameters: 7 # === Parameters:
9 # 8 #
10 # [*domain*] 9 # [*domain*]
11 # The domain name for the website. 10 # The domain name for the website.
12 # 11 #
13 # [*ssl_certificate*] 12 # [*ssl_certificate*]
14 # The name of the SSL certificate file within modules/private/files, if any. 13 # The name of the SSL certificate file within modules/private/files, if any.
15 # Requires a private_key as well. 14 # Requires a private_key as well.
16 # 15 #
17 # [*ssl_private_key*] 16 # [*ssl_private_key*]
18 # The name of the private key file within modules/private/files, if any. 17 # The name of the private key file within modules/private/files, if any.
19 # Requires a certificate as well. 18 # Requires a certificate as well.
20 # 19 #
21 # [*ensure*] 20 # [*ensure*]
22 # Whether to set up the website or not. 21 # Whether to set up the website or not, e.g. "asbsent" or "present".
23 # 22 #
24 # [*deploy_user*] 23 # [*deploy_user*]
25 # User that will be used to issue commands. 24 # User that will be used to issue commands.
26 # 25 #
27 # [*deploy_user_authorized_keys*] 26 # [*deploy_user_authorized_keys*]
28 # Array of public keys that will have access to ssh commands 27 # Array of public keys that will have access to ssh commands
29 # 28 #
30 # [*hooks*] 29 # [*hooks*]
31 # Hash of adblockplus::web::static::hook items to set up in this context. 30 # Hash of adblockplus::web::static::hook items to set up in this context.
32 # 31 #
33 # === Examples: 32 # === Examples:
34 # 33 #
35 # class {'adblockplus::web::static': 34 # class {'adblockplus::web::static':
36 # domain => 'help.eyeo.com', 35 # domain => 'help.eyeo.com',
37 # hooks => { 36 # hooks => {
38 # own-uname => { 37 # uname => {
39 # file => { 38 # file => {
40 # content => 'uname -a', 39 # content => 'uname -a',
41 # } 40 # },
42 # } 41 # },
42 # uptime => {
43 # file => {
44 # target => '/usr/bin/uptime',
45 # ensure => 'link',
46 # },
47 # },
43 # }, 48 # },
44 # } 49 # }
45 # 50 #
46 class adblockplus::web::static ( 51 class adblockplus::web::static (
47 $domain, 52 $domain,
48 $ssl_certificate = undef, 53 $ssl_certificate = undef,
49 $ssl_private_key = undef, 54 $ssl_private_key = undef,
50 $ensure = 'present', 55 $ensure = 'present',
51 $deploy_user = 'web-deploy', 56 $deploy_user = 'web-deploy',
52 $deploy_user_authorized_keys = undef, 57 $deploy_user_authorized_keys = [],
mathias 2018/04/05 01:12:30 This should default to an empty list.
f.lopez 2018/04/10 02:45:39 Acknowledged.
53 $hooks = {}, 58 $hooks = {},
54 ) { 59 ) {
55 60
56 include adblockplus::web 61 include adblockplus::web
57 include nginx 62 include nginx
58 include geoip
59 include ssh 63 include ssh
60 64
61 File { 65 File {
62 mode => '0755', 66 mode => '0755',
63 owner => $deploy_user, 67 owner => $deploy_user,
64 group => $deploy_user, 68 group => $deploy_user,
65 } 69 }
66 70
67 ensure_resource('file', "/var/www/$domain", { 71 ensure_resource('file', "/var/www/$domain", {
68 ensure => ensure_directory_state($ensure), 72 ensure => ensure_directory_state($ensure),
69 owner => www-data, 73 owner => 'www-data',
mathias 2018/04/05 01:12:29 Please quote non-keyword strings, always.
f.lopez 2018/04/10 02:45:38 Acknowledged.
70 group => www-data, 74 group => 'www-data',
71 }) 75 })
72 76
73 ensure_resource('nginx::hostconfig', $title, { 77 ensure_resource('nginx::hostconfig', $title, {
74 content => template('adblockplus/web/static.conf.erb'), 78 content => template('adblockplus/web/static.conf.erb'),
75 certificate => $ssl_certificate, 79 certificate => $ssl_certificate,
76 domain => $domain, 80 domain => $domain,
77 is_default => 'true', 81 is_default => true,
mathias 2018/04/05 01:12:29 This keywords should not need quotes.
f.lopez 2018/04/10 02:45:38 Acknowledged.
78 private_key => $ssl_private_key, 82 private_key => $ssl_private_key,
79 log => "web.access.log", 83 log => 'web.access.log',
mathias 2018/04/05 01:12:28 This should be single quotes. (I would prefer stic
f.lopez 2018/04/10 02:45:39 Acknowledged.
80 }) 84 })
81 85
82 $content = [ 86 $content = [
83 "Match User ${deploy_user}", 87 "Match User ${deploy_user}",
84 'AllowTcpForwarding no', 88 'AllowTcpForwarding no',
85 'X11Forwarding no', 89 'X11Forwarding no',
86 'AllowAgentForwarding no', 90 'AllowAgentForwarding no',
87 'GatewayPorts no', 91 'GatewayPorts no',
88 'ForceCommand /usr/local/bin/hooks_wrapper', 92 'ForceCommand /usr/local/bin/hooks_wrapper $SSH_ORIGINAL_COMMAND',
89 ] 93 ]
90 94
91 create_resources('concat::fragment', { 95 ensure_resource('concat::fragment', 'helpcenter', {
mathias 2018/04/05 01:12:28 There's no need to use the create_resources() func
f.lopez 2018/04/10 02:45:38 Acknowledged.
92 helpcenter => { 96 content => join($content, "\n\t"),
93 content => join($content, "\n"),
mathias 2018/04/05 01:12:28 If you'd use "\n\t" or similar it would create a m
f.lopez 2018/04/10 02:45:38 Acknowledged.
94 ensure => 'present', 97 ensure => 'present',
95 target => 'sshd_config', 98 target => 'sshd_config',
96 order => '20', 99 order => '20',
97 }}) 100 })
98 101
99 ensure_resource('adblockplus::user', $deploy_user, { 102 ensure_resource('adblockplus::user', $deploy_user, {
100 authorized_keys => $deploy_user_authorized_keys, 103 authorized_keys => $deploy_user_authorized_keys,
101 ensure => $ensure, 104 ensure => $ensure,
102 password_hash => '*',
mathias 2018/04/05 01:12:28 Is this parameter necessary? The underlying named
f.lopez 2018/04/10 02:45:39 Acknowledged.
103 shell => '/bin/bash', 105 shell => '/bin/bash',
104 groups => ['www-data'], 106 groups => ['www-data'],
105 }) 107 })
106 108
107 ensure_resource('file', "/usr/local/bin/hooks_wrapper", { 109 $wrapper_path = "/home/${deploy_user}/bin"
mathias 2018/04/05 01:12:28 Double quotes again :)
f.lopez 2018/04/10 02:45:38 Acknowledged.
110 ensure_resource('file', 'commands_dir', {
111 path => $wrapper_path,
112 ensure => ensure_directory_state($ensure),
113 })
114
115 ensure_resource('file', '/usr/local/bin/hooks_wrapper', {
108 ensure => ensure_file_state($ensure), 116 ensure => ensure_file_state($ensure),
109 content => template('adblockplus/web/hooks_wrapper.sh.erb'), 117 content => template('adblockplus/web/hooks_wrapper.sh.erb'),
110 })
111
112 ensure_resource('file', "/home/$deploy_user/bin", {
mathias 2018/04/05 01:12:30 And again :)
f.lopez 2018/04/10 02:45:38 this one has $deploy_user parameter in the middle,
113 ensure => ensure_directory_state($ensure),
114 }) 118 })
115 119
116 # https://docs.puppet.com/puppet/latest/function.html#createresources 120 # https://docs.puppet.com/puppet/latest/function.html#createresources
117 create_resources('adblockplus::web::static::hook', $hooks) 121 create_resources('adblockplus::web::static::hook', $hooks)
118 } 122 }
119 123
LEFTRIGHT

Powered by Google App Engine
This is Rietveld