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

Side by Side Diff: modules/adblockplus/manifests/web/static.pp

Issue 29733731: #7320 - Introduce helpcenter role (Closed)
Patch Set: For comments 8 and 9 Created April 17, 2018, 6:02 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(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, e.g. "asbsent" or "present".
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 ssh
58
59 File {
60 mode => '0755',
61 owner => $deploy_user,
62 group => $deploy_user,
63 }
64
65 ensure_resource('file', "/var/www/$domain", {
66 ensure => ensure_directory_state($ensure),
67 owner => 'www-data',
68 group => 'www-data',
69 })
70
71 ensure_resource('nginx::hostconfig', $title, {
72 content => template('adblockplus/web/static.conf.erb'),
73 certificate => $ssl_certificate,
74 domain => $domain,
75 is_default => true,
76 private_key => $ssl_private_key,
77 log => 'web.access.log',
78 })
79
80 $content = [
81 "Match User ${deploy_user}",
82 'AllowTcpForwarding no',
83 'X11Forwarding no',
84 'AllowAgentForwarding no',
85 'GatewayPorts no',
86 'ForceCommand /usr/local/bin/hooks_wrapper $SSH_ORIGINAL_COMMAND',
87 ]
88
89 ensure_resource('concat::fragment', 'helpcenter', {
90 content => join($content, "\n\t"),
91 ensure => 'present',
92 target => 'sshd_config',
93 order => '20',
94 })
95
96 ensure_resource('adblockplus::user', $deploy_user, {
97 authorized_keys => $deploy_user_authorized_keys,
98 ensure => $ensure,
99 shell => '/bin/bash',
100 groups => ['www-data'],
101 })
102
103 $wrapper_path = "/home/${deploy_user}/bin"
104 ensure_resource('file', 'commands_dir', {
105 path => $wrapper_path,
106 ensure => ensure_directory_state($ensure),
107 })
108
109 ensure_resource('file', '/usr/local/bin/hooks_wrapper', {
110 ensure => ensure_file_state($ensure),
111 content => template('adblockplus/web/hooks_wrapper.sh.erb'),
112 })
113
114 # https://docs.puppet.com/puppet/latest/function.html#createresources
115 create_resources('adblockplus::web::static::hook', $hooks)
116 }
117
OLDNEW

Powered by Google App Engine
This is Rietveld