]> WPIA git - infra.git/blob - environments/production/manifests/nginx.pp
add: virtual resource collectors for nginx+pg
[infra.git] / environments / production / manifests / nginx.pp
1 define front_vhost($source, $crt = undefined){
2   if $crt {
3     file{"/etc/ssl/private/$name.crt":
4       ensure => 'file',
5       source => ["puppet:///modules/$crt.crt", 'puppet:///modules/gigi/gigi.crt'],
6       show_diff => 'no',
7       notify => Service['nginx'],
8       before => File["/etc/nginx/sites-available/$name.conf"]
9     }
10     file{"/etc/ssl/private/$name.key":
11       ensure => 'file',
12       source => ["puppet:///modules/$crt.key", 'puppet:///modules/gigi/gigi.key'],
13       show_diff => 'no',
14       before => File["/etc/nginx/sites-available/$name.conf"]
15     }
16   }
17   file {"/etc/nginx/sites-available/$name.conf":
18     ensure => 'file',
19     content => epp($source),
20     require => Package['nginx-light'],
21   }->
22   file {"/etc/nginx/sites-enabled/$name.conf":
23     ensure => 'link',
24     target => "/etc/nginx/sites-available/$name.conf",
25     require => Package['nginx-light'],
26     notify => Service['nginx']
27   }
28 }
29
30 node front-nginx {
31   include container::contained;
32   include container::no_ssh;
33   apt_key{ 'E643C483A426BB5311D26520A631B6AF9FD3DF94':
34     source => 'http://deb2.dogcraft.de/signer.gpg',
35     ensure => 'present'
36   } ->
37     file { '/etc/apt/sources.list.d/dogcraft.list':
38       source => 'puppet:///modules/lxc/dogcraft.list',
39       ensure => 'present',
40       notify => Exec['apt_update']
41   }
42   package{ 'nginx-light':
43     ensure => 'installed'
44   }
45   $gigi_ip = $ips[gigi];
46   front_vhost{'gigi':
47     source => 'gigi/nginx',
48     crt => 'gigi/gigi',
49     notify => Service['nginx']
50   }
51   front_vhost{'crl':
52     source => 'crl/nginx',
53     notify => Service['nginx']
54   }
55   package{'wpia-infradocs':
56     ensure => 'installed'
57   } ->
58   front_vhost{'infradocs':
59     source => 'infradocs/nginx',
60     notify => Service['nginx']
61   }
62   if($protected != 'no') {
63     file{'/etc/nginx/access.txt':
64       content => $protected,
65       require => Package['nginx-light'],
66       before => Service['nginx']
67     }
68   }
69   file{'/etc/ssl/root.crt':
70     ensure => 'file',
71     source => ['puppet:///modules/nre/config/ca/root.crt'],
72     show_diff => 'no',
73     notify => Service['nginx'],
74     before => Front_vhost['quiz']
75   }
76   front_vhost{'quiz':
77     source => 'quiz/nginx',
78     crt => 'quiz/web',
79     notify => Service['nginx']
80   }
81   service {'nginx':
82     ensure => 'running',
83     enable => true,
84   }
85   #for gitweb hosting
86   package{'git':
87     ensure=>'installed'
88   }
89   front_vhost{'gitweb':
90     source => 'gitweb/nginx.epp',
91     notify => Service['nginx'],
92     crt => 'gitweb/web'
93   }
94
95   Front_vhost <| tag == nginx |> ~> Service['nginx']
96   File <| tag == nginx |> ~> Service['nginx']
97 }