Merge pull request 'feat: add pveceph consul services' (#40) from neoloc/ceph_facts into develop
Reviewed-on: https://git.query.consul/unkinben/puppet-prod/pulls/40
This commit is contained in:
commit
449c6b082e
10
modules/libs/lib/facter/is_pveceph_mds.rb
Normal file
10
modules/libs/lib/facter/is_pveceph_mds.rb
Normal 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
|
||||||
10
modules/libs/lib/facter/is_pveceph_osd.rb
Normal file
10
modules/libs/lib/facter/is_pveceph_osd.rb
Normal 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
|
||||||
36
site/profiles/manifests/proxmox/consul.pp
Normal file
36
site/profiles/manifests/proxmox/consul.pp
Normal 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',
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,6 +8,7 @@ class profiles::proxmox::init {
|
|||||||
include profiles::proxmox::ceph
|
include profiles::proxmox::ceph
|
||||||
include profiles::proxmox::config
|
include profiles::proxmox::config
|
||||||
include profiles::proxmox::weblb
|
include profiles::proxmox::weblb
|
||||||
|
include profiles::proxmox::consul
|
||||||
|
|
||||||
Class['profiles::proxmox::repos']
|
Class['profiles::proxmox::repos']
|
||||||
-> Class['profiles::proxmox::install']
|
-> Class['profiles::proxmox::install']
|
||||||
|
|||||||
10
site/profiles/templates/proxmox/check_ceph_service.sh.erb
Normal file
10
site/profiles/templates/proxmox/check_ceph_service.sh.erb
Normal 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
|
||||||
Loading…
Reference in New Issue
Block a user