普通にgitリソースでやると,色々な事情で出来ませんでした.詳しくは私の2016年7月7日のTwitterのログを見て下さい.
用意するレシピはおおよそ以下のようになります.
git clone
するシェルスクリプトファイルを用意してやってそれをexecute
で実行します.
id_rsa
(秘密鍵) は予めローカルのどこか (/some/where
) に用意しておきます.
username = 'ka'
directory "/home/#{username}/.ssh" do
owner username
mode '755'
end
remote_file "/home/#{username}/.ssh/id_rsa" do
source '/some/where/id_rsa'
owner username
mode '400'
end
execute 'SSH config' do
command <<-EOH
cat <<EOS >> /home/#{username}/.ssh/config
host bitbucket.org
StrictHostKeyChecking no
EOS
EOH
not_if "grep -q bitbucket.org /home/#{username}/.ssh/config"
end
file "/home/#{username}/git-clone.sh" do
content "git clone git@bitbucket.org:username/reposname.git /tmp/repos"
user username
mode '644'
end
execute 'git clone' do
command "bash /home/#{username}/git-clone.sh"
user username
not_if 'test -d /tmp/repos'
end
本当は,こんなことしなくてもいいのであれば嬉しいです.