1 class role::cryptoportfolio::front inherits role::cryptoportfolio {
2 ensure_resource('exec', 'systemctl daemon-reload', {
3 command => '/usr/bin/systemctl daemon-reload',
7 $password_seed = lookup("base_installation::puppet_pass_seed")
9 $cf_front_app = "${home}/go/src/immae.eu/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front"
10 $cf_front_app_api_workdir = "${cf_front_app}/cmd/app"
11 $cf_front_app_api_bin = "${cf_front_app_api_workdir}/cryptoportfolio-app"
12 $cf_front_app_api_conf = "${home}/conf.toml"
13 $cf_front_app_api_secret = generate_password(24, $password_seed, "cryptoportfolio_api_secret")
15 $cf_front_app_password_reset_secret = generate_password(24, $password_seed, "cryptoportfolio_api_password_reset_secret")
16 $cf_front_app_free_sms_user = lookup("role::cryptoportfolio::front::free_sms_user")
17 $cf_front_app_free_sms_pass = lookup("role::cryptoportfolio::front::free_sms_pass")
19 $cf_front_app_static_conf = "${cf_front_app}/cmd/web/env/prod.env"
21 ensure_packages(["go", "npm", "nodejs", "yarn"])
26 "${home}/go/src/immae.eu",
27 "${home}/go/src/immae.eu/Immae",
28 "${home}/go/src/immae.eu/Immae/Projets",
29 "${home}/go/src/immae.eu/Immae/Projets/Cryptomonnaies",
30 "${home}/go/src/immae.eu/Immae/Projets/Cryptomonnaies/Cryptoportfolio",
32 ensure => "directory",
36 require => User["$user:"],
39 file { "${home}/front":
41 target => $cf_front_app,
42 before => File[$cf_front_app],
45 file { "/etc/systemd/system/cryptoportfolio-app.service":
49 content => template("role/cryptoportfolio/cryptoportfolio-app.service.erb"),
50 notify => Exec["systemctl daemon-reload"],
53 service { 'cryptoportfolio-app':
56 subscribe => [File[$cf_front_app_api_conf], Exec["go-cryptoportfolio-app"], Exec["web-cryptoportfolio-build"]],
58 File["/etc/systemd/system/cryptoportfolio-app.service"],
59 Postgresql::Server::Db[$pg_db]
62 exec { "dump $pg_db structure":
64 user => $::profile::postgresql::pg_user,
65 group => $::profile::postgresql::pg_user,
66 command => "/usr/bin/pg_dump --schema-only --clean --no-publications $pg_db > /var/lib/postgres/${pg_db}.schema",
69 archive { "${home}/front_${front_version}.tar.gz":
70 path => "${home}/front_${front_version}.tar.gz",
71 source => "https://git.immae.eu/releases/cryptoportfolio/front/front_${front_version}.tar.gz",
72 checksum_type => "sha256",
73 checksum => $front_sha256,
77 username => lookup("base_installation::ldap_cn"),
78 password => generate_password(24, $password_seed, "ldap"),
79 extract_path => $cf_front_app,
80 require => [User["$user:"], File[$cf_front_app]],
82 Exec["web-cryptoportfolio-dependencies"],
88 $pg_password = generate_password(24, $password_seed, "postgres_cryptoportfolio")
89 $pg_host = "${pg_hostname}:${pg_port}"
90 file { $cf_front_app_api_conf:
94 content => template("role/cryptoportfolio/api_conf.toml.erb"),
95 before => Exec["go-cryptoportfolio-app"],
100 environment => ["HOME=${home}"],
101 creates => "${home}/go/bin/dep",
102 command => "/usr/bin/go get -u github.com/golang/dep/cmd/dep",
105 exec { "go-cryptoportfolio-dependencies":
106 cwd => $cf_front_app,
108 environment => ["HOME=${home}"],
109 command => "${home}/go/bin/dep ensure",
112 exec { "go-cryptoportfolio-app":
113 cwd => $cf_front_app_api_workdir,
115 environment => ["HOME=${home}"],
116 command => "/usr/bin/make build",
121 file { $cf_front_app_static_conf:
125 content => template("role/cryptoportfolio/static_conf.env.erb"),
126 before => Exec["web-cryptoportfolio-build"],
129 exec { "web-cryptoportfolio-dependencies":
130 cwd => "${cf_front_app}/cmd/web",
132 environment => ["HOME=${home}"],
133 command => "/usr/bin/make install",
135 require => [Package["npm"], Package["nodejs"], Package["yarn"]]
137 exec { "web-cryptoportfolio-build":
138 cwd => "${cf_front_app}/cmd/web",
140 environment => ["HOME=${home}"],
141 path => ["${cf_front_app}/cmd/web/node_modules/.bin/", "/usr/bin"],
142 command => "/usr/bin/make static ENV=${env}",
147 $slack_logger = lookup("role::cryptoportfolio::front::slack_logger")
148 unless empty($slack_logger) {
149 file { "/usr/local/bin/api_logger":
151 content => template("role/cryptoportfolio/api_logger.py.erb"),
154 file { "/etc/systemd/system/cryptoportfolio-log.service":
158 content => template("role/cryptoportfolio/cryptoportfolio-log.service.erb"),
159 notify => Exec["systemctl daemon-reload"],
162 service { 'cryptoportfolio-log':
166 Service["cryptoportfolio-app"],
171 unless empty($webhook_url) {
172 exec { "front-slack-notify":
176 "P_WEBHOOK=${webhook_url}",
177 "P_VERSION=${front_version}",
178 "P_HOST=${web_host}",
179 "P_HTTPS=${web_ssl}",
181 command => "/usr/local/bin/slack-notify",
182 require => File["/usr/local/bin/slack-notify"],
183 subscribe => [Exec["go-cryptoportfolio-app"], Exec["web-cryptoportfolio-build"]],