Please review pull request #205: (maint) Add Hiera install option opened by (djm68)
Description:
Add -h and --hiera + URI to install Hiera. Creates a default
hiera.yaml file as well.
TODO: add Windows install option as well.
- Opened: Wed May 09 23:09:11 UTC 2012
- Based on: puppetlabs:master (213e56ef727e47e2bf477ed879710ecbf835934b)
- Requested merge: djm68:add_hiera_install_option (a13eba8b3f73a75ff5df4f582c6bab7992562866)
Diff follows:
diff --git a/lib/options_parsing.rb b/lib/options_parsing.rb
index ace6804..a883913 100644
--- a/lib/options_parsing.rb
+++ b/lib/options_parsing.rb
@@ -80,6 +80,15 @@ def self.parse_args
@options[:facter] = value
end
+ @options[:hiera] = 'git://github.com/puppetlabs/hiera.git#HEAD'
+ opts.on('-h', '--hiera URI', 'Select Hiera git install URI',
+ " #{@options[:hiera]}",
+ " - otherwise, as per the puppet argument"
+ ) do |value|
+ #@options[:type] = 'git'
+ @options[:hiera] = value
+ end
+
@options[:plugins] = []
opts.on('--plugin URI', 'Select puppet plugin git install URI') do |value|
#@options[:type] = 'git'
@@ -174,7 +183,7 @@ def self.parse_args
@options[:xml] = value
end
- opts.on( '-h', '--help', 'Display this screen' ) do
+ opts.on('--help', 'Display this screen' ) do
puts opts
exit
end
diff --git a/lib/test_config.rb b/lib/test_config.rb
index bb9f9ac..9064dd6 100644
--- a/lib/test_config.rb
+++ b/lib/test_config.rb
@@ -24,6 +24,7 @@ def self.load_file(config_file)
config['CONFIG']['pe_ver_win'] = puppet_enterprise_version_win if is_pe?
config['CONFIG']['puppet_ver'] = Options.parse_args[:puppet] unless is_pe?
config['CONFIG']['facter_ver'] = Options.parse_args[:facter] unless is_pe?
+ config['CONFIG']['hiera_ver'] = Options.parse_args[:hiera] unless is_pe?
# need to load expect versions of PE binaries
config['VERSION'] = YAML.load_file('ci/pe/pe_version') rescue nil if is_pe?
config
diff --git a/setup/git/04_HieraSetup.rb b/setup/git/04_HieraSetup.rb
new file mode 100644
index 0000000..33d6218
--- /dev/null
+++ b/setup/git/04_HieraSetup.rb
@@ -0,0 +1,61 @@
+test_name "Install and configure Hiera on Puppet Master..."
+
+hieracfg = %q{---
+:backend:
+ - yaml
+:hierarchy:
+ - %{certname}
+ - %{environment}
+ - global
+}
+
+def install_from_git(host, package, repo, revision)
+ target = "#{SourcePath}/#{package}"
+
+ step "Clone #{repo} if needed"
+ on host, "test -d #{SourcePath} || mkdir -p #{SourcePath}"
+ on host, "test -d #{target} || git clone #{repo} #{target}"
+
+ step "Update #{package} and check out revision #{revision}"
+ commands = ["cd #{target}",
+ "remote rm origin",
+ "remote add origin #{repo}",
+ "fetch origin",
+ "clean -fdx",
+ "checkout -f #{revision}"]
+ on host, commands.join(" && git ")
+end
+
+if (options[:hiera]) then
+ step "Parse Hiera options"
+ SourcePath = "/opt/puppet-git-repos"
+ GitHub = 'git://github.com/puppetlabs'
+ IsURI = %r{^[^:]+://|^[email protected]:}
+ IsGitHubURI = %r{(https://github.com/[^/]+/[^/]+)(?:/tree/(.*))$}
+
+ if match = IsGitHubURI.match(options[:hiera]) then
+ HieraRepo = match[1] + '.git'
+ HieraRev = match[2] || 'origin/master'
+ elsif options[:hiera] =~ IsURI then
+ repo, rev = options[:hiera].split('#', 2)
+ HieraRepo = repo
+ HieraRev = rev || 'HEAD'
+ else
+ HieraRepo = "#{GitHub}/hiera.git"
+ HieraRev = options[:hiera]
+ end
+
+ step "Install Hiera from git"
+ install_from_git master, :hiera, HieraRepo, HieraRev
+ version=''
+ on master, "cd /opt/puppet-git-repos/hiera && git describe" do
+ version = stdout.chomp
+ end
+ config[:version][:hiera] = version
+
+ step "Master: Create Hiera config file /etc/puppetlabs/puppet/hiera.yaml"
+ create_remote_file(master, '/etc/puppet/hiera.yaml', hieracfg)
+else
+ Log.notify "Skipping Hiera install"
+ skip_test "Skipping Hiera install"
+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.
