1 class role::cryptoportfolio::bot inherits role::cryptoportfolio {
2 $password_seed = lookup("base_installation::puppet_pass_seed")
4 $cf_bot_app = "${home}/bot"
5 $cf_bot_app_conf = "${home}/bot_config.ini"
6 $cf_bot_app_reports = "${home}/bot_reports"
8 ensure_packages(["python", "python-pip"])
11 ensure => "directory",
15 require => User["$user:"],
18 archive { "${home}/trader_${bot_version}.tar.gz":
19 path => "${home}/trader_${bot_version}.tar.gz",
20 source => "https://git.immae.eu/releases/cryptoportfolio/trader/trader_${bot_version}.tar.gz",
21 checksum_type => "sha256",
22 checksum => $bot_sha256,
26 username => lookup("base_installation::ldap_cn"),
27 password => generate_password(24, $password_seed, "ldap"),
28 extract_path => $cf_bot_app,
29 require => [User["$user:"], File[$cf_bot_app]],
31 exec { "py-cryptoportfolio-dependencies":
34 environment => ["HOME=${home}"],
35 command => "/usr/bin/make install",
36 require => User["$user:"],
39 File[$cf_bot_app_conf],
40 Cron["py-cryptoportfolio-before"],
41 Cron["py-cryptoportfolio-after"],
45 $pg_password = generate_password(24, $password_seed, "postgres_cryptoportfolio")
46 file { $cf_bot_app_conf:
50 content => template("role/cryptoportfolio/bot_config.ini.erb"),
53 Archive["${home}/trader_${bot_version}.tar.gz"],
57 cron { "py-cryptoportfolio-before":
59 command => "cd $cf_bot_app ; python main.py --config $cf_bot_app_conf --before",
61 weekday => 7, # Sunday
64 environment => ["HOME=${home}","PATH=/usr/bin/"],
66 File[$cf_bot_app_conf],
67 Archive["${home}/trader_${bot_version}.tar.gz"]
71 cron { "py-cryptoportfolio-after":
73 command => "cd $cf_bot_app ; python main.py --config $cf_bot_app_conf --after",
75 weekday => 1, # Monday
78 environment => ["HOME=${home}","PATH=/usr/bin/"],
80 File[$cf_bot_app_conf],
81 Archive["${home}/trader_${bot_version}.tar.gz"]
85 unless empty($webhook_url) {
86 exec { "bot-slack-notify":
90 "P_WEBHOOK=${webhook_url}",
91 "P_VERSION=${bot_version}",
95 command => "/usr/local/bin/slack-notify",
96 require => File["/usr/local/bin/slack-notify"],
97 subscribe => Exec["py-cryptoportfolio-dependencies"],