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