refacter: renamed facts to libs

This commit is contained in:
2024-02-17 23:03:54 +11:00
parent e10bed689c
commit 1030ba460e
16 changed files with 0 additions and 0 deletions
@@ -0,0 +1,22 @@
# frozen_string_literal: true
# check if the /etc/my.cnf.d/server.cnf file exists,
# open it and search for the 'datadir =' option
# store the datadir value as this fact
require 'facter'
Facter.add('mariadb_datapath') do
setcode do
if File.exist?('/etc/my.cnf.d/server.cnf')
datadir = nil
File.foreach('/etc/my.cnf.d/server.cnf') do |line|
match = line.match(/^\s*datadir\s*=\s*(.+)\s*$/)
if match
datadir = match[1].strip
break
end
end
datadir
end
end
end