X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/a68415b8f2bf106b6ea5948b0605c897b516ef4f..ad6b3f72b1b2bb9c7184f3badc87193b4e57aba0:/cookbooks/chef/recipes/repository.rb?ds=inline diff --git a/cookbooks/chef/recipes/repository.rb b/cookbooks/chef/recipes/repository.rb index 4eaa409bc..d5d8d2bc2 100644 --- a/cookbooks/chef/recipes/repository.rb +++ b/cookbooks/chef/recipes/repository.rb @@ -1,14 +1,14 @@ # -# Cookbook Name:: chef +# Cookbook:: chef # Recipe:: repository # -# Copyright 2013, OpenStreetMap Foundation +# Copyright:: 2013, OpenStreetMap Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -21,50 +21,52 @@ include_recipe "git" keys = data_bag_item("chef", "keys") +chef_gem "bundler" do + version ">= 2.1.4" +end + directory "/var/lib/chef" do owner "chefrepo" group "chefrepo" - mode 0o2775 + mode "2775" end -git "/var/lib/chef" do - action :checkout - repository node[:chef][:repository] - revision "master" - user "chefrepo" - group "chefrepo" -end +%w[public private].each do |repository| + repository_directory = node[:chef][:"#{repository}_repository"] -directory "/var/lib/chef/.chef" do - owner "chefrepo" - group "chefrepo" - mode 0o2775 -end + git "/var/lib/chef/#{repository}" do + action :checkout + repository repository_directory + revision "master" + user "chefrepo" + group "chefrepo" + end -file "/var/lib/chef/.chef/client.pem" do - content keys["git"].join("\n") - owner "chefrepo" - group "chefrepo" - mode 0o660 -end + directory "/var/lib/chef/#{repository}/.chef" do + owner "chefrepo" + group "chefrepo" + mode "2775" + end -cookbook_file "/var/lib/chef/.chef/knife.rb" do - source "knife.rb" - owner "chefrepo" - group "chefrepo" - mode 0o660 -end + file "/var/lib/chef/#{repository}/.chef/client.pem" do + content keys["git"].join("\n") + owner "chefrepo" + group "chefrepo" + mode "660" + end -template "#{node[:chef][:repository]}/hooks/post-receive" do - source "post-receive.erb" - owner "chefrepo" - group "chefrepo" - mode 0o750 -end + cookbook_file "/var/lib/chef/#{repository}/.chef/knife.rb" do + source "knife.rb" + owner "chefrepo" + group "chefrepo" + mode "660" + end -template "/etc/cron.daily/chef-repository-backup" do - source "repository-backup.cron.erb" - owner "root" - group "root" - mode 0o755 + template "#{repository_directory}/hooks/post-receive" do + source "post-receive.erb" + owner "chefrepo" + group "chefrepo" + mode "750" + variables :repository => repository + end end