X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=modules%2Frole%2Fmanifests%2Fcryptoportfolio.pp;h=59dacd0254e1e6c4a4e067d0b5ac52d1e42546f1;hb=55b362b98a42ecfef010d3aad9a973084d57898a;hp=046b79ef3f223f4445ef4ee0e462c48fef2bf87b;hpb=76a321e1b7da9f122f35a9722d9f8f331b06f8aa;p=perso%2FImmae%2FProjets%2FPuppet.git diff --git a/modules/role/manifests/cryptoportfolio.pp b/modules/role/manifests/cryptoportfolio.pp index 046b79e..59dacd0 100644 --- a/modules/role/manifests/cryptoportfolio.pp +++ b/modules/role/manifests/cryptoportfolio.pp @@ -1,86 +1,49 @@ -class role::cryptoportfolio { +class role::cryptoportfolio ( + String $user, + String $group, + String $home, + Optional[String] $env = "prod", + Optional[String] $webhook_url = undef, + String $pg_user, + String $pg_user_replication, + String $pg_db, + Optional[String] $pg_hostname = "/run/postgresql", + Optional[String] $pg_port = "5432", + Optional[String] $redis_host = "/run/redis/redis.sock", + Optional[String] $smtp_login = undef, + Optional[String] $smtp_password = undef, + Optional[String] $smtp_host = undef, + Optional[String] $mail_from = undef, + Optional[String] $web_host = undef, + Optional[String] $web_port = "", + Optional[Boolean] $web_ssl = true, + Optional[String] $front_version = undef, + Optional[String] $front_sha256 = undef, + Optional[String] $trader_version = undef, + Optional[String] $trader_sha256 = undef, +) { include "base_installation" + include "profile::tools" include "profile::postgresql" + include "profile::apache" + include "profile::xmr_stak" + include "profile::boinc" - $password_seed = lookup("base_installation::puppet_pass_seed") |$key| { {} } + contain "role::cryptoportfolio::postgresql" + contain "role::cryptoportfolio::apache" - postgresql::server::db { 'cryptoportfolio': - user => 'cryptoportfolio', - password => postgresql_password('cryptoportfolio', generate_password(24, $password_seed, "postgres_cryptoportfolio")), - } - - postgresql::server::pg_hba_rule { 'allow localhost TCP access to cryptoportfolio user': - type => 'host', - database => 'cryptoportfolio', - user => 'cryptoportfolio', - address => '127.0.0.1/32', - auth_method => 'md5', - order => "b0", - } - postgresql::server::pg_hba_rule { 'allow localhost ip6 TCP access to cryptoportfolio user': - type => 'host', - database => 'cryptoportfolio', - user => 'cryptoportfolio', - address => '::1/128', - auth_method => 'md5', - order => "b0", - } - - class { 'nginx': } + contain "role::cryptoportfolio::notify" - nginx::resource::server { 'cryptoportfolio.immae.eu': - listen_port => 80, - proxy => 'http://localhost:8000', - } - - ensure_packages(["go", "npm", "nodejs", "yarn"]) - - user { "cryptoportfolio": - name => "cryptoportfolio", - ensure => "present", - managehome => true, - home => "/opt/cryptoportfolio", - system => true, - password => '!!', + unless empty($trader_version) { + if versioncmp($trader_version, "v1.3") >= 0 { + include "profile::redis" + } + contain "role::cryptoportfolio::bot" } - $front_version = lookup("cryptoportfolio::front_version") |$key| { {} } - $front_sha256 = lookup("cryptoportfolio::front_sha256") |$key| { {} } - + # FIXME: restore backup unless empty($front_version) { - file { "/opt/cryptoportfolio/front": - ensure => directory, - mode => "0700", - owner => "cryptoportfolio", - group => "cryptoportfolio", - } - - file { "/opt/cryptoportfolio/front/${front_version}": - ensure => directory, - mode => "0700", - owner => "cryptoportfolio", - group => "cryptoportfolio", - require => File["/opt/cryptoportfolio/front"], - } - - archive { "/opt/cryptoportfolio/front/${front_version}.tar.gz": - path => "/opt/cryptoportfolio/front/${front_version}.tar.gz", - source => "https://git.immae.eu/releases/cryptoportfolio/front/front_${front_version}.tar.gz", - creates => "/opt/cryptoportfolio/front/${front_version}/README.md", - checksum_type => "sha256", - checksum => $front_sha256, - cleanup => false, - extract => true, - extract_path => "/opt/cryptoportfolio/front/${front_version}", - require => File["/opt/cryptoportfolio/front/${front_version}"], - } - - file { "/opt/cryptoportfolio/front/current": - ensure => "link", - target => "/opt/cryptoportfolio/front/${front_version}", - require => Archive["/opt/cryptoportfolio/front/${front_version}.tar.gz"] - } + contain "role::cryptoportfolio::front" } - }