-
-
Save tfheen/800147 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "id": "bert", | |
"git_key": { | |
"name": "git-key-rsa", | |
"public":"ssh-rsa ABCDEFG" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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