Skip to content
This repository was archived by the owner on Feb 25, 2020. It is now read-only.

Commit 6255e58

Browse files
author
varac
committed
move leap_webapp.conf template to common.conf which is included by the nagios and webapp node (#5096)
1 parent d8112f6 commit 6255e58

File tree

5 files changed

+56
-24
lines changed

5 files changed

+56
-24
lines changed

provider_base/services/monitor.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,14 @@
22
"nagios": {
33
"nagiosadmin_pw": "= secret :nagios_admin_password",
44
"hosts": "= nodes_like_me.pick_fields('domain.internal', 'ip_address', 'services', 'openvpn.gateway_address')"
5+
},
6+
"x509": {
7+
"use": true,
8+
"ca_cert": "= file :ca_cert, :missing => 'provider CA. Run `leap cert ca`'",
9+
"client_ca_cert": "= file :client_ca_cert, :missing => 'Certificate Authority. Run `leap cert ca`'",
10+
"client_ca_key": "= file :client_ca_key, :missing => 'Certificate Authority. Run `leap cert ca`'",
11+
"commercial_cert": "= file [:commercial_cert, domain.full_suffix]",
12+
"commercial_key": "= file [:commercial_key, domain.full_suffix]",
13+
"commercial_ca_cert": "= try_file :commercial_ca_cert"
514
}
615
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class site_apache::common {
2+
# installs x509 cert + key and common config
3+
# that both nagios + leap webapp use
4+
5+
$web_domain = hiera('domain')
6+
$domain_name = $web_domain['name']
7+
8+
include x509::variables
9+
include site_config::x509::commercial::cert
10+
include site_config::x509::commercial::key
11+
include site_config::x509::commercial::ca
12+
13+
Class['Site_config::X509::Commercial::Key'] ~> Service[apache]
14+
Class['Site_config::X509::Commercial::Cert'] ~> Service[apache]
15+
Class['Site_config::X509::Commercial::Ca'] ~> Service[apache]
16+
17+
include site_apache::module::rewrite
18+
19+
class { '::apache': no_default_site => true, ssl => true }
20+
21+
apache::vhost::file {
22+
'common':
23+
content => template('site_apache/vhosts.d/common.conf.erb')
24+
}
25+
26+
}

puppet/modules/site_apache/templates/vhosts.d/leap_webapp.conf.erb renamed to puppet/modules/site_apache/templates/vhosts.d/common.conf.erb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@
2323
RequestHeader set X_FORWARDED_PROTO 'https'
2424

2525
<IfModule mod_headers.c>
26-
<% if @webapp['secure'] -%>
26+
<% if (defined? @services) and (@services.include? 'webapp') and (@webapp['secure']) -%>
2727
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
2828
<% end -%>
2929
Header always unset X-Powered-By
3030
Header always unset X-Runtime
3131
</IfModule>
3232

33+
<% if (defined? @services) and (@services.include? 'webapp') -%>
3334
DocumentRoot /srv/leap/webapp/public
3435

3536
RewriteEngine On
@@ -52,16 +53,20 @@
5253
ExpiresActive On
5354
ExpiresDefault "access plus 1 year"
5455
</Location>
56+
<% end -%>
57+
5558

56-
<% if (defined? @services) and (@services.include? 'monitor') -%>
59+
<% if (defined? @services) and (@services.include? 'monitor') -%>
5760
<DirectoryMatch (/usr/share/nagios3/htdocs|/usr/lib/cgi-bin/nagios3|/etc/nagios3/stylesheets)>
61+
<% if (defined? @services) and (@services.include? 'webapp') -%>
5862
PassengerEnabled off
63+
<% end -%>
5964
AllowOverride all
6065
# Nagios won't work with setting this option to "DENY",
6166
# as set in conf.d/security (#4169). Therefor we allow
6267
# it here, only for nagios.
6368
Header set X-Frame-Options: "ALLOW"
6469
</DirectoryMatch>
65-
<% end -%>
70+
<% end -%>
6671
</VirtualHost>
6772

puppet/modules/site_nagios/manifests/server.pp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,26 @@
1111

1212
include nagios::defaults
1313
include nagios::base
14-
#Class ['nagios'] -> Class ['nagios::defaults']
15-
class {'nagios::apache':
14+
class {'nagios':
15+
# don't manage apache class from nagios, cause we already include
16+
# it in site_apache::common
17+
httpd => 'absent',
1618
allow_external_cmd => true,
1719
stored_config => false,
18-
#before => Class ['nagios::defaults']
1920
}
2021

22+
file { '/etc/apache2/conf.d/nagios3.conf':
23+
ensure => link,
24+
target => '/usr/share/doc/nagios3-common/examples/apache2.conf',
25+
notify => Service['apache']
26+
}
27+
28+
include site_apache::common
2129
include site_apache::module::headers
2230

2331
File ['nagios_htpasswd'] {
2432
source => undef,
25-
content => "nagiosadmin:$nagiosadmin_pw",
33+
content => "nagiosadmin:${nagiosadmin_pw}",
2634
mode => '0640',
2735
}
2836

puppet/modules/site_webapp/manifests/apache.pp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,14 @@
77
$web_domain = hiera('domain')
88
$domain_name = $web_domain['name']
99

10-
include x509::variables
11-
include site_config::x509::commercial::cert
12-
include site_config::x509::commercial::key
13-
include site_config::x509::commercial::ca
14-
15-
Class['Site_config::X509::Commercial::Key'] ~> Service[apache]
16-
Class['Site_config::X509::Commercial::Cert'] ~> Service[apache]
17-
Class['Site_config::X509::Commercial::Ca'] ~> Service[apache]
18-
19-
class { '::apache': no_default_site => true, ssl => true }
20-
10+
include site_apache::common
2111
include site_apache::module::headers
22-
include site_apache::module::rewrite
2312
include site_apache::module::alias
2413
include site_apache::module::expires
2514
include site_apache::module::removeip
2615

2716
class { 'passenger': use_munin => false }
2817

29-
apache::vhost::file {
30-
'leap_webapp':
31-
content => template('site_apache/vhosts.d/leap_webapp.conf.erb')
32-
}
33-
3418
apache::vhost::file {
3519
'api':
3620
content => template('site_apache/vhosts.d/api.conf.erb')

0 commit comments

Comments
 (0)