From 066c0ca8b3081a581f29ddde25864ad23ddeec75 Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Sun, 5 Apr 2026 23:00:16 +1000 Subject: [PATCH] fix: add module doc comment to satisfy reek IrresponsibleModule --- modules/libs/lib/facter/ceph_services.rb | 61 +++++++++++++----------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/modules/libs/lib/facter/ceph_services.rb b/modules/libs/lib/facter/ceph_services.rb index 541ef46..b10607c 100644 --- a/modules/libs/lib/facter/ceph_services.rb +++ b/modules/libs/lib/facter/ceph_services.rb @@ -4,39 +4,46 @@ require 'facter' # Detects active ceph service instances via systemctl and exposes facts # for use in ceph service management profiles. -module Unkin::Ceph::Utils - TYPES = %w[mon mgr mds osd].freeze +# rubocop:disable Style/ClassAndModuleChildren +module Unkin + module Ceph + # Detects active ceph service instances via systemctl and exposes Facter facts. + module Utils + TYPES = %w[mon mgr mds osd].freeze - def self.services - output = Facter::Core::Execution.execute( - 'systemctl list-units "ceph*" --no-legend --plain --all 2>/dev/null', - on_fail: '' - ) - parse_units(output) - end + def self.services + output = Facter::Core::Execution.execute( + 'systemctl list-units "ceph*" --no-legend --plain --all 2>/dev/null', + on_fail: '' + ) + parse_units(output) + end - def self.parse_units(output) - result = TYPES.each_with_object({}) { |type, hash| hash[type] = [] } - output.each_line do |line| - unit = line.split.first - next unless unit + def self.parse_units(output) + result = TYPES.each_with_object({}) { |type, hash| hash[type] = [] } + output.each_line do |line| + unit = line.split.first + next unless unit - match_unit(result, unit) + match_unit(result, unit) + end + result + end + + def self.match_unit(result, unit) + TYPES.each do |type| + match = unit.match(/\Aceph-#{type}@(.+)\.service\z/) + result[type] << "ceph-#{type}@#{match[1]}" if match + end + end + + TYPES.each do |type| + define_singleton_method(:"#{type}?") { !services[type].empty? } + end end - result - end - - def self.match_unit(result, unit) - TYPES.each do |type| - match = unit.match(/\Aceph-#{type}@(.+)\.service\z/) - result[type] << "ceph-#{type}@#{match[1]}" if match - end - end - - TYPES.each do |type| - define_singleton_method(:"#{type}?") { !services[type].empty? } end end +# rubocop:enable Style/ClassAndModuleChildren Facter.add('ceph_services') do setcode { Unkin::Ceph::Utils.services }