]> WPIA git - infra.git/blob - modules/motion/manifests/virtual.pp
fix: correctly auto-start cassiopeia services
[infra.git] / modules / motion / manifests / virtual.pp
1 define motion::virtual ($domain = "motion.${systemDomain}", $container = $name) {
2   @file{"/run/${container}-socket":
3     ensure => 'directory',
4     tag => [root]
5   } ->
6   @lxc::container { $container:
7     contname => $container,
8     ip => $ips[$container],
9     dir => ['/motion-socket'],
10     bind => {
11       "/run/${container}-socket" => { 'target' => "motion-socket"},
12     },
13     tag => [root]
14   }
15   @lxc::container_bind{ "/run/${container}-socket":
16     container => 'front-nginx',
17     target => "${container}-socket",
18     tag => [root]
19   }
20
21   @file{"/etc/ssl/${container}-roots.pem":
22     ensure => 'file',
23     source => ['puppet:///modules/motion/motion-roots.pem', 'puppet:///modules/nre/config/ca/root.crt'],
24     tag => [nginx]
25   }
26   @front_vhost{$container:
27     source => 'motion/nginx.epp',
28     args => {container => $container, name => $container, cert_stem => "/etc/ssl/private/${container}", domain => $domain, socket => "unix:/${container}-socket/motion.fcgi"},
29     crt => "motion/${container}",
30     tag => [nginx]
31   }
32
33   @file{'/etc/nginx/conf.d/bucket_size.conf':
34     content => "map_hash_bucket_size 256;log_format motion-cert '\$date_gmt \$host:\$ssl_client_serial:\$ssl_client_i_dn;\$motion_user_role';\n",
35     ensure => 'file',
36     before => Service['nginx'],
37     tag => [nginx]
38   }
39   @file{'/etc/nginx/conf.d/motion_map.conf':
40     content => inline_epp(file('motion/user_map.epp', 'motion/user_map.template.epp'), {name => $name}),
41     ensure => 'file',
42     before => Service['nginx'],
43     tag => [nginx]
44   }
45
46
47   @postgresql::server::db { $container:
48     user     => $container,
49     password => postgresql_password($container, 'motion'),
50     tag => [primary]
51   }
52   @postgresql::server::pg_hba_rule { "allow ${container} to access its database":
53     description => "Open up PostgreSQL for access from motion-user to its database",
54     type        => 'host',
55     database    => $container,
56     user        => $container,
57     address     => "${ips[$container]}/32",
58     auth_method => 'md5',
59     tag => [primary]
60   }
61 }
62
63 define motion::frontend($domain, $container, $roots = 'puppet:///modules/motion/motion-roots.pem'){
64   @file{"/etc/ssl/${name}-roots.pem":
65     ensure => 'file',
66     source => [$roots, 'puppet:///modules/nre/config/ca/root.crt'],
67     tag => [nginx]
68   }
69   @front_vhost{"${container}-${domain}":
70     source => 'motion/nginx.epp',
71     args => {container => $container, name => $name, cert_stem => "/etc/ssl/private/${container}", domain => $domain, socket => "unix:/${container}-socket/motion.fcgi"},
72     crt => "motion/${container}",
73     tag => [nginx]
74   }
75 }