aboutsummaryrefslogtreecommitdiff
path: root/modules/role/manifests/cryptoportfolio.pp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/role/manifests/cryptoportfolio.pp')
-rw-r--r--modules/role/manifests/cryptoportfolio.pp123
1 files changed, 56 insertions, 67 deletions
diff --git a/modules/role/manifests/cryptoportfolio.pp b/modules/role/manifests/cryptoportfolio.pp
index 32b6ac7..6c760b5 100644
--- a/modules/role/manifests/cryptoportfolio.pp
+++ b/modules/role/manifests/cryptoportfolio.pp
@@ -26,7 +26,7 @@ class role::cryptoportfolio {
26 $cf_group = "cryptoportfolio" 26 $cf_group = "cryptoportfolio"
27 $cf_home = "/opt/cryptoportfolio" 27 $cf_home = "/opt/cryptoportfolio"
28 $cf_env = "prod" 28 $cf_env = "prod"
29 $cf_front_app_host = "cryptoportfolio.immae.eu" 29 $cf_front_app_host = lookup("base_installation::system_hostname") |$key| { "example.com" }
30 $cf_front_app_port = "" 30 $cf_front_app_port = ""
31 $cf_front_app_ssl = "true" 31 $cf_front_app_ssl = "true"
32 $cf_front_app = "${cf_home}/go/src/immae.eu/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front" 32 $cf_front_app = "${cf_home}/go/src/immae.eu/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front"
@@ -196,14 +196,14 @@ class role::cryptoportfolio {
196 require => User[$cf_user], 196 require => User[$cf_user],
197 } 197 }
198 198
199 archive { "${cf_home}/${bot_version}.tar.gz": 199 archive { "${cf_home}/trader_${bot_version}.tar.gz":
200 path => "${cf_home}/${bot_version}.tar.gz", 200 path => "${cf_home}/trader_${bot_version}.tar.gz",
201 source => "https://git.immae.eu/releases/cryptoportfolio/trader/trader_${bot_version}.tar.gz", 201 source => "https://git.immae.eu/releases/cryptoportfolio/trader/trader_${bot_version}.tar.gz",
202 checksum_type => "sha256", 202 checksum_type => "sha256",
203 checksum => $bot_sha256, 203 checksum => $bot_sha256,
204 cleanup => false, 204 cleanup => false,
205 extract => true, 205 extract => true,
206 user => "cryptoportfolio", 206 user => $cf_user,
207 username => $facts["ec2_metadata"]["hostname"], 207 username => $facts["ec2_metadata"]["hostname"],
208 password => generate_password(24, $password_seed, "ldap"), 208 password => generate_password(24, $password_seed, "ldap"),
209 extract_path => $cf_bot_app, 209 extract_path => $cf_bot_app,
@@ -230,7 +230,7 @@ class role::cryptoportfolio {
230 content => template("role/cryptoportfolio/bot_config.ini.erb"), 230 content => template("role/cryptoportfolio/bot_config.ini.erb"),
231 require => [ 231 require => [
232 User[$cf_user], 232 User[$cf_user],
233 Archive["${cf_home}/${bot_version}.tar.gz"], 233 Archive["${cf_home}/trader_${bot_version}.tar.gz"],
234 ], 234 ],
235 } 235 }
236 236
@@ -244,7 +244,7 @@ class role::cryptoportfolio {
244 environment => ["HOME=${cf_home}","PATH=/usr/bin/"], 244 environment => ["HOME=${cf_home}","PATH=/usr/bin/"],
245 require => [ 245 require => [
246 File[$cf_bot_app_conf], 246 File[$cf_bot_app_conf],
247 Archive["${cf_home}/${bot_version}.tar.gz"] 247 Archive["${cf_home}/trader_${bot_version}.tar.gz"]
248 ], 248 ],
249 } 249 }
250 250
@@ -258,12 +258,11 @@ class role::cryptoportfolio {
258 environment => ["HOME=${cf_home}","PATH=/usr/bin/"], 258 environment => ["HOME=${cf_home}","PATH=/usr/bin/"],
259 require => [ 259 require => [
260 File[$cf_bot_app_conf], 260 File[$cf_bot_app_conf],
261 Archive["${cf_home}/${bot_version}.tar.gz"] 261 Archive["${cf_home}/trader_${bot_version}.tar.gz"]
262 ], 262 ],
263 } 263 }
264 } 264 }
265 265
266 # FIXME: incorrect build for go app
267 # FIXME: restore backup 266 # FIXME: restore backup
268 unless empty($front_version) { 267 unless empty($front_version) {
269 ensure_packages(["go", "npm", "nodejs", "yarn"]) 268 ensure_packages(["go", "npm", "nodejs", "yarn"])
@@ -284,56 +283,10 @@ class role::cryptoportfolio {
284 require => User[$cf_user], 283 require => User[$cf_user],
285 } 284 }
286 285
287 archive { "${cf_home}/${front_version}.tar.gz":
288 path => "${cf_home}/${front_version}.tar.gz",
289 source => "https://git.immae.eu/releases/cryptoportfolio/front/front_${front_version}.tar.gz",
290 checksum_type => "sha256",
291 checksum => $front_sha256,
292 cleanup => false,
293 extract => true,
294 user => $cf_user,
295 username => $facts["ec2_metadata"]["hostname"],
296 password => generate_password(24, $password_seed, "ldap"),
297 extract_path => $cf_front_app,
298 require => [User[$cf_user], File[$cf_front_app]],
299 }
300
301 file { "${cf_home}/front": 286 file { "${cf_home}/front":
302 ensure => "link", 287 ensure => "link",
303 target => $cf_front_app, 288 target => $cf_front_app,
304 before => File[$cf_front_app], 289 before => File[$cf_front_app],
305 } ~>
306 exec { "remove old ${cf_front_app} directory":
307 refreshonly => true,
308 user => $cf_user,
309 command => "/usr/bin/rm -rf ${cf_front_app}",
310 before => File[$cf_front_app],
311 }
312
313 exec { "go-get-dep":
314 user => $cf_user,
315 environment => ["HOME=${cf_home}"],
316 creates => "${cf_home}/go/bin/dep",
317 command => "/usr/bin/go get -u github.com/golang/dep/cmd/dep",
318 require => User[$cf_user],
319 }
320
321 exec { "go-cryptoportfolio-dependencies":
322 cwd => $cf_front_app,
323 user => $cf_user,
324 environment => ["HOME=${cf_home}"],
325 creates => "${cf_front_app}/vendor",
326 command => "${cf_home}/go/bin/dep ensure",
327 require => [Exec["go-get-dep"], Archive["${cf_home}/${front_version}.tar.gz"]],
328 }
329
330 exec { "go-cryptoportfolio-app":
331 cwd => $cf_front_app_api_workdir,
332 user => $cf_user,
333 environment => ["HOME=${cf_home}"],
334 creates => $cf_front_app_api_bin,
335 command => "/usr/bin/make build",
336 require => Exec["go-cryptoportfolio-dependencies"],
337 } 290 }
338 291
339 file { "/etc/systemd/system/cryptoportfolio-app.service": 292 file { "/etc/systemd/system/cryptoportfolio-app.service":
@@ -360,43 +313,79 @@ class role::cryptoportfolio {
360 command => "/usr/bin/pg_dump --schema-only --clean --no-publications $cf_pg_db > /var/lib/postgres/${cf_pg_db}.schema", 313 command => "/usr/bin/pg_dump --schema-only --clean --no-publications $cf_pg_db > /var/lib/postgres/${cf_pg_db}.schema",
361 } 314 }
362 315
316 archive { "${cf_home}/front_${front_version}.tar.gz":
317 path => "${cf_home}/front_${front_version}.tar.gz",
318 source => "https://git.immae.eu/releases/cryptoportfolio/front/front_${front_version}.tar.gz",
319 checksum_type => "sha256",
320 checksum => $front_sha256,
321 cleanup => false,
322 extract => true,
323 user => $cf_user,
324 username => $facts["ec2_metadata"]["hostname"],
325 password => generate_password(24, $password_seed, "ldap"),
326 extract_path => $cf_front_app,
327 require => [User[$cf_user], File[$cf_front_app]],
328 notify => [
329 Exec["web-cryptoportfolio-dependencies"],
330 Exec["go-get-dep"],
331 ]
332 }
333
334 # Api
363 file { $cf_front_app_api_conf: 335 file { $cf_front_app_api_conf:
364 owner => $cf_user, 336 owner => $cf_user,
365 group => $cf_group, 337 group => $cf_group,
366 mode => "0600", 338 mode => "0600",
367 content => template("role/cryptoportfolio/api_conf.toml.erb"), 339 content => template("role/cryptoportfolio/api_conf.toml.erb"),
340 before => Exec["go-cryptoportfolio-app"],
368 } 341 }
369 342
343 exec { "go-get-dep":
344 user => $cf_user,
345 environment => ["HOME=${cf_home}"],
346 creates => "${cf_home}/go/bin/dep",
347 command => "/usr/bin/go get -u github.com/golang/dep/cmd/dep",
348 refreshonly => true,
349 } ~>
350 exec { "go-cryptoportfolio-dependencies":
351 cwd => $cf_front_app,
352 user => $cf_user,
353 environment => ["HOME=${cf_home}"],
354 command => "${cf_home}/go/bin/dep ensure",
355 refreshonly => true,
356 } ~>
357 exec { "go-cryptoportfolio-app":
358 cwd => $cf_front_app_api_workdir,
359 user => $cf_user,
360 environment => ["HOME=${cf_home}"],
361 command => "/usr/bin/make build",
362 refreshonly => true,
363 }
364
365 # Static pages
370 file { $cf_front_app_static_conf: 366 file { $cf_front_app_static_conf:
371 owner => $cf_user, 367 owner => $cf_user,
372 group => $cf_group, 368 group => $cf_group,
373 mode => "0600", 369 mode => "0600",
374 content => template("role/cryptoportfolio/static_conf.env.erb"), 370 content => template("role/cryptoportfolio/static_conf.env.erb"),
375 notify => Exec["remove build ${cf_front_app}/cmd/web/build/"], 371 before => Exec["web-cryptoportfolio-build"],
376 } 372 }
377 373
378 exec { "web-cryptoportfolio-dependencies": 374 exec { "web-cryptoportfolio-dependencies":
379 cwd => "${cf_front_app}/cmd/web", 375 cwd => "${cf_front_app}/cmd/web",
376 user => $cf_user,
380 environment => ["HOME=${cf_home}"], 377 environment => ["HOME=${cf_home}"],
381 command => "/usr/bin/make install", 378 command => "/usr/bin/make install",
382 creates => "${cf_front_app}/cmd/web/node_modules",
383 notify => Exec["remove build ${cf_front_app}/cmd/web/build/"],
384 require => [Package["npm"], Package["nodejs"], Package["yarn"]]
385 }
386
387 exec { "remove build ${cf_front_app}/cmd/web/build/":
388 command => "/usr/bin/rm -rf '${cf_front_app}/cmd/web/build/'",
389 refreshonly => true, 379 refreshonly => true,
390 before => Exec["web-cryptoportfolio-build"] 380 require => [Package["npm"], Package["nodejs"], Package["yarn"]]
391 } 381 } ~>
392
393 exec { "web-cryptoportfolio-build": 382 exec { "web-cryptoportfolio-build":
394 cwd => "${cf_front_app}/cmd/web", 383 cwd => "${cf_front_app}/cmd/web",
384 user => $cf_user,
395 environment => ["HOME=${cf_home}"], 385 environment => ["HOME=${cf_home}"],
396 path => ["${cf_front_app}/cmd/web/node_modules/.bin/", "/usr/bin"], 386 path => ["${cf_front_app}/cmd/web/node_modules/.bin/", "/usr/bin"],
397 command => "/usr/bin/make static ENV=${cf_env}", 387 command => "/usr/bin/make static ENV=${cf_env}",
398 creates => "${cf_front_app}/cmd/web/build/static", 388 refreshonly => true,
399 require => [File[$cf_front_app_static_conf], Exec["web-cryptoportfolio-dependencies"]]
400 } 389 }
401 } 390 }
402} 391}