Merge pull request #47 from craigtracey/master

Add support for an alternative an modulepath
This commit is contained in:
Dan Bode
2012-05-14 15:50:36 -07:00
2 changed files with 29 additions and 24 deletions

View File

@@ -8,21 +8,24 @@
require 'puppet' require 'puppet'
repo_file = 'other_repos.yaml' repo_file = 'other_repos.yaml'
default_modulepath = '/etc/puppet/modules'
namespace :modules do namespace :modules do
desc 'clone all required modules' desc 'clone all required modules'
task :clone do task :clone do
repo_hash = YAML.load_file(File.join(File.dirname(__FILE__), repo_file)) repo_hash = YAML.load_file(File.join(File.dirname(__FILE__), repo_file))
repos = (repo_hash['repos'] || {}) repos = (repo_hash['repos'] || {})
modulepath = (repo_hash['modulepath'] || default_modulepath)
repos_to_clone = (repos['repo_paths'] || {}) repos_to_clone = (repos['repo_paths'] || {})
branches_to_checkout = (repos['checkout_branches'] || {}) branches_to_checkout = (repos['checkout_branches'] || {})
repos_to_clone.each do |remote, local| repos_to_clone.each do |remote, local|
# I should check to see if the file is there? # I should check to see if the file is there?
output = `git clone #{remote} #{local}` outpath = File.join(modulepath, local)
output = `git clone #{remote} #{outpath}`
Puppet.debug(output) Puppet.debug(output)
end end
branches_to_checkout.each do |local, branch| branches_to_checkout.each do |local, branch|
Dir.chdir(local) do Dir.chdir(File.join(modulepath, local)) do
output = `git checkout #{branch}` output = `git checkout #{branch}`
end end
# Puppet.debug(output) # Puppet.debug(output)
@@ -33,11 +36,12 @@ namespace :modules do
task 'status' do task 'status' do
repo_hash = YAML.load_file(File.join(File.dirname(__FILE__), repo_file)) repo_hash = YAML.load_file(File.join(File.dirname(__FILE__), repo_file))
repos = (repo_hash['repos'] || {}) repos = (repo_hash['repos'] || {})
modulepath = (repo_hash['modulepath'] || default_modulepath)
repos_to_clone = (repos['repo_paths'] || {}) repos_to_clone = (repos['repo_paths'] || {})
branches_to_checkout = (repos['checkout_branches'] || {}) branches_to_checkout = (repos['checkout_branches'] || {})
repos_to_clone.each do |remote, local| repos_to_clone.each do |remote, local|
# I should check to see if the file is there? # I should check to see if the file is there?
Dir.chdir(local) do Dir.chdir(File.join(modulepath, local)) do
puts "Checking status of #{local}" puts "Checking status of #{local}"
puts `git status` puts `git status`
end end

View File

@@ -1,25 +1,26 @@
# modulepath: /etc/puppet/modules
repos: repos:
repo_paths: repo_paths:
# openstack git repos # openstack git repos
git://github.com/puppetlabs/puppetlabs-nova: /etc/puppet/modules/nova git://github.com/puppetlabs/puppetlabs-nova: nova
git://github.com/puppetlabs/puppetlabs-glance: /etc/puppet/modules/glance git://github.com/puppetlabs/puppetlabs-glance: glance
git://github.com/puppetlabs/puppetlabs-swift: /etc/puppet/modules/swift git://github.com/puppetlabs/puppetlabs-swift: swift
git://github.com/puppetlabs/puppetlabs-keystone: /etc/puppet/modules/keystone git://github.com/puppetlabs/puppetlabs-keystone: keystone
git://github.com/puppetlabs/puppetlabs-horizon: /etc/puppet/modules/horizon git://github.com/puppetlabs/puppetlabs-horizon: horizon
# openstack middleware # openstack middleware
git://github.com/puppetlabs/puppetlabs-rabbitmq: /etc/puppet/modules/rabbitmq git://github.com/puppetlabs/puppetlabs-rabbitmq: rabbitmq
git://github.com/puppetlabs/puppetlabs-mysql: /etc/puppet/modules/mysql git://github.com/puppetlabs/puppetlabs-mysql: mysql
git://github.com/puppetlabs/puppetlabs-git: /etc/puppet/modules/git git://github.com/puppetlabs/puppetlabs-git: git
git://github.com/puppetlabs/puppetlabs-vcsrepo: /etc/puppet/modules/vcsrepo git://github.com/puppetlabs/puppetlabs-vcsrepo: vcsrepo
git://github.com/saz/puppet-memcached: /etc/puppet/modules/memcached git://github.com/saz/puppet-memcached: memcached
git://github.com/puppetlabs/puppetlabs-rsync: /etc/puppet/modules/rsync git://github.com/puppetlabs/puppetlabs-rsync: rsync
# other deps # other deps
git://github.com/ghoneycutt/puppet-xinetd: /etc/puppet/modules/xinetd git://github.com/ghoneycutt/puppet-xinetd: xinetd
git://github.com/saz/puppet-ssh: /etc/puppet/modules/ssh git://github.com/saz/puppet-ssh: ssh
git://github.com/puppetlabs/puppetlabs-stdlib: /etc/puppet/modules/stdlib git://github.com/puppetlabs/puppetlabs-stdlib: stdlib
git://github.com/puppetlabs/puppetlabs-apt: /etc/puppet/modules/apt git://github.com/puppetlabs/puppetlabs-apt: apt
git://github.com/ripienaar/puppet-concat: /etc/puppet/modules/concat git://github.com/ripienaar/puppet-concat: concat
checkout_branches: checkout_branches:
# /etc/puppet/modules/keystone: dev # keystone: dev
# /etc/puppet/modules/glance: dev # glance: dev
# /etc/puppet/modules/nova: dev # nova: dev