puppet-prod/modules/libs/lib/facter/pve_nodelist.rb
Ben Vincent 8745c6bcb8
All checks were successful
Build / precommit (pull_request) Successful in 3m31s
fix: resolve warnings/errors
- modules/libs/lib/facter/pve_nodelist.rb:11:5: W: [Correctable] Lint/RedundantCopDisableDirective: Unnecessary disabling of Metrics/BlockNesting.a
- site/profiles/manifests/puppet/puppetboard.pp - WARNING: there should be a single space before '=>' on line 158, column 14 on line 158 (check: space_before_arrow)
- site/profiles/manifests/consul/client.pp - WARNING: there should be a single space before '=>' on line 93, column 13 on line 93 (check: space_before_arrow)
- site/profiles/manifests/ntp/client.pp - WARNING: there should be a single space before '=>' on line 44, column 16 on line 44 (check: space_before_arrow)
- site/profiles/manifests/puppet/enc.pp - WARNING: there should be a single space before '=>' on line 14, column 11 on line 14 (check: space_before_arrow)
- site/profiles/manifests/puppet/enc.pp - WARNING: there should be a single space before '=>' on line 18, column 11 on line 18 (check: space_before_arrow)

- set max block nesting to 4
2025-07-08 20:06:50 +10:00

33 lines
830 B
Ruby

# frozen_string_literal: true
require 'facter'
Facter.add('pve_nodelist') do
confine enc_role: 'roles::infra::proxmox::node'
setcode do
conf_file = '/etc/pve/corosync.conf'
node_list = {}
current_node = nil
if File.exist?(conf_file)
File.foreach(conf_file) do |line|
if line =~ /^\s*node\s*\{/
current_node = {}
elsif line =~ /^\s*\}/
if current_node
node_name = current_node['name']
node_list[node_name] = current_node if node_name
current_node = nil
end
elsif current_node && line =~ /^\s*(\w+):\s*(.+)$/
key = Regexp.last_match(1).strip
value = Regexp.last_match(2).strip
current_node[key] = value
end
end
end
node_list.empty? ? nil : node_list
end
end