# 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,
directory "/var/lib/chef" do
owner "chefrepo"
group "chefrepo"
- mode 02775
+ mode 0o2775
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 02775
-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["chef-git"].join("\n")
- owner "chefrepo"
- group "chefrepo"
- mode 0660
-end
+ directory "/var/lib/chef/#{repository}/.chef" do
+ owner "chefrepo"
+ group "chefrepo"
+ mode 0o2775
+ end
-cookbook_file "/var/lib/chef/.chef/knife.rb" do
- source "knife.rb"
- owner "chefrepo"
- group "chefrepo"
- mode 0660
-end
+ file "/var/lib/chef/#{repository}/.chef/client.pem" do
+ content keys["git"].join("\n")
+ owner "chefrepo"
+ group "chefrepo"
+ mode 0o660
+ end
-template "#{node[:chef][:repository]}/hooks/post-receive" do
- source "post-receive.erb"
- owner "chefrepo"
- group "chefrepo"
- mode 0750
+ cookbook_file "/var/lib/chef/#{repository}/.chef/knife.rb" do
+ source "knife.rb"
+ owner "chefrepo"
+ group "chefrepo"
+ mode 0o660
+ end
+
+ template "#{repository_directory}/hooks/post-receive" do
+ source "post-receive.erb"
+ owner "chefrepo"
+ group "chefrepo"
+ mode 0o750
+ variables :repository => repository
+ end
end