X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=modules%2Frole%2Fmanifests%2Fcryptoportfolio.pp;fp=modules%2Frole%2Fmanifests%2Fcryptoportfolio.pp;h=6c760b580c9b0c9327e36a97fe85af492f275e08;hb=89c7d1dea4af6026af00624af77bb1a08c8ebd53;hp=32b6ac721a59ad5c7d86e674ba1907c64cdac84d;hpb=a77b768abb31be9e19563e130d763f163496477d;p=perso%2FImmae%2FProjets%2FPuppet.git 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 { $cf_group = "cryptoportfolio" $cf_home = "/opt/cryptoportfolio" $cf_env = "prod" - $cf_front_app_host = "cryptoportfolio.immae.eu" + $cf_front_app_host = lookup("base_installation::system_hostname") |$key| { "example.com" } $cf_front_app_port = "" $cf_front_app_ssl = "true" $cf_front_app = "${cf_home}/go/src/immae.eu/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front" @@ -196,14 +196,14 @@ class role::cryptoportfolio { require => User[$cf_user], } - archive { "${cf_home}/${bot_version}.tar.gz": - path => "${cf_home}/${bot_version}.tar.gz", + archive { "${cf_home}/trader_${bot_version}.tar.gz": + path => "${cf_home}/trader_${bot_version}.tar.gz", source => "https://git.immae.eu/releases/cryptoportfolio/trader/trader_${bot_version}.tar.gz", checksum_type => "sha256", checksum => $bot_sha256, cleanup => false, extract => true, - user => "cryptoportfolio", + user => $cf_user, username => $facts["ec2_metadata"]["hostname"], password => generate_password(24, $password_seed, "ldap"), extract_path => $cf_bot_app, @@ -230,7 +230,7 @@ class role::cryptoportfolio { content => template("role/cryptoportfolio/bot_config.ini.erb"), require => [ User[$cf_user], - Archive["${cf_home}/${bot_version}.tar.gz"], + Archive["${cf_home}/trader_${bot_version}.tar.gz"], ], } @@ -244,7 +244,7 @@ class role::cryptoportfolio { environment => ["HOME=${cf_home}","PATH=/usr/bin/"], require => [ File[$cf_bot_app_conf], - Archive["${cf_home}/${bot_version}.tar.gz"] + Archive["${cf_home}/trader_${bot_version}.tar.gz"] ], } @@ -258,12 +258,11 @@ class role::cryptoportfolio { environment => ["HOME=${cf_home}","PATH=/usr/bin/"], require => [ File[$cf_bot_app_conf], - Archive["${cf_home}/${bot_version}.tar.gz"] + Archive["${cf_home}/trader_${bot_version}.tar.gz"] ], } } - # FIXME: incorrect build for go app # FIXME: restore backup unless empty($front_version) { ensure_packages(["go", "npm", "nodejs", "yarn"]) @@ -284,56 +283,10 @@ class role::cryptoportfolio { require => User[$cf_user], } - archive { "${cf_home}/${front_version}.tar.gz": - path => "${cf_home}/${front_version}.tar.gz", - source => "https://git.immae.eu/releases/cryptoportfolio/front/front_${front_version}.tar.gz", - checksum_type => "sha256", - checksum => $front_sha256, - cleanup => false, - extract => true, - user => $cf_user, - username => $facts["ec2_metadata"]["hostname"], - password => generate_password(24, $password_seed, "ldap"), - extract_path => $cf_front_app, - require => [User[$cf_user], File[$cf_front_app]], - } - file { "${cf_home}/front": ensure => "link", target => $cf_front_app, before => File[$cf_front_app], - } ~> - exec { "remove old ${cf_front_app} directory": - refreshonly => true, - user => $cf_user, - command => "/usr/bin/rm -rf ${cf_front_app}", - before => File[$cf_front_app], - } - - exec { "go-get-dep": - user => $cf_user, - environment => ["HOME=${cf_home}"], - creates => "${cf_home}/go/bin/dep", - command => "/usr/bin/go get -u github.com/golang/dep/cmd/dep", - require => User[$cf_user], - } - - exec { "go-cryptoportfolio-dependencies": - cwd => $cf_front_app, - user => $cf_user, - environment => ["HOME=${cf_home}"], - creates => "${cf_front_app}/vendor", - command => "${cf_home}/go/bin/dep ensure", - require => [Exec["go-get-dep"], Archive["${cf_home}/${front_version}.tar.gz"]], - } - - exec { "go-cryptoportfolio-app": - cwd => $cf_front_app_api_workdir, - user => $cf_user, - environment => ["HOME=${cf_home}"], - creates => $cf_front_app_api_bin, - command => "/usr/bin/make build", - require => Exec["go-cryptoportfolio-dependencies"], } file { "/etc/systemd/system/cryptoportfolio-app.service": @@ -360,43 +313,79 @@ class role::cryptoportfolio { command => "/usr/bin/pg_dump --schema-only --clean --no-publications $cf_pg_db > /var/lib/postgres/${cf_pg_db}.schema", } + archive { "${cf_home}/front_${front_version}.tar.gz": + path => "${cf_home}/front_${front_version}.tar.gz", + source => "https://git.immae.eu/releases/cryptoportfolio/front/front_${front_version}.tar.gz", + checksum_type => "sha256", + checksum => $front_sha256, + cleanup => false, + extract => true, + user => $cf_user, + username => $facts["ec2_metadata"]["hostname"], + password => generate_password(24, $password_seed, "ldap"), + extract_path => $cf_front_app, + require => [User[$cf_user], File[$cf_front_app]], + notify => [ + Exec["web-cryptoportfolio-dependencies"], + Exec["go-get-dep"], + ] + } + + # Api file { $cf_front_app_api_conf: owner => $cf_user, group => $cf_group, mode => "0600", content => template("role/cryptoportfolio/api_conf.toml.erb"), + before => Exec["go-cryptoportfolio-app"], } + exec { "go-get-dep": + user => $cf_user, + environment => ["HOME=${cf_home}"], + creates => "${cf_home}/go/bin/dep", + command => "/usr/bin/go get -u github.com/golang/dep/cmd/dep", + refreshonly => true, + } ~> + exec { "go-cryptoportfolio-dependencies": + cwd => $cf_front_app, + user => $cf_user, + environment => ["HOME=${cf_home}"], + command => "${cf_home}/go/bin/dep ensure", + refreshonly => true, + } ~> + exec { "go-cryptoportfolio-app": + cwd => $cf_front_app_api_workdir, + user => $cf_user, + environment => ["HOME=${cf_home}"], + command => "/usr/bin/make build", + refreshonly => true, + } + + # Static pages file { $cf_front_app_static_conf: owner => $cf_user, group => $cf_group, mode => "0600", content => template("role/cryptoportfolio/static_conf.env.erb"), - notify => Exec["remove build ${cf_front_app}/cmd/web/build/"], + before => Exec["web-cryptoportfolio-build"], } exec { "web-cryptoportfolio-dependencies": cwd => "${cf_front_app}/cmd/web", + user => $cf_user, environment => ["HOME=${cf_home}"], command => "/usr/bin/make install", - creates => "${cf_front_app}/cmd/web/node_modules", - notify => Exec["remove build ${cf_front_app}/cmd/web/build/"], - require => [Package["npm"], Package["nodejs"], Package["yarn"]] - } - - exec { "remove build ${cf_front_app}/cmd/web/build/": - command => "/usr/bin/rm -rf '${cf_front_app}/cmd/web/build/'", refreshonly => true, - before => Exec["web-cryptoportfolio-build"] - } - + require => [Package["npm"], Package["nodejs"], Package["yarn"]] + } ~> exec { "web-cryptoportfolio-build": cwd => "${cf_front_app}/cmd/web", + user => $cf_user, environment => ["HOME=${cf_home}"], path => ["${cf_front_app}/cmd/web/node_modules/.bin/", "/usr/bin"], command => "/usr/bin/make static ENV=${cf_env}", - creates => "${cf_front_app}/cmd/web/build/static", - require => [File[$cf_front_app_static_conf], Exec["web-cryptoportfolio-dependencies"]] + refreshonly => true, } } }