]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/oxidized/recipes/default.rb
oxidized: install daemon app into own folder
[chef.git] / cookbooks / oxidized / recipes / default.rb
index c20f865c0f658ebbfed81581c5eaea51ee8232dc..5754ceefe9aef7cd7c68ed16ee9645529f3b500d 100644 (file)
@@ -34,6 +34,12 @@ package %w[
 keys = data_bag_item("oxidized", "keys")
 devices = data_bag_item("oxidized", "devices")
 
+directory "/etc/oxidized" do
+  owner "root"
+  group "root"
+  mode "755"
+end
+
 template "/etc/oxidized/config" do
   source "config.erb"
   owner "oxidized"
@@ -57,6 +63,21 @@ directory "/var/log/oxidized" do
   mode "755"
 end
 
+directory "/opt/oxidized" do
+  owner "oxidized"
+  group "oxidized"
+  mode "755"
+end
+
+git "/opt/oxidized/daemon" do
+  action :sync
+  repository "https://github.com/openstreetmap/oxidized.git"
+  depth 1
+  user "oxidized"
+  group "oxidized"
+  notifies :run, "bundle_install[/opt/oxidized/daemon]"
+end
+
 # Key is set as a deployment key in github repo
 file "/opt/oxidized/.ssh/id_rsa" do
   content keys["git"].join("\n")
@@ -74,21 +95,12 @@ end
 
 execute "/opt/oxidized/.ssh/id_rsa.pub" do
   command "ssh-keygen -f /opt/oxidized/.ssh/id_rsa -y > /opt/oxidized/.ssh/id_rsa.pub"
-  owner "oxidized"
+  user "oxidized"
   group "oxidized"
   creates "/opt/oxidized/.ssh/id_rsa.pub"
   notifies :restart, "service[oxidized]"
 end
 
-git "/opt/oxidized" do
-  action :sync
-  repository "https://github.com/openstreetmap/oxidized.git"
-  depth 1
-  user "oxidized"
-  group "oxidized"
-  notifies :run, "bundle_install[/opt/oxidized]"
-end
-
 git "/var/lib/oxidized/configs.git" do
   action :sync
   repository "git@github.com:openstreetmap/oxidized-configs.git" # Uses oxidized ssh key
@@ -97,7 +109,7 @@ git "/var/lib/oxidized/configs.git" do
   group "oxidized"
 end
 
-bundle_install "/opt/oxidized" do
+bundle_install "/opt/oxidized/daemon" do
   action :nothing
   options "--deployment"
   user "oxidized"
@@ -110,7 +122,7 @@ systemd_service "oxidized" do
   description "oxidized network device backup daemon"
   after "network.target"
   user "oxidized"
-  working_directory "/opt/oxidized"
+  working_directory "/opt/oxidized/daemon"
   exec_start "#{node[:ruby][:bundle]} exec oxidized"
   environment "OXIDIZED_HOME" => "/etc/oxidized",
               "OXIDIZED_LOGS" => "/var/log/oxidized"