aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-03-04 20:49:34 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-03-04 21:19:38 +0100
commit383fa18a98e98e5e85f35bef17938957c52ee216 (patch)
tree49c21a38de7c5480a062629ff83506bec1365fc5 /modules
parenta545a4222ee6a4bcdee9c73a8f4abe0e38f1bdad (diff)
downloadPuppet-383fa18a98e98e5e85f35bef17938957c52ee216.tar.gz
Puppet-383fa18a98e98e5e85f35bef17938957c52ee216.tar.zst
Puppet-383fa18a98e98e5e85f35bef17938957c52ee216.zip
Fix front app not building correctly
Diffstat (limited to 'modules')
-rw-r--r--modules/role/manifests/cryptoportfolio.pp107
1 files changed, 47 insertions, 60 deletions
diff --git a/modules/role/manifests/cryptoportfolio.pp b/modules/role/manifests/cryptoportfolio.pp
index 1e39479..c940f33 100644
--- a/modules/role/manifests/cryptoportfolio.pp
+++ b/modules/role/manifests/cryptoportfolio.pp
@@ -263,7 +263,6 @@ class role::cryptoportfolio {
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,77 @@ 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_version}.tar.gz":
317 path => "${cf_home}/${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"],
341 }
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,
368 } 363 }
369 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",
380 environment => ["HOME=${cf_home}"], 376 environment => ["HOME=${cf_home}"],
381 command => "/usr/bin/make install", 377 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, 378 refreshonly => true,
390 before => Exec["web-cryptoportfolio-build"] 379 require => [Package["npm"], Package["nodejs"], Package["yarn"]]
391 } 380 } ~>
392
393 exec { "web-cryptoportfolio-build": 381 exec { "web-cryptoportfolio-build":
394 cwd => "${cf_front_app}/cmd/web", 382 cwd => "${cf_front_app}/cmd/web",
395 environment => ["HOME=${cf_home}"], 383 environment => ["HOME=${cf_home}"],
396 path => ["${cf_front_app}/cmd/web/node_modules/.bin/", "/usr/bin"], 384 path => ["${cf_front_app}/cmd/web/node_modules/.bin/", "/usr/bin"],
397 command => "/usr/bin/make static ENV=${cf_env}", 385 command => "/usr/bin/make static ENV=${cf_env}",
398 creates => "${cf_front_app}/cmd/web/build/static", 386 refreshonly => true,
399 require => [File[$cf_front_app_static_conf], Exec["web-cryptoportfolio-dependencies"]]
400 } 387 }
401 } 388 }
402} 389}