lib/system_builder/configurator.rb in system-builder-0.0.23 vs lib/system_builder/configurator.rb in system-builder-0.0.26
- old
+ new
@@ -4,11 +4,11 @@
def initialize(proc = nil, &block)
@proc = (proc or block)
end
- def configure(chroot)
+ def configure(chroot, options = {})
@proc.call chroot
end
end
@@ -23,36 +23,38 @@
def puppet_directories
%w{manifests files modules templates plugins}.collect { |d| "#{manifest}/#{d}" }.select { |d| File.directory?(d) }
end
- def configure(chroot)
+ def configure(chroot, options = {})
+ debian_release = (options.delete(:debian_release) or :lenny)
+
puts "* run puppet configuration"
- unless chroot.image.exists?("/etc/apt/sources.list.d/lenny-backports.list")
- chroot.image.open("/etc/apt/sources.list.d/lenny-backports.list") do |f|
- f.puts "deb http://backports.debian.org/debian-backports lenny-backports main contrib non-free"
+ unless chroot.image.exists?("/etc/apt/sources.list.d/#{debian_release}-backports.list")
+ chroot.image.open("/etc/apt/sources.list.d/#{debian_release}-backports.list") do |f|
+ f.puts "deb http://backports.debian.org/debian-backports #{debian_release}-backports main contrib non-free"
end
chroot.image.open("/etc/apt/preferences") do |f|
f.puts "Package: puppet"
- f.puts "Pin: release a=lenny-backports"
+ f.puts "Pin: release a=#{debian_release}-backports"
f.puts "Pin-Priority: 999"
- end
+ end if debian_release == :lenny
chroot.sudo "apt-get update"
end
- chroot.apt_install :puppet
+ chroot.apt_install :puppet, :rubygems
chroot.image.open("/etc/default/puppet") do |f|
f.puts "START=no"
end
unless File.directory?(manifest)
chroot.image.install "/tmp/puppet.pp", manifest
# chmod +r to make file readable for buildbot
- chroot.sudo "puppet --color=false tmp/puppet.pp | tee /tmp/puppet.log && chmod +r /tmp/puppet.log"
+ chroot.sudo "puppet --color=false tmp/puppet.pp 2>&1 | tee /tmp/puppet.log && chmod +r /tmp/puppet.log"
process_log_file(chroot.image.expand_path("/tmp/puppet.log"))
else
context_dir = "/tmp/puppet"
chroot.image.mkdir context_dir
@@ -72,18 +74,20 @@
f.puts "allow *"
end
end
chroot.image.mkdir "#{context_dir}/tmp"
- chroot.sudo "puppet --color=false --modulepath '#{context_dir}/modules' --confdir='#{context_dir}/config' --templatedir='#{context_dir}/templates' --manifestdir='#{context_dir}/manifests' --vardir=#{context_dir}/tmp '#{context_dir}/manifests/site.pp' | tee #{context_dir}/puppet.log"
+ debian_options = "export DEBIAN_SCRIPT_DEBUG=1;" if ENV['DEBIAN_SCRIPT_DEBUG']
+ chroot.sudo "#{debian_options} puppet --color=false --modulepath '#{context_dir}/modules' --confdir='#{context_dir}/config' --templatedir='#{context_dir}/templates' --manifestdir='#{context_dir}/manifests' --vardir=#{context_dir}/tmp '#{context_dir}/manifests/site.pp' 2>&1 | tee #{context_dir}/puppet.log"
+
process_log_file(chroot.image.expand_path("#{context_dir}/puppet.log"))
end
end
def process_log_file(log_file)
FileUtils.cp log_file, "puppet.log"
- unless File.readlines("puppet.log").grep(/^err:/).empty?
+ unless File.readlines("puppet.log").grep(/^(err:|Could not parse for environment production)/).empty?
raise "Error(s) during puppet configuration, see puppet.log file"
end
end
end