Skip to content

Instantly share code, notes, and snippets.

@tfheen
Forked from Atalanta/gist:800142
Created January 28, 2011 11:38
Show Gist options
  • Save tfheen/800147 to your computer and use it in GitHub Desktop.
Save tfheen/800147 to your computer and use it in GitHub Desktop.
users = search(:users, "repos:*")
shared_repos = search(:git_repos, "url:*")
users.each do |u|
username = u['id']
u["repos"].each do |target, repo|
git "/home/#{username}/#{target}" do
repository repo['repo']
reference repo['revision']
action :checkout
user username
ssh_wrapper "ssh -i /home/#{username}/.ssh/#{u['git_key']['name']}"
end
end
shared_repos.each do |shared_repo|
git "/home/#{username}/#{shared_repo['id']}" do
repository shared_repo["url"]
reference shared_repo["revision"]
action :checkout
user username
ssh_wrapper "ssh -i /home/#{username}/.ssh/#{u['git_key']['name']}"
only_if {File.exists?("/home/#{username}/.ssh/#{u['git_key']['name']}")}
end
end
end
{ "id": "bert",
"git_key": {
"name": "git-key-rsa",
"public":"ssh-rsa ABCDEFG"
},
% knife data bag show git_repos test_lab
{
"url": "[email protected]:test_lab.git",
"id": "test_lab",
"revision": "HEAD"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment