puppet-prod/modules/facts/lib/facter/mysql_wsrep.rb
Ben Vincent 1f7b347ef4 refacter: tidy facts
- create a facts module, move all facts to this module
2024-02-17 22:57:36 +11:00

22 lines
541 B
Ruby

# frozen_string_literal: true
# skip if mysql isnt installed or active
if system('which mysql > /dev/null 2>&1') && system('systemctl is-active --quiet mariadb')
# export mysql wsrep status
wsrep_status = `mysql -e "SHOW STATUS LIKE 'wsrep%';"`
# loop over the output
wsrep_status.each_line do |line|
# skip the line unless it starts with 'wsrep_'
next unless line.match(/^wsrep_/)
key, value = line.split("\t")
Facter.add("mysql_#{key.strip}") do
setcode do
value.strip
end
end
end
end