Please review pull request #206: Add --modules command line option to test modules opened by (jeffmccune)
Description:
Without this patch the git acceptance type has no way to install
arbitrary Puppet modules. We need this functionality to properly test
the Registry puppet module.
This patch fixes the problem by providing a --modules command line
option. This option takes a list of URI's to Puppet module
repositories. Each listed URI will be cloned into /opt/puppet-git-repos
on each master system using the 04_InstallModules setup step when using
--type git.
Individual test cases may then configure a modulepath directory that
symlinks in the modules we're testing are "installed" on the puppet
master systems.
- Opened: Thu May 10 00:08:48 UTC 2012
- Based on: puppetlabs:master (cb22cb78ec6f05b3c377204c240024475afaa99c)
- Requested merge: jeffmccune:feature/master/registry_acceptance (eb5ce9724ad2121cb75e863e6f2c317055e32f33)
Diff follows:
diff --git a/lib/options_parsing.rb b/lib/options_parsing.rb
index ace6804..6cf07cb 100644
--- a/lib/options_parsing.rb
+++ b/lib/options_parsing.rb
@@ -80,6 +80,11 @@ def self.parse_args
@options[:facter] = value
end
+ @options[:modules] = []
+ opts.on('--modules URI', 'Select puppet module git install URI') do |value|
+ @options[:modules] << value
+ end
+
@options[:plugins] = []
opts.on('--plugin URI', 'Select puppet plugin git install URI') do |value|
#@options[:type] = 'git'
diff --git a/setup/git/04_InstallModules.rb b/setup/git/04_InstallModules.rb
new file mode 100644
index 0000000..96d2f36
--- /dev/null
+++ b/setup/git/04_InstallModules.rb
@@ -0,0 +1,56 @@
+require 'pathname'
+
+# Given an array of modules specified by the --modules command line option,
+# Parse all of them into an array of usable hash structures.
+class PuppetModules
+ attr_reader :modules
+
+ def initialize(modules=[])
+ @modules = modules
+ end
+
+ def list
+ return [] unless modules
+ modules.collect do |uri|
+ git_url, git_ref = uri.split '#'
+ folder = Pathname.new(git_url).basename('.git')
+ name = folder.to_s.split('-', 2)[1] || folder.to_s
+ {
+ :name => name,
+ :url ="" git_url,
+ :folder => folder.to_s,
+ :ref => git_ref,
+ }
+ end
+ end
+end
+
+modules = PuppetModules.new(options[:modules]).list
+
+step "Masters: Install Puppet Modules"
+masters = hosts.select { |host| host['roles'].include? 'master' }
+
+masters.each do |host|
+ modules.each do |mod|
+ # The idea here is that each test can symlink the modules they want from a
+ # temporary directory to this location. This will preserve the global
+ # state of the system while allowing individual test cases to quickly run
+ # with a module "installed" in the module path.
+ moddir = "/opt/puppet-git-repos"
+ target = "#{moddir}/#{mod[:name]}"
+
+ step "Clone #{mod[:url]} if needed"
+ on host, "test -d #{moddir} || mkdir -p #{moddir}"
+ on host, "test -d #{target} || git clone #{mod[:url]} #{target}"
+ step "Update #{mod[:name]} and check out revision #{mod[:ref]}"
+
+ commands = ["cd #{target}",
+ "remote rm origin",
+ "remote add origin #{mod[:url]}",
+ "fetch origin",
+ "clean -fdx",
+ "checkout -f #{mod[:ref]}"]
+
+ on host, commands.join(" && git ")
+ end
+end
-- You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
