diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-04-21 10:31:33 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-04-21 10:31:33 +0200 |
commit | 66a9a63ae8e6ef06456e46549b2ff6cffb224c6c (patch) | |
tree | 58624f2d05cf74587ecf74fba92618f0c60b4bc9 | |
parent | bb0e1f38162aa143666ad66c113675c2589fa57b (diff) | |
parent | d5f4e591f9cfedefdd4a71515b46c78e9a77e2ad (diff) | |
download | Puppet-66a9a63ae8e6ef06456e46549b2ff6cffb224c6c.tar.gz Puppet-66a9a63ae8e6ef06456e46549b2ff6cffb224c6c.tar.zst Puppet-66a9a63ae8e6ef06456e46549b2ff6cffb224c6c.zip |
Merge branch 'dev'
-rw-r--r-- | .gitmodules | 3 | ||||
-rwxr-xr-x | bin/install_script.sh | 7 | ||||
-rw-r--r-- | modules/profile/files/redis/socket_shutdown_override.conf | 3 | ||||
-rw-r--r-- | modules/profile/manifests/redis.pp | 34 | ||||
m--------- | modules/redis | 0 | ||||
-rw-r--r-- | modules/role/manifests/cryptoportfolio.pp | 4 | ||||
-rw-r--r-- | modules/role/manifests/cryptoportfolio/bot.pp | 31 | ||||
-rw-r--r-- | modules/role/templates/cryptoportfolio/bot_config_hourly.ini.erb | 17 |
8 files changed, 96 insertions, 3 deletions
diff --git a/.gitmodules b/.gitmodules index 6752dee..c75f803 100644 --- a/.gitmodules +++ b/.gitmodules | |||
@@ -58,3 +58,6 @@ | |||
58 | [submodule "modules/cron"] | 58 | [submodule "modules/cron"] |
59 | path = modules/cron | 59 | path = modules/cron |
60 | url = git://git.immae.eu/github/voxpupuli/puppet-cron | 60 | url = git://git.immae.eu/github/voxpupuli/puppet-cron |
61 | [submodule "modules/redis"] | ||
62 | path = modules/redis | ||
63 | url = git://git.immae.eu/github/arioch/puppet-redis | ||
diff --git a/bin/install_script.sh b/bin/install_script.sh index bd7f38b..36cc594 100755 --- a/bin/install_script.sh +++ b/bin/install_script.sh | |||
@@ -5,6 +5,9 @@ cat <<EOF | |||
5 | $(basename $0) [options] | 5 | $(basename $0) [options] |
6 | --help,-h This help | 6 | --help,-h This help |
7 | 7 | ||
8 | Please chose environment: | ||
9 | --environment env Environment to use for the install | ||
10 | |||
8 | One of the following options is necessary: | 11 | One of the following options is necessary: |
9 | --instance-id id Id of the cloud instance | 12 | --instance-id id Id of the cloud instance |
10 | --vps-id id Id of the vps | 13 | --vps-id id Id of the vps |
@@ -17,14 +20,12 @@ $(basename $0) [options] | |||
17 | --no-reboot-start Don't reboot to rescue at the beginning | 20 | --no-reboot-start Don't reboot to rescue at the beginning |
18 | --no-reboot-end Don't reboot to normal at the end | 21 | --no-reboot-end Don't reboot to normal at the end |
19 | --git-branch branch Use another puppet branch (default: master) | 22 | --git-branch branch Use another puppet branch (default: master) |
20 | --environment env Environment to use for the install (default: production) | ||
21 | EOF | 23 | EOF |
22 | } | 24 | } |
23 | 25 | ||
24 | set -e | 26 | set -e |
25 | 27 | ||
26 | git_branch=master | 28 | git_branch=master |
27 | environment=production | ||
28 | host_user="" | 29 | host_user="" |
29 | password="" | 30 | password="" |
30 | T="" | 31 | T="" |
@@ -89,7 +90,7 @@ while [ -n "$1" ]; do | |||
89 | shift | 90 | shift |
90 | done | 91 | done |
91 | 92 | ||
92 | if [ -z "$T" -o -z "$host_id" ]; then | 93 | if [ -z "$T" -o -z "$host_id" -o -z "$environment" ]; then |
93 | usage | 94 | usage |
94 | exit 1 | 95 | exit 1 |
95 | fi | 96 | fi |
diff --git a/modules/profile/files/redis/socket_shutdown_override.conf b/modules/profile/files/redis/socket_shutdown_override.conf new file mode 100644 index 0000000..8b73264 --- /dev/null +++ b/modules/profile/files/redis/socket_shutdown_override.conf | |||
@@ -0,0 +1,3 @@ | |||
1 | [Service] | ||
2 | ExecStop= | ||
3 | ExecStop=/usr/bin/redis-cli -s /run/redis/redis.sock shutdown | ||
diff --git a/modules/profile/manifests/redis.pp b/modules/profile/manifests/redis.pp new file mode 100644 index 0000000..79871b1 --- /dev/null +++ b/modules/profile/manifests/redis.pp | |||
@@ -0,0 +1,34 @@ | |||
1 | class profile::redis { | ||
2 | file { '/etc/systemd/system/redis.service.d/': | ||
3 | ensure => "directory", | ||
4 | path => "/etc/systemd/system/redis.service.d/", | ||
5 | mode => "0755", | ||
6 | owner => "root", | ||
7 | group => "root" | ||
8 | } -> | ||
9 | file { '/etc/systemd/system/redis.service.d/socket_shutdown.conf': | ||
10 | ensure => "present", | ||
11 | path => "/etc/systemd/system/redis.service.d/noclear.conf", | ||
12 | source => 'puppet:///modules/profile/redis/socket_shutdown_override.conf', | ||
13 | recurse => true, | ||
14 | mode => "0644", | ||
15 | owner => "root", | ||
16 | group => "root", | ||
17 | notify => Service["redis"], | ||
18 | } | ||
19 | |||
20 | package { "ruby-augeas": | ||
21 | ensure => installed, | ||
22 | } -> | ||
23 | class { '::redis': | ||
24 | unixsocket => "/run/redis/redis.sock", | ||
25 | unixsocketperm => "777", | ||
26 | ulimit => false, | ||
27 | daemonize => false, | ||
28 | config_file => "/etc/redis.conf", | ||
29 | config_file_orig => "/etc/redis.conf.puppet", | ||
30 | port => 0, | ||
31 | require => File["/etc/systemd/system/redis.service.d/socket_shutdown.conf"], | ||
32 | } | ||
33 | |||
34 | } | ||
diff --git a/modules/redis b/modules/redis new file mode 160000 | |||
Subproject bfcc2120f7b83342b03241d1429028a6defdd0d | |||
diff --git a/modules/role/manifests/cryptoportfolio.pp b/modules/role/manifests/cryptoportfolio.pp index 6a659cc..53b7abd 100644 --- a/modules/role/manifests/cryptoportfolio.pp +++ b/modules/role/manifests/cryptoportfolio.pp | |||
@@ -9,6 +9,7 @@ class role::cryptoportfolio ( | |||
9 | String $pg_db, | 9 | String $pg_db, |
10 | Optional[String] $pg_hostname = "localhost", | 10 | Optional[String] $pg_hostname = "localhost", |
11 | Optional[String] $pg_port = "5432", | 11 | Optional[String] $pg_port = "5432", |
12 | Optional[String] $redis_host = "/run/redis/redis.sock", | ||
12 | Optional[String] $web_host = undef, | 13 | Optional[String] $web_host = undef, |
13 | Optional[String] $web_port = "", | 14 | Optional[String] $web_port = "", |
14 | Optional[Boolean] $web_ssl = true, | 15 | Optional[Boolean] $web_ssl = true, |
@@ -30,6 +31,9 @@ class role::cryptoportfolio ( | |||
30 | contain "role::cryptoportfolio::notify" | 31 | contain "role::cryptoportfolio::notify" |
31 | 32 | ||
32 | unless empty($trader_version) { | 33 | unless empty($trader_version) { |
34 | if versioncmp($trader_version, "v1.3") >= 0 { | ||
35 | include "profile::redis" | ||
36 | } | ||
33 | contain "role::cryptoportfolio::bot" | 37 | contain "role::cryptoportfolio::bot" |
34 | } | 38 | } |
35 | 39 | ||
diff --git a/modules/role/manifests/cryptoportfolio/bot.pp b/modules/role/manifests/cryptoportfolio/bot.pp index 082e820..2f01c98 100644 --- a/modules/role/manifests/cryptoportfolio/bot.pp +++ b/modules/role/manifests/cryptoportfolio/bot.pp | |||
@@ -3,6 +3,7 @@ class role::cryptoportfolio::bot inherits role::cryptoportfolio { | |||
3 | 3 | ||
4 | $cf_bot_app = "${home}/bot" | 4 | $cf_bot_app = "${home}/bot" |
5 | $cf_bot_app_conf = "${home}/bot_config.ini" | 5 | $cf_bot_app_conf = "${home}/bot_config.ini" |
6 | $cf_bot_app_conf_hourly = "${home}/bot_config_hourly.ini" | ||
6 | $cf_bot_app_reports = "${home}/bot_reports" | 7 | $cf_bot_app_reports = "${home}/bot_reports" |
7 | 8 | ||
8 | ensure_packages(["python", "python-pip"]) | 9 | ensure_packages(["python", "python-pip"]) |
@@ -80,6 +81,36 @@ class role::cryptoportfolio::bot inherits role::cryptoportfolio { | |||
80 | ], | 81 | ], |
81 | } | 82 | } |
82 | 83 | ||
84 | if versioncmp($trader_version, "v1.3") >= 0 { | ||
85 | file { $cf_bot_app_conf_hourly: | ||
86 | owner => $user, | ||
87 | group => $group, | ||
88 | mode => "0600", | ||
89 | content => template("role/cryptoportfolio/bot_config_hourly.ini.erb"), | ||
90 | require => [ | ||
91 | User["$user:"], | ||
92 | Archive["${home}/trader_${trader_version}.tar.gz"], | ||
93 | ], | ||
94 | } | ||
95 | |||
96 | cron::job::multiple { "py-cryptoportfolio-hourly": | ||
97 | ensure => present, | ||
98 | environment => ["HOME=${home}","PATH=/usr/bin/"], | ||
99 | require => [ | ||
100 | File[$cf_bot_app_conf_hourly], | ||
101 | Archive["${home}/trader_${trader_version}.tar.gz"] | ||
102 | ], | ||
103 | jobs => [ | ||
104 | { | ||
105 | command => "cd $cf_bot_app ; python main.py --config $cf_bot_app_conf_hourly", | ||
106 | user => $user, | ||
107 | minute => 30, | ||
108 | description => "Print the current state to redis", | ||
109 | }, | ||
110 | ], | ||
111 | } | ||
112 | } | ||
113 | |||
83 | unless empty($webhook_url) { | 114 | unless empty($webhook_url) { |
84 | exec { "bot-slack-notify": | 115 | exec { "bot-slack-notify": |
85 | refreshonly => true, | 116 | refreshonly => true, |
diff --git a/modules/role/templates/cryptoportfolio/bot_config_hourly.ini.erb b/modules/role/templates/cryptoportfolio/bot_config_hourly.ini.erb new file mode 100644 index 0000000..067f12a --- /dev/null +++ b/modules/role/templates/cryptoportfolio/bot_config_hourly.ini.erb | |||
@@ -0,0 +1,17 @@ | |||
1 | [postgresql] | ||
2 | db-host = <%= @pg_hostname %> | ||
3 | db-port = <%= @pg_port %> | ||
4 | db-user = <%= @pg_user %> | ||
5 | db-password = <%= @pg_password %> | ||
6 | db-database = <%= @pg_db %> | ||
7 | |||
8 | [redis] | ||
9 | redis-host = <%= @redis_host %> | ||
10 | |||
11 | [app] | ||
12 | action = print_balances | ||
13 | report-redis | ||
14 | no-report-path | ||
15 | no-report-db | ||
16 | quiet | ||
17 | debug | ||