X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/524d90d022751710980613df6b943291fc1498d6..87f64c5bb4a347382e1886130c538ec76bc44731:/cookbooks/prometheus/resources/exporter.rb diff --git a/cookbooks/prometheus/resources/exporter.rb b/cookbooks/prometheus/resources/exporter.rb index d3652d3b8..8dd928846 100644 --- a/cookbooks/prometheus/resources/exporter.rb +++ b/cookbooks/prometheus/resources/exporter.rb @@ -22,14 +22,19 @@ default_action :create property :exporter, :kind_of => String, :name_property => true property :port, :kind_of => Integer, :required => [:create] property :listen_switch, :kind_of => String, :default => "web.listen-address" +property :exporter_options, :kind_of => [String, Array] property :package, :kind_of => String +property :package_options, :kind_of => String property :defaults, :kind_of => String property :service, :kind_of => String action :create do - package package_name + package package_name do + options new_resource.package_options + end template defaults_name do + cookbook "prometheus" source "defaults.erb" owner "root" group "root" @@ -42,6 +47,15 @@ action :create do subscribes :restart, "template[#{defaults_name}]" end + firewall_rule "accept-prometheus-#{new_resource.name}" do + action :accept + source "osm" + dest "fw" + proto "tcp:syn" + dest_ports new_resource.port + only_if { node[:prometheus][:mode] == "external" } + end + node.default[:prometheus][:exporters][new_resource.exporter] = listen_address end @@ -65,7 +79,11 @@ action_class do end def listen_address - "#{node.internal_ipaddress}:#{new_resource.port}" + if node[:prometheus][:mode] == "wireguard" + "[#{node[:prometheus][:address]}]:#{new_resource.port}" + else + "#{node[:prometheus][:address]}:#{new_resource.port}" + end end def service_name