]> git.openstreetmap.org Git - chef.git/blob - cookbooks/chef/recipes/repository.rb
Update authorized_keys
[chef.git] / cookbooks / chef / recipes / repository.rb
1 #
2 # Cookbook:: chef
3 # Recipe:: repository
4 #
5 # Copyright:: 2013, OpenStreetMap Foundation
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #     https://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19
20 include_recipe "chef::knife"
21 include_recipe "git"
22
23 keys = data_bag_item("chef", "keys")
24
25 chef_gem "bundler" do
26   version ">= 2.1.4"
27 end
28
29 directory "/var/lib/chef" do
30   owner "chefrepo"
31   group "chefrepo"
32   mode "2775"
33 end
34
35 %w[public private].each do |repository|
36   repository_directory = node[:chef][:"#{repository}_repository"]
37
38   git "/var/lib/chef/#{repository}" do
39     action :checkout
40     repository repository_directory
41     revision "master"
42     user "chefrepo"
43     group "chefrepo"
44   end
45
46   directory "/var/lib/chef/#{repository}/.chef" do
47     owner "chefrepo"
48     group "chefrepo"
49     mode "2775"
50   end
51
52   file "/var/lib/chef/#{repository}/.chef/client.pem" do
53     content keys["git"].join("\n")
54     owner "chefrepo"
55     group "chefrepo"
56     mode "660"
57   end
58
59   cookbook_file "/var/lib/chef/#{repository}/.chef/knife.rb" do
60     source "knife.rb"
61     owner "chefrepo"
62     group "chefrepo"
63     mode "660"
64   end
65
66   template "#{repository_directory}/hooks/post-receive" do
67     source "post-receive.erb"
68     owner "chefrepo"
69     group "chefrepo"
70     mode "750"
71     variables :repository => repository
72   end
73 end