1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
class site_webapp {
tag 'leap_service'
$definition_files = hiera('definition_files')
$provider = $definition_files['provider']
$eip_service = $definition_files['eip_service']
$soledad_service = $definition_files['soledad_service']
$smtp_service = $definition_files['smtp_service']
$node_domain = hiera('domain')
$provider_domain = $node_domain['full_suffix']
$webapp = hiera('webapp')
$api_version = $webapp['api_version']
$secret_token = $webapp['secret_token']
include site_config::ruby
include site_webapp::apache
include site_webapp::couchdb
include site_webapp::client_ca
include site_webapp::haproxy
group { 'leap-webapp':
ensure => present,
allowdupe => false;
}
user { 'leap-webapp':
ensure => present,
allowdupe => false,
gid => 'leap-webapp',
groups => 'ssl-cert',
home => '/srv/leap/webapp',
require => [ Group['leap-webapp'] ];
}
vcsrepo { '/srv/leap/webapp':
ensure => present,
force => true,
revision => 'origin/master',
provider => git,
source => 'git://code.leap.se/leap_web',
owner => 'leap-webapp',
group => 'leap-webapp',
require => [ User['leap-webapp'], Group['leap-webapp'] ],
notify => Exec['bundler_update']
}
exec { 'bundler_update':
cwd => '/srv/leap/webapp',
command => '/bin/bash -c "/usr/bin/bundle check || /usr/bin/bundle install --path vendor/bundle --without test development"',
unless => '/usr/bin/bundle check',
user => 'leap-webapp',
timeout => 600,
require => [ Class['bundler::install'], Vcsrepo['/srv/leap/webapp'] ],
notify => Service['apache'];
}
exec { 'compile_assets':
cwd => '/srv/leap/webapp',
command => '/usr/bin/bundle exec rake assets:precompile',
user => 'leap-webapp',
logoutput => on_failure,
require => Exec['bundler_update'],
notify => Service['apache'];
}
file {
'/srv/leap/webapp/public/provider.json':
content => $provider,
require => Vcsrepo['/srv/leap/webapp'],
owner => leap-webapp, group => leap-webapp, mode => '0644';
'/srv/leap/webapp/public/ca.crt':
ensure => link,
require => Vcsrepo['/srv/leap/webapp'],
target => '/usr/local/share/ca-certificates/leap_api.crt';
"/srv/leap/webapp/public/${api_version}":
ensure => directory,
require => Vcsrepo['/srv/leap/webapp'],
owner => leap-webapp, group => leap-webapp, mode => '0755';
"/srv/leap/webapp/public/${api_version}/config/":
ensure => directory,
require => Vcsrepo['/srv/leap/webapp'],
owner => leap-webapp, group => leap-webapp, mode => '0755';
"/srv/leap/webapp/public/${api_version}/config/eip-service.json":
content => $eip_service,
require => Vcsrepo['/srv/leap/webapp'],
owner => leap-webapp, group => leap-webapp, mode => '0644';
"/srv/leap/webapp/public/${api_version}/config/soledad-service.json":
content => $soledad_service,
require => Vcsrepo['/srv/leap/webapp'],
owner => leap-webapp, group => leap-webapp, mode => '0644';
"/srv/leap/webapp/public/${api_version}/config/smtp-service.json":
content => $smtp_service,
require => Vcsrepo['/srv/leap/webapp'],
owner => leap-webapp, group => leap-webapp, mode => '0644';
}
try::file {
'/srv/leap/webapp/public/favicon.ico':
ensure => present,
owner => leap-webapp,
group => leap-webapp,
mode => '0644',
require => Vcsrepo['/srv/leap/webapp'],
source => $webapp['favicon'];
'/srv/leap/webapp/app/assets/stylesheets/tail.scss':
ensure => present,
owner => leap-webapp,
group => leap-webapp,
mode => '0644',
require => Vcsrepo['/srv/leap/webapp'],
source => $webapp['tail_scss'],
before => Exec['bundler_update'];
'/srv/leap/webapp/app/assets/stylesheets/head.scss':
ensure => present,
owner => leap-webapp,
group => leap-webapp,
mode => '0644',
require => Vcsrepo['/srv/leap/webapp'],
source => $webapp['head_scss'],
before => Exec['bundler_update'];
'/srv/leap/webapp/public/img':
ensure => directory,
recurse => true,
purge => true,
force => true,
owner => leap-webapp,
group => leap-webapp,
mode => '0644',
require => Vcsrepo['/srv/leap/webapp'],
source => $webapp['img_dir'];
}
file {
'/srv/leap/webapp/config/config.yml':
content => template('site_webapp/config.yml.erb'),
owner => leap-webapp,
group => leap-webapp,
mode => '0600',
require => Vcsrepo['/srv/leap/webapp'],
notify => Service['apache'];
}
include site_shorewall::webapp
}
|