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"
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
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