]> WPIA git - infra.git/blob - environments/production/manifests/root.pp
add: gitweb service
[infra.git] / environments / production / manifests / root.pp
1 class my_fw::post {
2   package { 'iptables-persistent':
3     ensure => 'installed'
4   }
5   resources { 'firewall':
6       purge => true,
7   }
8   Package['iptables-persistent'] ->
9   firewall { '80 dnat':
10     proto  => 'tcp',
11     dport  => '80',
12     jump => 'DNAT',
13     todest => "${$ips[front-nginx]}:80",
14     iniface => $internet_iface,
15     table    => 'nat',
16     chain    => 'PREROUTING',
17   } ->
18   firewall { '80 dnat-https':
19     proto  => 'tcp',
20     dport  => '443',
21     jump => 'DNAT',
22     todest => "${$ips[front-nginx]}:443",
23     iniface => $internet_iface,
24     table    => 'nat',
25     chain    => 'PREROUTING',
26   } ->
27   firewall { '80 dnat-git':
28     proto  => 'tcp',
29     dport  => '9418',
30     jump => 'DNAT',
31     todest => "${$ips[gitweb]}:9418",
32     iniface => $internet_iface,
33     table    => 'nat',
34     chain    => 'PREROUTING',
35   } ->
36   firewall { '80 dnat-htop-ssh':
37     proto  => 'tcp',
38     dport  => '2222',
39     jump => 'DNAT',
40     todest => "${$ips[hop]}:22",
41     iniface => $internet_iface,
42     table    => 'nat',
43     chain    => 'PREROUTING',
44   } ->
45   firewall { '80 MASQ':
46     chain => 'POSTROUTING',
47     table => 'nat',
48     jump => 'MASQUERADE',
49     proto => 'all',
50     outiface => $internet_iface,
51     source => '10.0.3.0/24',
52   }
53 }
54
55
56 node host01 {
57     include my_fw::post
58     include lxc
59     package {'bridge-utils':
60         ensure => 'installed'
61     } -> file {'/etc/network/interfaces.d/lxcbr0':
62         source => 'puppet:///modules/lxc/lxcbr0'
63     } -> exec {'ifup lxcbr0':
64       command => '/sbin/ifdown lxcbr0; /sbin/ifup lxcbr0',
65       refreshonly => true,
66       subscribe => File['/etc/network/interfaces.d/lxcbr0']
67     } -> exec { "enable forwarding on $hostname":
68       user    => "root",
69       command => "/bin/echo 1 > /proc/sys/net/ipv4/ip_forward",
70       unless  => "/bin/grep -q 1 /proc/sys/net/ipv4/ip_forward";
71     }->
72       file_line {"root-resolv1":
73       path   => "/etc/resolv.conf",
74       ensure => 'absent',
75       match_for_absence => "true",
76       match  => '^domain ',
77       line   => ''
78     }->
79       file_line {"root-resolv2":
80       path   => "/etc/resolv.conf",
81       ensure => 'absent',
82       match_for_absence => "true",
83       match  => '^search ',
84       line   => ''
85     }
86 if $signerLocation == 'self' {
87     exec {"create cassiopeia-comm-keys":
88       command => '/etc/puppet/code/modules/cassiopeia/mkcassiopeia',
89       creates => '/etc/puppet/code/modules/cassiopeia/files/signer_client.crt'
90     }
91 } else {
92     exec {"create cassiopeia-comm-keys":
93       command => '/bin/false',
94       creates => '/etc/puppet/code/modules/cassiopeia/files/signer_client.crt'
95     }
96 }
97     exec {"gigi keystore.pkcs12":
98       command => '/bin/bash -c \'keystorepw=$(/usr/bin/head -c 15 /dev/urandom | base64); /usr/bin/openssl pkcs12 -export -name "mail" -in /etc/puppet/code/modules/gigi/files/client.crt -inkey /etc/puppet/code/modules/gigi/client.key -CAfile /etc/puppet/codemodules/nre/files/config/ca/root.crt -password file:<(echo $keystorepw) > /etc/puppet/code/modules/gigi/files/keystore.pkcs12; /usr/bin/printf "%s" "$keystorepw" > /etc/puppet/code/modules/gigi/files/keystorepw\'',
99       unless => '/usr/bin/[  /etc/puppet/code/modules/gigi/files/keystore.pkcs12 -nt /etc/puppet/code/modules/gigi/files/client.crt ] || ! /usr/bin/[ -f /etc/puppet/code/modules/gigi/files/client.crt ]'
100     }
101     lxc::container { 'front-nginx':
102         contname => 'front-nginx',
103         ip => $ips[front-nginx],
104         dir => ["/data", "/data-crl", '/data-crl-gigi', '/gitweb-socket', '/srv/git'],
105         bind => {
106           "/data/nginx" => {target => "data", option => ",ro"},
107           "/data/crl" => {target => "data-crl", option => ",ro"},
108           "/data/gigi-crl" => {target => "data-crl-gigi", option => ",ro"},
109           "/run/gitweb-socket" => {target => 'gitweb-socket'},
110           "/data/git" => { 'target' => "srv/git", option => ",ro"}
111         },
112         require => File['/data/nginx', '/data/crl/htdocs', '/data/gigi-crl']
113     }
114     file { '/data':
115        ensure => 'directory',
116     }
117     file { '/data/nginx':
118       ensure => 'directory',
119     }
120     file { '/data/crl':
121       ensure => 'directory',
122       owner => $administrativeUser
123     }
124     file { '/data/git':
125       ensure => 'directory',
126       owner => $administrativeUser,
127     }
128     file { '/data/gigi-crl':
129       ensure => 'directory',
130       owner => $administrativeUser
131     }
132     file { '/data/crl/htdocs':
133       ensure => 'directory',
134       owner => $administrativeUser
135     }
136     file { '/data/postgres/conf':
137       ensure => 'directory',
138     }
139     file { '/data/postgres/data':
140       ensure => 'directory',
141     }
142     file { '/data/postgres':
143       ensure => 'directory',
144     }
145     file { '/data/gigi':
146       ensure => 'directory',
147     }
148     lxc::container { 'postgres-primary':
149         contname => 'postgres-primary',
150         ip => $ips[postgres],
151         dir => ["/var/lib/postgresql", "/etc/postgresql"],
152         bind => {
153           "/data/postgres/data" => { target => "var/lib/postgresql"},
154           "/data/postgres/conf" => { target => "etc/postgresql"}
155         },
156         require => File['/data/postgres']
157     }
158     $gigi_serial_conf= $signerLocation ? {
159       'self'          => [],
160       '/dev/ttyS0'    => ["lxc.cgroup.devices.allow = c 4:64 rwm"]
161     }
162
163     lxc::container { 'gigi':
164         contname => 'gigi',
165         ip => $ips[gigi],
166         dir => ["/var/lib/wpia-gigi", "/var/lib/wpia-gigi/keys", '/var/lib/cassiopeia', '/var/lib/cassiopeia/ca'],
167         bind => {
168           "/data/gigi" => { target => "var/lib/wpia-gigi/keys"},
169           "/data/gigi-crl" => { target => "var/lib/cassiopeia/ca"}
170         },
171         confline => $gigi_serial_conf,
172         require => File['/data/gigi', '/data/gigi-crl']
173     }
174     if $signerLocation == 'self' {
175       lxc::container { 'cassiopeia':
176         contname => 'cassiopeia',
177         ip => $ips[cassiopeia]
178       }
179     }
180     lxc::container { 'exim':
181         contname => 'exim',
182         ip => $ips[exim]
183     }
184     lxc::container { 'hop':
185         contname => 'hop',
186         ip => $ips[hop]
187     }
188     lxc::container { 'quiz':
189         contname => 'quiz',
190         ip => $ips[quiz]
191     }
192     file{'/run/gitweb-socket':
193         ensure => 'directory'
194     }
195     lxc::container { 'gitweb':
196         require => File['/data/git', '/run/gitweb-socket'],
197         contname => 'gitweb',
198         dir => ['/gitweb-socket', '/srv/git'],
199         bind => {
200           "/run/gitweb-socket" => { 'target' => "gitweb-socket"},
201           "/data/git" => { 'target' => "srv/git", option => ",ro"}
202         },
203         ip => $ips[gitweb]
204     }
205     # Required for bootstrap-user
206     package {'acl':
207         ensure => 'installed'
208     }
209 }
210