- ensure_packages(["go", "npm", "nodejs", "yarn"])
-
- file { [
- "${home}/go/",
- "${home}/go/src",
- "${home}/go/src/immae.eu",
- "${home}/go/src/immae.eu/Immae",
- "${home}/go/src/immae.eu/Immae/Projets",
- "${home}/go/src/immae.eu/Immae/Projets/Cryptomonnaies",
- "${home}/go/src/immae.eu/Immae/Projets/Cryptomonnaies/Cryptoportfolio",
- $cf_front_app]:
- ensure => "directory",
- mode => "0700",
- owner => $user,
- group => $group,
- require => User["$user:"],
- }
-
- file { "${home}/front":
- ensure => "link",
- target => $cf_front_app,
- before => File[$cf_front_app],
- }
-
- file { "/etc/systemd/system/cryptoportfolio-app.service":
- mode => "0644",
- owner => "root",
- group => "root",
- content => template("role/cryptoportfolio/cryptoportfolio-app.service.erb"),
- notify => Exec["systemctl daemon-reload"],
- }
-
- service { 'cryptoportfolio-app':
- enable => true,
- ensure => "running",
- subscribe => [Exec["go-cryptoportfolio-app"], Exec["web-cryptoportfolio-build"]],
- require => [
- File["/etc/systemd/system/cryptoportfolio-app.service"],
- Postgresql::Server::Db[$pg_db]
- ],
- } ~>
- exec { "dump $pg_db structure":
- refreshonly => true,
- user => $::profile::postgresql::pg_user,
- group => $::profile::postgresql::pg_user,
- command => "/usr/bin/pg_dump --schema-only --clean --no-publications $pg_db > /var/lib/postgres/${pg_db}.schema",
- }
-
- archive { "${home}/front_${front_version}.tar.gz":
- path => "${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 => $user,
- username => lookup("base_installation::ldap_cn"),
- password => generate_password(24, $password_seed, "ldap"),
- extract_path => $cf_front_app,
- require => [User["$user:"], File[$cf_front_app]],
- notify => [
- Exec["web-cryptoportfolio-dependencies"],
- Exec["go-get-dep"],
- ]
- }
-
- # Api
- file { $cf_front_app_api_conf:
- owner => $user,
- group => $group,
- mode => "0600",
- content => template("role/cryptoportfolio/api_conf.toml.erb"),
- before => Exec["go-cryptoportfolio-app"],
- }
-
- exec { "go-get-dep":
- user => $user,
- environment => ["HOME=${home}"],
- creates => "${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 => $user,
- environment => ["HOME=${home}"],
- command => "${home}/go/bin/dep ensure",
- refreshonly => true,
- } ~>
- exec { "go-cryptoportfolio-app":
- cwd => $cf_front_app_api_workdir,
- user => $user,
- environment => ["HOME=${home}"],
- command => "/usr/bin/make build",
- refreshonly => true,
- }
-
- # Static pages
- file { $cf_front_app_static_conf:
- owner => $user,
- group => $group,
- mode => "0600",
- content => template("role/cryptoportfolio/static_conf.env.erb"),
- before => Exec["web-cryptoportfolio-build"],
- }
-
- exec { "web-cryptoportfolio-dependencies":
- cwd => "${cf_front_app}/cmd/web",
- user => $user,
- environment => ["HOME=${home}"],
- command => "/usr/bin/make install",
- refreshonly => true,
- require => [Package["npm"], Package["nodejs"], Package["yarn"]]
- } ~>
- exec { "web-cryptoportfolio-build":
- cwd => "${cf_front_app}/cmd/web",
- user => $user,
- environment => ["HOME=${home}"],
- path => ["${cf_front_app}/cmd/web/node_modules/.bin/", "/usr/bin"],
- command => "/usr/bin/make static ENV=${env}",
- refreshonly => true,
- }
-
- unless empty($webhook_url) {
- exec { "front-slack-notify":
- refreshonly => true,
- environment => [
- "P_PROJECT=Front",
- "P_WEBHOOK=${webhook_url}",
- "P_VERSION=${front_version}",
- "P_HOST=${web_host}",
- "P_HTTPS=${web_ssl}",
- ],
- command => "/usr/local/bin/slack-notify",
- require => File["/usr/local/bin/slack-notify"],
- subscribe => [Exec["go-cryptoportfolio-app"], Exec["web-cryptoportfolio-build"]],
- }
- }