# # Cookbook:: kosmos_sentry # Recipe:: default # apt_repository "docker" do uri "https://download.docker.com/linux/ubuntu" key "https://download.docker.com/linux/ubuntu/gpg" components ["stable"] end %w[docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin].each do |pkg| package pkg end deploy_path = "/opt/sentry" git deploy_path do repository node["sentry"]["repo"] revision node["sentry"]["revision"] # TODO test and uncomment # notifies :run, "execute[run_install_script]", :immediately end execute "run_install_script" do cwd deploy_path command "./install.sh --apply-automatic-config-updates --no-report-self-hosted-issues" action :nothing end credentials = data_bag_item("credentials", "sentry") env_config = { sentry_event_retention_days: node["sentry"]["retention_days"], sentry_bind: node["sentry"]["bind"] || node["sentry"]["port"], launchpad_rpc_shared_secret: credentials["launchpad_rpc_shared_secret"] } template "#{deploy_path}/.env.custom" do source 'env.custom.erb' mode 0600 sensitive true variables config: env_config # TODO # 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: "yes", WorkingDirectory: deploy_path, ExecStart: "docker compose --env-file .env --env-file .env.custom up -d --wait", ExecStop: "docker compose down --remove-orphans", StandardOutput: "syslog", TimeoutStartSec: 600, TimeoutStopSec: 300 }, Install: { WantedBy: "multi-user.target" }}) verify false triggers_reload true action [:create] end service "sentry" do action [:enable] 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