key "https://download.docker.com/linux/ubuntu/gpg"
end
+apt_repository "grafana" do
+ action repository_actions["grafana"]
+ uri "https://packages.grafana.com/enterprise/deb"
+ distribution "stable"
+ components ["main"]
+ key "https://packages.grafana.com/gpg.key"
+end
+
package "unattended-upgrades"
if Dir.exist?("/usr/share/unattended-upgrades")
default[:prometheus][:exporters] = {}
+
+if node[:recipes].include?("prometheus::server")
+ default[:apt][:sources] |= ["grafana"]
+end
version "1.0.0"
supports "ubuntu"
+depends "apache"
+depends "apt"
depends "networking"
# limitations under the License.
#
+include_recipe "apache"
+include_recipe "apt"
+
+passwords = data_bag_item("prometheus", "passwords")
+
package "prometheus"
clients = search(:node, "recipes:prometheus\\:\\:default").sort_by(&:name)
action [:enable, :start]
subscribes :reload, "template[/etc/prometheus/prometheus.yml]"
end
+
+package "grafana-enterprise"
+
+template "/etc/grafana/grafana.ini" do
+ source "grafana.ini.erb"
+ owner "root"
+ group "grafana"
+ mode "640"
+ variables :passwords => passwords
+end
+
+service "grafana-server" do
+ action [:enable, :start]
+end
+
+apache_module "alias"
+apache_module "proxy_http"
+
+ssl_certificate "prometheus.openstreetmap.org" do
+ domains ["prometheus.openstreetmap.org", "prometheus.osm.org"]
+ notifies :reload, "service[apache2]"
+end
+
+apache_site "prometheus.openstreetmap.org" do
+ template "apache.erb"
+end
--- /dev/null
+# DO NOT EDIT - This file is being maintained by Prometheus
+
+<VirtualHost *:80>
+ ServerName prometheus.openstreetmap.org
+ ServerAlias prometheus.osm.org
+ ServerAdmin webmaster@openstreetmap.org
+
+ CustomLog /var/log/apache2/prometheus.openstreetmap.org-access.log combined
+ ErrorLog /var/log/apache2/prometheus.openstreetmap.org-error.log
+
+ RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
+ Redirect permanent / https://prometheus.openstreetmap.org/
+</VirtualHost>
+
+<VirtualHost *:443>
+ ServerName prometheus.openstreetmap.org
+ ServerAdmin webmaster@openstreetmap.org
+
+ CustomLog /var/log/apache2/prometheus.openstreetmap.org-access.log combined
+ ErrorLog /var/log/apache2/prometheus.openstreetmap.org-error.log
+
+ SSLEngine on
+ SSLCertificateFile /etc/ssl/certs/prometheus.openstreetmap.org.pem
+ SSLCertificateKeyFile /etc/ssl/private/prometheus.openstreetmap.org.key
+
+ ProxyPass / http://localhost:3000/
+ ProxyPreserveHost on
+</VirtualHost>
--- /dev/null
+# DO NOT EDIT - This file is being maintained by Chef
+
+[server]
+root_url = https://prometheus.openstreetmap.org/
+
+[security]
+admin_user = admin
+admin_password = <%= @passwords[:grafana_admin] %>
--- /dev/null
+{
+ "id": "passwords",
+ "grafana_admin": "grafana_admin"
+}
--- /dev/null
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("apache2") do
+ it { should be_installed }
+end
+
+describe service("apache2") do
+ it { should be_enabled }
+ it { should be_running }
+end
+
+describe port(80) do
+ it { should be_listening.with("tcp") }
+end
+
+describe port(443) do
+ it { should be_listening.with("tcp") }
+end
--- /dev/null
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("grafana-enterprise") do
+ it { should be_installed }
+end
+
+describe service("grafana-server") do
+ it { should be_enabled }
+ it { should be_running }
+end
+
+describe port(3000) do
+ it { should be_listening.with("tcp6") }
+end