feat: add pveceph consul services

- refacter the pveceph facts
- define consul services for osd, mgr, mds and mons
This commit is contained in:
Ben Vincent 2024-06-18 19:57:15 +10:00
parent 0ff9b86782
commit 94aed2df9c
5 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,10 @@
# frozen_string_literal: true
require 'facter'
Facter.add('is_pveceph_mds') do
confine enc_role: 'roles::infra::proxmox::node'
setcode do
system('pgrep -x ceph-mds > /dev/null 2>&1')
end
end

View File

@ -0,0 +1,10 @@
# frozen_string_literal: true
require 'facter'
Facter.add('is_pveceph_osd') do
confine enc_role: 'roles::infra::proxmox::node'
setcode do
system('pgrep -x ceph-osd > /dev/null 2>&1')
end
end

View File

@ -0,0 +1,36 @@
# profiles::proxmox::consul
class profiles::proxmox::consul {
$services = {
'mon' => { 'port' => 6789, 'service_name' => 'ceph-mon', 'fact' => 'is_pveceph_mon' },
'osd' => { 'port' => 6800, 'service_name' => 'ceph-osd', 'fact' => 'is_pveceph_osd' },
'mds' => { 'port' => 6800, 'service_name' => 'ceph-mds', 'fact' => 'is_pveceph_mds' },
'mgr' => { 'port' => 9283, 'service_name' => 'ceph-mgr', 'fact' => 'is_pveceph_mgr' },
}
file { '/usr/local/bin/check_ceph_service.sh':
ensure => file,
mode => '0755',
content => template('profiles/proxmox/check_ceph_service.sh.erb'),
}
$services.each |$key, $value| {
if $facts[$value['fact']] {
consul::service { "ceph-${key}":
service_name => $value['service_name'],
tags => ['proxmox', 'ceph', $key],
address => $facts['networking']['ip'],
port => $value['port'],
checks => [
{
id => "pveceph_${key}_check",
name => "PVECeph ${key} Check",
script => "/usr/local/bin/check_ceph_service.sh ${key}",
interval => '10s',
timeout => '1s',
}
],
}
}
}
}

View File

@ -8,6 +8,7 @@ class profiles::proxmox::init {
include profiles::proxmox::ceph
include profiles::proxmox::config
include profiles::proxmox::weblb
include profiles::proxmox::consul
Class['profiles::proxmox::repos']
-> Class['profiles::proxmox::install']

View File

@ -0,0 +1,10 @@
#!/bin/bash
if [ $# -eq 0 ]; then
echo "No service specified"
exit 1
fi
if systemctl is-active --quiet $1; then
exit 0
else
exit 2
fi