port 6081 should be allowed via snapshot
[mirror/dsa-puppet.git] / modules / roles / manifests / snapshot_web.pp
1 class roles::snapshot_web {
2         include apache2
3         include apache2::rewrite
4
5         ensure_packages ( [
6                 "libapache2-mod-wsgi",
7                 ], {
8                 ensure => 'installed',
9         })
10
11         apache2::site { '020-snapshot.debian.org':
12                 site   => 'snapshot.debian.org',
13                 content => template('roles/snapshot/snapshot.debian.org.conf.erb')
14         }
15
16         case $::hostname {
17                 'lw07': {
18                         $ipv4addr        = '185.17.185.185'
19                         $ipv6addr        = '2001:1af8:4020:b030:deb::185'
20                         $ipv6addr_apache = '2001:1af8:4020:b030:deb::187'
21                 }
22                 'sallinen': {
23                         $ipv4addr        = '193.62.202.27'
24                         $ipv6addr        = '2001:630:206:4000:1a1a:0:c13e:ca1b'
25                         $ipv6addr_apache = '2001:630:206:4000:1a1a:0:c13e:ca1a'
26                 }
27                 default: {
28                         fail ( "unknown host $::hostname for snapshot_web." )
29                 }
30         }
31
32         # varnish cache
33         ###############
34         @ferm::rule { 'dsa-nat-snapshot-varnish-v4':
35                 table => 'nat',
36                 chain => 'PREROUTING',
37                 rule  => "proto tcp daddr ${ipv4addr} dport 80 REDIRECT to-ports 6081",
38         }
39
40         varnish::config { 'default':
41                 listen  => [
42                         ':6081',
43                         "[$ipv6addr]:80"
44                         ],
45                 backend => 'file,/var/lib/varnish/varnish_storage.bin,8G',
46                 content => template('roles/snapshot/snapshot.debian.org.vcl.erb'),
47         }
48
49         # the ipv6 port 80 is owned by varnish
50         file { '/etc/apache2/ports.conf':
51                 content  => @("EOF"),
52                         Listen 0.0.0.0:80
53                         Listen [$ipv6addr_apache]:80
54                         | EOF
55                 require => Package['apache2'],
56                 notify  => Service['apache2'],
57         }
58
59         # haproxy ssl termination
60         #########################
61         include haproxy
62         file { '/etc/haproxy/haproxy.cfg':
63                 content => template('roles/snapshot/haproxy.cfg.erb'),
64                 require => Package['haproxy'],
65                 notify  => Service['haproxy'],
66         }
67         ssl::service { 'snapshot.debian.org':
68                 notify  => Service['haproxy'],
69                 key => true,
70         }
71 }