From 9530a4e1f0bc650ed91ea0dbe4002656d1eeb722 Mon Sep 17 00:00:00 2001 From: Cool Fire Date: Sat, 12 Sep 2020 16:02:14 +0200 Subject: [PATCH] Create role for heartbeat/status page --- profile/manifests/heartbeat.pp | 61 ++++++++++++++++++++++++++++++++++ role/manifests/heartbeat.pp | 4 +-- 2 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 profile/manifests/heartbeat.pp diff --git a/profile/manifests/heartbeat.pp b/profile/manifests/heartbeat.pp new file mode 100644 index 0000000..e21d82b --- /dev/null +++ b/profile/manifests/heartbeat.pp @@ -0,0 +1,61 @@ +# Class: profile::heartbeat +# +# - Set up OS packages +# - Manage certificates +# - Manage apache vhost +# - Deploy heartbeat git repository +# + +class profile::heartbeat ( + String $vhost = 'heartbeat.insomnia247.nl', +) { + include ::profile::base::packages + include ::profile::domaincerts + include ::site_apache + include ::site_ssh::keys_only + include ::site_rundeck::client + include ::systemd + + # Create apache vhost + site_apache::vhost::system { $vhost: + aliases => [ 'status.insomnia247.nl' ], + customdirectives => " + PassengerAppRoot /var/www/vhosts/${vhost}/ + RailsEnv production + PassengerUser www-data + PassengerGroup www-data" + } + + # Pull down repository + vcsrepo { "/var/www/vhosts/${vhost}/": + ensure => latest, + provider => git, + user => 'www-data', + group => 'www-data', + source => 'https://github.com/cFire/heartbeat.git', + } + + ~> exec { 'bundle_install': + command => '/usr/bin/bundle install --path vendor/bundle', + cwd => "/var/www/vhosts/${vhost}/", + user => 'www-data', + refreshonly => true, + } + + ~> exec { "${vhost} Touch restart": + command => "/usr/bin/touch /var/www/vhosts/${vhost}/tmp/restart.txt", + user => 'www-data', + refreshonly => true, + } + + cron { 'heartbeat_checker': + command => "cd /var/www/vhosts/${vhost}/; bundle exec ruby checker.rb", + environment => [ 'MAILTO=""' ], + user => 'www-data', + minute => '*/5', + } + + Class['Profile::Base::Packages'] + -> Site_apache::Vhost::System[$vhost] + -> Vcsrepo["/var/www/vhosts/${vhost}/"] +} diff --git a/role/manifests/heartbeat.pp b/role/manifests/heartbeat.pp index c7f167d..7c5f976 100644 --- a/role/manifests/heartbeat.pp +++ b/role/manifests/heartbeat.pp @@ -1,8 +1,8 @@ # Class: role::heartbeat # -# Install and configure nginx for heartbeat/status page +# Install and configure webserver for heartbeat/status page # class role::heartbeat inherits role::base { - # resources + include ::profile::heartbeat } -- GitLab