refacter: renamed facts to libs
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user