]> WPIA git - infra.git/blob - environments/production/manifests/nginx.pp
373e2a84c2c84b6bbc2176f701ba254ddb952c5c
[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   package{ 'nginx-light':
34     ensure => 'installed'
35   }
36   $gigi_ip = $ips[gigi];
37   front_vhost{'gigi':
38     source => 'gigi/nginx',
39     crt => 'gigi/gigi',
40     notify => Service['nginx']
41   }
42   front_vhost{'crl':
43     source => 'crl/nginx',
44     notify => Service['nginx']
45   }
46   if($protected != 'no') {
47     file{'/etc/nginx/access.txt':
48       content => $protected,
49       require => Package['nginx-light'],
50       before => Service['nginx']
51     }
52   }
53   file{'/etc/ssl/root.crt':
54     ensure => 'file',
55     source => ['puppet:///modules/nre/config/ca/root.crt'],
56     show_diff => 'no',
57     notify => Service['nginx'],
58     before => Front_vhost['quiz']
59   }
60   front_vhost{'quiz':
61     source => 'quiz/nginx',
62     crt => 'quiz/web',
63     notify => Service['nginx']
64   }
65   service {'nginx':
66     ensure => 'running'
67   }
68   #for gitweb hosting
69   package{'git':
70     ensure=>'installed'
71   }
72   front_vhost{'gitweb':
73     source => 'gitweb/nginx.epp',
74     notify => Service['nginx'],
75     crt => 'gitweb/web'
76   }
77 }