From 85abd2fdbad83430df4824843764719064afb9b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sat, 3 Mar 2018 22:24:19 +0100 Subject: Fetch node informations from LDAP environment, hostname --- modules/role/manifests/cryptoportfolio.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/role/manifests') diff --git a/modules/role/manifests/cryptoportfolio.pp b/modules/role/manifests/cryptoportfolio.pp index 32b6ac7..1e39479 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" -- cgit v1.2.3 From 383fa18a98e98e5e85f35bef17938957c52ee216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sun, 4 Mar 2018 20:49:34 +0100 Subject: Fix front app not building correctly --- modules/role/manifests/cryptoportfolio.pp | 107 +++++++++++++----------------- 1 file changed, 47 insertions(+), 60 deletions(-) (limited to 'modules/role/manifests') 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 { } } - # 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,77 @@ 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_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]], + 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", 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", 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, } } } -- cgit v1.2.3 From 3f868d0b4f48e75aeed56a13f3c4053bac9108f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sun, 4 Mar 2018 20:56:38 +0100 Subject: Rename archive files --- modules/role/manifests/cryptoportfolio.pp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'modules/role/manifests') diff --git a/modules/role/manifests/cryptoportfolio.pp b/modules/role/manifests/cryptoportfolio.pp index c940f33..5fb0438 100644 --- a/modules/role/manifests/cryptoportfolio.pp +++ b/modules/role/manifests/cryptoportfolio.pp @@ -196,8 +196,8 @@ 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, @@ -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,7 +258,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"] ], } } @@ -313,8 +313,8 @@ 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_version}.tar.gz": - path => "${cf_home}/${front_version}.tar.gz", + 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, -- cgit v1.2.3 From c17e63ed33a5260ea5bf0f869d7dce39676526cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sun, 4 Mar 2018 21:05:42 +0100 Subject: Fix user for build --- modules/role/manifests/cryptoportfolio.pp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'modules/role/manifests') diff --git a/modules/role/manifests/cryptoportfolio.pp b/modules/role/manifests/cryptoportfolio.pp index 5fb0438..6c760b5 100644 --- a/modules/role/manifests/cryptoportfolio.pp +++ b/modules/role/manifests/cryptoportfolio.pp @@ -203,7 +203,7 @@ class role::cryptoportfolio { 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, @@ -373,6 +373,7 @@ class role::cryptoportfolio { exec { "web-cryptoportfolio-dependencies": cwd => "${cf_front_app}/cmd/web", + user => $cf_user, environment => ["HOME=${cf_home}"], command => "/usr/bin/make install", refreshonly => true, @@ -380,6 +381,7 @@ class role::cryptoportfolio { } ~> 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}", -- cgit v1.2.3