Basic Sentry setup
Not running the install script automatically at this point yet.
This commit is contained in:
82
site-cookbooks/kosmos_sentry/recipes/default.rb
Normal file
82
site-cookbooks/kosmos_sentry/recipes/default.rb
Normal file
@@ -0,0 +1,82 @@
|
||||
#
|
||||
# Cookbook:: kosmos_sentry
|
||||
# Recipe:: default
|
||||
#
|
||||
|
||||
package "docker"
|
||||
|
||||
remote_file "/usr/local/bin/docker-compose" do
|
||||
source "https://github.com/docker/compose/releases/download/v#{node["sentry"]["docker-compose"]["version"]}/docker-compose-linux-x86_64"
|
||||
checksum node["sentry"]["docker-compose"]["checksum"]
|
||||
mode '0755'
|
||||
end
|
||||
|
||||
deploy_path = "/opt/sentry"
|
||||
|
||||
git deploy_path do
|
||||
repository node["sentry"]["repo"]
|
||||
revision node["sentry"]["revision"]
|
||||
end
|
||||
|
||||
# TODO
|
||||
# Automatically run install script if sentry/sentry.conf.py does not exist yet
|
||||
|
||||
env_config = {
|
||||
sentry_event_retention_days: node["sentry"]["retention_days"],
|
||||
sentry_bind: node["sentry"]["bind"] || node["sentry"]["port"],
|
||||
# Default values from upstream
|
||||
compose_project_name: "sentry-self-hosted",
|
||||
sentry_image: "getsentry/sentry:nightly",
|
||||
snuba_image: "getsentry/snuba:nightly",
|
||||
relay_image: "getsentry/relay:nightly",
|
||||
symbolicator_image: "getsentry/symbolicator:nightly",
|
||||
wal2json_version: "latest",
|
||||
healthcheck_interval: "30s",
|
||||
healthcheck_timeout: "60s",
|
||||
healthcheck_retries: "10"
|
||||
}
|
||||
|
||||
template "#{deploy_path}/.env.custom" do
|
||||
source 'env.custom.erb'
|
||||
mode 0600
|
||||
sensitive true
|
||||
variables config: env_config
|
||||
notifies :restart, "service[sentry]", :delayed
|
||||
end
|
||||
|
||||
systemd_unit "sentry.service" do
|
||||
content({Unit: {
|
||||
Description: "Sentry service using Docker Compose",
|
||||
Requires: "docker.service",
|
||||
After: "docker.service",
|
||||
},
|
||||
Service: {
|
||||
Type: "oneshot",
|
||||
RemainAfterExit: "true",
|
||||
WorkingDirectory: deploy_path,
|
||||
ExecStart: "docker-compose --env-file #{deploy_path}/.env.custom up -d --remove-orphans",
|
||||
ExecStop: "docker-compose stop",
|
||||
StandardOutput: "syslog"
|
||||
},
|
||||
Install: {
|
||||
WantedBy: "multi-user.target"
|
||||
}})
|
||||
verify false
|
||||
triggers_reload true
|
||||
action [:create]
|
||||
end
|
||||
|
||||
service "sentry" do
|
||||
action [:enable, :start]
|
||||
end
|
||||
|
||||
include_recipe 'firewall'
|
||||
|
||||
firewall_rule 'sentry' do
|
||||
port node["sentry"]["port"]
|
||||
protocol :tcp
|
||||
command :allow
|
||||
if node["sentry"]["allowed_ips"]
|
||||
source node["sentry"]["allowed_ips"]
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user