boxgrinder-build 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/CHANGELOG +14 -0
  2. data/README.md +136 -0
  3. data/Rakefile +11 -6
  4. data/bin/boxgrinder-build +199 -0
  5. data/boxgrinder-build.gemspec +26 -14
  6. data/lib/boxgrinder-build/appliance.rb +6 -6
  7. data/lib/boxgrinder-build/helpers/guestfs-helper.rb +5 -3
  8. data/lib/boxgrinder-build/helpers/image-helper.rb +6 -0
  9. data/lib/boxgrinder-build/helpers/plugin-helper.rb +15 -4
  10. data/lib/boxgrinder-build/plugins/base-plugin.rb +1 -0
  11. data/lib/boxgrinder-build/plugins/delivery/ebs/ebs-plugin.rb +280 -0
  12. data/lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb +66 -0
  13. data/lib/boxgrinder-build/plugins/delivery/s3/s3-plugin.rb +242 -0
  14. data/lib/boxgrinder-build/plugins/delivery/s3/src/cert-ec2.pem +23 -0
  15. data/lib/boxgrinder-build/plugins/delivery/sftp/sftp-plugin.rb +152 -0
  16. data/lib/boxgrinder-build/plugins/delivery/usb/usb-plugin.rb +43 -0
  17. data/lib/boxgrinder-build/plugins/os/centos/centos-plugin.rb +46 -0
  18. data/lib/boxgrinder-build/plugins/os/fedora/fedora-plugin.rb +61 -0
  19. data/lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb +67 -0
  20. data/lib/boxgrinder-build/plugins/os/rpm-based/kickstart.rb +118 -0
  21. data/lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb +202 -0
  22. data/lib/boxgrinder-build/plugins/os/rpm-based/rpm-dependency-validator.rb +153 -0
  23. data/lib/boxgrinder-build/plugins/os/rpm-based/src/appliance.ks.erb +37 -0
  24. data/lib/boxgrinder-build/plugins/os/rpm-based/src/base.repo +4 -0
  25. data/lib/boxgrinder-build/plugins/os/rpm-based/src/motd.init +21 -0
  26. data/lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb +239 -0
  27. data/lib/boxgrinder-build/plugins/platform/ec2/src/fstab_32bit +7 -0
  28. data/lib/boxgrinder-build/plugins/platform/ec2/src/fstab_64bit +7 -0
  29. data/lib/boxgrinder-build/plugins/platform/ec2/src/ifcfg-eth0 +7 -0
  30. data/lib/boxgrinder-build/plugins/platform/ec2/src/menu.lst +6 -0
  31. data/lib/boxgrinder-build/plugins/platform/ec2/src/rc_local +19 -0
  32. data/lib/boxgrinder-build/plugins/platform/virtualbox/virtualbox-plugin.rb +62 -0
  33. data/lib/boxgrinder-build/plugins/platform/vmware/src/README-enterprise +18 -0
  34. data/lib/boxgrinder-build/plugins/platform/vmware/src/README-personal +16 -0
  35. data/lib/boxgrinder-build/plugins/platform/vmware/src/base.vmdk +20 -0
  36. data/lib/boxgrinder-build/plugins/platform/vmware/src/base.vmx +45 -0
  37. data/lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb +194 -0
  38. data/rubygem-boxgrinder-build.spec +73 -10
  39. data/spec/appliance-spec.rb +2 -2
  40. data/spec/helpers/guestfs-helper-spec.rb +4 -2
  41. data/spec/helpers/image-helper-spec.rb +4 -0
  42. data/spec/helpers/plugin-helper-spec.rb +0 -38
  43. data/spec/managers/plugin-manager-spec.rb +6 -6
  44. data/spec/plugins/delivery/ebs/ebs-plugin-spec.rb +230 -0
  45. data/spec/plugins/delivery/ebs/ebs.yaml +3 -0
  46. data/spec/plugins/delivery/local/local-plugin-spec.rb +133 -0
  47. data/spec/plugins/delivery/s3/s3-plugin-spec.rb +351 -0
  48. data/spec/plugins/delivery/sftp/sftp-plugin-spec.rb +26 -0
  49. data/spec/plugins/os/centos/centos-plugin-spec.rb +52 -0
  50. data/spec/plugins/os/fedora/fedora-plugin-spec.rb +73 -0
  51. data/spec/plugins/os/rhel/rhel-plugin-spec.rb +158 -0
  52. data/spec/plugins/os/rpm-based/kickstart-spec.rb +129 -0
  53. data/spec/plugins/os/rpm-based/rpm-based-os-plugin-spec.rb +162 -0
  54. data/spec/plugins/os/rpm-based/rpm-dependency-validator-spec.rb +50 -0
  55. data/spec/plugins/os/rpm-based/src/jeos-f13-plain.ks +20 -0
  56. data/spec/plugins/os/rpm-based/src/jeos-f13-without-version.ks +22 -0
  57. data/spec/plugins/os/rpm-based/src/jeos-f13.ks +23 -0
  58. data/spec/plugins/platform/ec2/ec2-plugin-spec.rb +339 -0
  59. data/spec/plugins/platform/virtualbox/virtualbox-plugin-spec.rb +118 -0
  60. data/spec/plugins/platform/vmware/vmware-plugin-spec.rb +299 -0
  61. metadata +149 -25
  62. data/README +0 -7
  63. data/bin/boxgrinder +0 -128
  64. data/lib/boxgrinder-build/helpers/thor-helper.rb +0 -85
data/CHANGELOG CHANGED
@@ -1,3 +1,17 @@
1
+ v0.9.0
2
+
3
+ * [BGBUILD-174] Move plugins to boxgrinder-build gem
4
+ * [BGBUILD-169] S3 plugin temporary work-around for EL5
5
+ * [BGBUILD-103] README to indicate supported operating systems / requirements
6
+ * [BGBUILD-175] Rewrite boxgrinder CLI to remove thor dependency
7
+ * [BGBUILD-81] post command execution w/ setarch breaks commands which are scripts
8
+ * [BGBUILD-173] Include setarch package in default package list for RPM-based OSes
9
+ * [BGBUILD-177] Fedora 13 builds have enabled firewall although they shouldn't have it
10
+ * [BGBUILD-178] Remove sensitive data from logs
11
+ * [BGBUILD-179] Boolean and numeric parameters in hash-like values are not recognized
12
+ * [BGBUILD-176] Fail the build with appropriate message if any of post section commands fails to execute
13
+ * [BGBUILD-183] Add support for Fedora 15
14
+
1
15
  v0.8.1
2
16
 
3
17
  * [BGBUILD-141] Long delay after "Preparing guestfs" message when creating new image
data/README.md ADDED
@@ -0,0 +1,136 @@
1
+ # BoxGrinder
2
+
3
+ BoxGrinder is a set of projects that help you grind out appliances for multiple virtualization and Cloud providers.
4
+
5
+ Visit us at [boxgrinder.org](http://www.boxgrinder.org)
6
+
7
+ ## BoxGrinder Build
8
+
9
+ BoxGrinder Build is a command line tool to help you build appliances. With an appliance definition and just a single command, BoxGrinder can create your appliance, target it to a platform and deliver it.
10
+
11
+ ### Boxgrinder Build Meta Appliance: Boxgrinder the Easy Way
12
+
13
+ The Boxgrinder Meta appliance is pre-configured with an optimal environment prepared to use Boxgrinder right from launch. Just [download the latest appliance](http://boxgrinder.org/download/boxgrinder-build-meta-appliance/) from boxgrinder.org in your desired format, launch it, and you're ready to grind out images!
14
+
15
+ It is a great way to use or test BoxGrinder in a virtual environment without affecting your local system.
16
+
17
+ Visit the [Boxgrinder Meta appliance usage article](http://boxgrinder.org/tutorials/boxgrinder-build-meta-appliance/) to learn more.
18
+
19
+ ### Supported OSes
20
+
21
+ At present the project officially supports the following OSes in x86_64 and i386 variants:
22
+
23
+ * Fedora (13, 14)
24
+ * RHEL (5.x, 6.x) and CentOS (5.x)
25
+
26
+ ### Requirements
27
+
28
+ * Acquiring and installing BoxGrinder is very simple, with RPMs ensuring the correct dependencies are pulled and installed. However, depending upon your OS of choice, the prerequisites for installing BoxGrinder vary slightly.
29
+ * Administrative level permissions (root or equivalent)
30
+
31
+ #### Fedora
32
+
33
+ BoxGrinder and all of its dependencies reside within the official Fedora repositories, therefore there are no special requirements. Simply install via your package manager.
34
+
35
+ #### RHEL/CentOS
36
+
37
+ EPEL and BoxGrinder repositories locations must be added to your package manager in order to install BoxGrinder and resolve its dependencies successfully.
38
+
39
+ For detailed instructions, see: [Preparing your environment](http://boxgrinder.org/tutorials/boxgrinder-build-quick-start/preparing-environment/)
40
+
41
+ ### Installing
42
+
43
+ Once the prerequisites are satisfied, install BoxGrinder via a package manager, for instance in YUM;
44
+
45
+ * `sudo yum install "rubygem-boxgrinder*"` to install BoxGrinder Core, BoxGrinder Build and all standard plugins.
46
+
47
+ You may only wish to install a subset of the available plugins, see the [BoxGrinder plugins list](http://boxgrinder.org/tutorials/#Plugin_list) to find out which are available. You can, of course, [write your own](http://boxgrinder.org/tutorials/how-to-write-a-plugin-for-boxgrinder-build/) plugins!
48
+
49
+ ### Removing
50
+
51
+ You should remove BoxGrinder through your system package manager, for instance with YUM:
52
+
53
+ * `sudo yum remove "rubygem-boxgrinder*"`
54
+
55
+ ### Usage
56
+
57
+ BoxGrinder.org's [quick-start](http://boxgrinder.org/tutorials/boxgrinder-build-quick-start/) tutorial is the best place to learn the fundamentals of BoxGrinder Build, enabling you to rapidly leverage the feature-set on offer.
58
+
59
+ The following sections provide a basic overview of functionality.
60
+
61
+ ### Plugins
62
+
63
+ Most of the features of BoxGrinder Build are provided through plugins, with three primary variants (Operating System, Platform and Delivery), each catering for a phase of the build process. Furthermore, the flexible and extensible structure of BoxGrinder Build enables users to seamlessly add new features and functionality.
64
+
65
+ * Operating System - provide support to run and build for a given OS
66
+ * Platform - ability to produce appliances for a specific platform, such as Amazon's EC2 or VirtualBox VM
67
+ * Delivery - send the completed appliance, for instance by SFTP or bundled as an AMI and uploaded to S3.
68
+
69
+ Learn more: [BoxGrinder Build](http://boxgrinder.org/build/)
70
+
71
+ #### Plugin Configuration
72
+
73
+ Many plugins allow, or mandate, some degree of configuration before they are executed. These properties are aggregated into a single per-user configuration file, at `~/.boxgrinder/config`. The user should consult the documentation of a given plugin to determine what fields it should be configured with, and which fields (if any), are requisite.
74
+
75
+ plugins:
76
+ sftp:
77
+ host: 192.168.0.1
78
+ username: boxgrinder
79
+ path: /home/boxgrinder/appliances
80
+
81
+ * In this example, the SFTP plugin's fields are [all mandatory](http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#SFTP_Delivery_Plugin).
82
+
83
+ Learn more: [BoxGrinder Plugins](http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#Plugin_configuration)
84
+
85
+ #### Defining Appliances
86
+
87
+ Appliances are defined in YAML, the following "JEOS" definition can be used by BoxGrinder to produce a basic, but fully functional appliance;
88
+
89
+ name: f14-basic
90
+ summary: Just Enough Operating System based on Fedora 14
91
+ os:
92
+ name: fedora
93
+ version: 14
94
+ hardware:
95
+ partitions:
96
+ "/":
97
+ size: 2
98
+ packages:
99
+ - @core
100
+
101
+ * With this simple definition, BoxGrinder will produce a Fedora 14 appliance with the Core [group of packages](http://yum.baseurl.org/wiki/YumGroups). You can easily add packages, repositories, and harness a plethora of powerful features in a concise, declarative manner.
102
+ * For an introduction to Appliance Definitions, see: [Quick-start, building your first appliance](http://boxgrinder.org/tutorials/boxgrinder-build-quick-start/build-your-first-appliance)
103
+ * For fuller explanations of all parameters BoxGrinder offers, see: [Appliance definition parameters](http://boxgrinder.org/tutorials/appliance-definition/)
104
+
105
+ #### Building Appliances
106
+ The BoxGrinder Build CLI is a simple interface through which you can instruct BoxGrinder to build your appliances. You can view a brief manual on each task by utilising the help function:
107
+
108
+ boxgrinder help [TASK]
109
+
110
+ BoxGrinder's primary task is `build`, and is run with a mandatory appliance definition, along with optional platform and delivery plugin specifiers. BoxGrinder resolves the packages and associated dependencies in the appliance definition, and installs them into the new image it generates based upon the operating system and versions specified.
111
+
112
+ boxgrinder build [appliance definition file] [options]
113
+
114
+ * The two most common options are `[-p|--platform=]` and `[-d|--delivery=]`. Neither is mandatory, if platform is omitted then only the raw KVM image is created. You can can later return and target a build to different platforms, and BoxGrinder will always reuse the intermediary data where it is available. If you wish to force a rebuild, you can use the `[-f|--force]` flag.
115
+ * It is possible to manually provide key-value pairs for platform and delivery plugin configuration on the command line. These will override any pre-existing plugin parameters set in the BoxGrinder config file.
116
+ * Shell commands can be executed in `post` sections of the appliance definition files, which is useful for basic configuration. However, it is advisable that more complex configuration and installation of custom software is performed properly through RPM files. This is often best achieved through local repositories, which can be configured as [_ephemeral_](http://boxgrinder.org/tutorials/appliance-definition/) in order to avoid the repository being installed into the resultant image's package manager.
117
+
118
+ See: [BoxGrinder Build Usage Instructions](http://boxgrinder.org/tutorials/boxgrinder-build-usage-instructions/), [How to use local repositories](http://boxgrinder.org/tutorials/how-to-use-local-repository), and `boxgrinder help build`
119
+
120
+ ##### Examples
121
+
122
+ boxgrinder build fedora-14.appl -p vmware -d sftp
123
+
124
+ Build an image based upon _fedora-14.appl_, and produce an image targeted at the _vmware_ platform. Once complete, deliver by _sftp_. Note that each of these plugins must be configured in `~/.boxgrinder/conf` or by providing the key-value pairs as command-line arguments.
125
+
126
+ -----------------------
127
+
128
+ boxgrinder build fedora-14.appl -p virtualbox -d local
129
+
130
+ Assuming that BoxGrinder had succeeded in building the prior image, the RAW file is again used as an intermediary without needing to be rebuild. An image targeted at VirtualBox is then produced, and delivered to a local file, as determined in _conf_.
131
+
132
+ -----------------------
133
+
134
+ setarch i386 boxgrinder build fedora-14.appl
135
+
136
+ Build an i386 appliance (on an x86_64 machine).
data/Rakefile CHANGED
@@ -21,12 +21,17 @@ require 'spec/rake/spectask'
21
21
  require 'echoe'
22
22
 
23
23
  Echoe.new("boxgrinder-build") do |p|
24
- p.project = "BoxGrinder Build"
25
- p.author = "Marek Goldmann"
26
- p.summary = "A tool for creating appliances from simple plain text files for various virtual environments."
27
- p.url = "http://www.jboss.org/boxgrinder"
28
- p.email = "info@boxgrinder.org"
29
- p.runtime_dependencies = ["thor >=0.13", "boxgrinder-core ~>0.2.1"]
24
+ p.project = "BoxGrinder Build"
25
+ p.author = "Marek Goldmann"
26
+ p.summary = "A tool for creating appliances from simple plain text files for various virtual environments."
27
+ p.url = "http://boxgrinder.org/"
28
+ p.email = "info@boxgrinder.org"
29
+ p.runtime_dependencies = [
30
+ "boxgrinder-core ~>0.3.0",
31
+ 'aws', # S3
32
+ 'amazon-ec2', # EBS and S3
33
+ 'net-sftp', 'net-ssh', 'progressbar', # SFTP
34
+ ]
30
35
  end
31
36
 
32
37
  desc "Run all tests"
@@ -0,0 +1,199 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Copyright 2010 Red Hat, Inc.
4
+ #
5
+ # This is free software; you can redistribute it and/or modify it
6
+ # under the terms of the GNU Lesser General Public License as
7
+ # published by the Free Software Foundation; either version 3 of
8
+ # the License, or (at your option) any later version.
9
+ #
10
+ # This software is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this software; if not, write to the Free
17
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19
+
20
+ require 'optparse'
21
+ require 'rubygems'
22
+ require 'hashery/opencascade'
23
+ require 'boxgrinder-core/models/config'
24
+ require 'boxgrinder-core/helpers/log-helper'
25
+ require 'boxgrinder-build/appliance'
26
+
27
+ if Process.uid != 0
28
+ puts "This program must be executed with root privileges. Try 'sudo #{File.basename($0)}'."
29
+ abort
30
+ end
31
+
32
+ options = OpenCascade.new(
33
+ :platform => :none,
34
+ :delivery => :none,
35
+ :force => false,
36
+ :os_config => {},
37
+ :platform_config => {},
38
+ :delivery_config => {},
39
+ :additional_plugins => [],
40
+ :debug => false,
41
+ :trace => false,
42
+ :backtrace => false,
43
+ :log_level => :info
44
+ )
45
+
46
+ def validate_hash_option(options, name, value)
47
+ value.each do |entry|
48
+ if entry =~ /^(\S+):(\S+)$/
49
+
50
+ k = $1.strip
51
+ v = $2.strip
52
+
53
+ if v =~ /^([-+]?(0|[1-9][0-9_]*))$/
54
+ v = v.to_i
55
+ elsif v =~ /^(y|Y|yes|Yes|YES|true|True|TRUE|on|On|ON)$/
56
+ v = true
57
+ elsif v =~ /^(n|N|no|No|NO|false|False|FALSE|off|Off|OFF)$/
58
+ v = false
59
+ elsif v =~ /^([-+]?([0-9][0-9_]*)?\.[0-9.]*([eE][-+][0-9]+)?)$/
60
+ v = v.to_f
61
+ end
62
+
63
+ options[name][k] = v
64
+ else
65
+ yield entry if block_given?
66
+ abort
67
+ end
68
+ end
69
+ end
70
+
71
+ def process_options(options)
72
+ OptionParser.new do |opts|
73
+ program = File.basename($0)
74
+
75
+ opts.banner = <<EOB
76
+ Usage: #{program} [appliance definition file] [options]
77
+
78
+ A tool for building VM images from simple definition files.
79
+
80
+ Homepage:
81
+ http://boxgrinder.org/
82
+
83
+ Documentation:
84
+ http://boxgrinder.org/tutorials/
85
+
86
+ Examples:
87
+ $ #{program} jeos.appl # Build KVM image for jeos.appl
88
+ $ #{program} jeos.appl -f # Build KVM image for jeos.appl with removing previous build for this image
89
+ $ #{program} jeos.appl --os-config format:qcow2 # Build KVM image for jeos.appl with a qcow2 disk
90
+ $ #{program} jeos.appl -p vmware --platform-config type:personal,thin_disk:true # Build VMware image for VMware Server, Player, Fusion using thin (growing) disk
91
+ $ #{program} jeos.appl -p ec2 -d ami # Build and register AMI for jeos.appl
92
+ $ #{program} jeos.appl -p vmware -d local # Build VMware image for jeos.appl and deliver it to local directory
93
+ EOB
94
+
95
+
96
+ opts.separator ""
97
+ opts.separator "Options:"
98
+
99
+ opts.on("-p", "--platform [TYPE]", "The name of platform you want to convert to.") { |v| options.platform = v.to_sym }
100
+ opts.on("-d", "--delivery [METHOD]", "The delivery method for selected appliance.") { |v| options.delivery = v.to_sym }
101
+ opts.on("-f", "--force", "Force image creation - removes all previous builds for selected appliance. Default: false.") { |v| options.force = v }
102
+
103
+ opts.separator ""
104
+ opts.separator "Plugin configuration options:"
105
+
106
+ opts.on("-l", "--plugins [PLUGINS]", Array, "Comma separated list of additional plugins. Default: empty.") do |v|
107
+ options[:additional_plugins] = v
108
+ end
109
+
110
+ opts.separator ""
111
+
112
+ opts.on("--os-config [CONFIG]", Array, "Operating system plugin configuration in format: key1:value1,key2:value2.") do |v|
113
+ validate_hash_option(options, :os_config, v) do |entry|
114
+ puts "Operating system plugin configuration is not valid at '#{entry}'. Valid format is: 'key:value'."
115
+ end
116
+ end
117
+
118
+ opts.on("--platform-config [CONFIG]", Array, "Platform plugin configuration in format: key1:value1,key2:value2.") do |v|
119
+ validate_hash_option(options, :platform_config, v) do |entry|
120
+ puts "Platform plugin configuration is not valid at '#{entry}'. Valid format is: 'key:value'."
121
+ end
122
+ end
123
+
124
+ opts.on("--delivery-config [CONFIG]", Array, "Delivery plugin configuration in format: key1:value1,key2:value2.") do |v|
125
+ validate_hash_option(options, :delivery_config, v) do |entry|
126
+ puts "Delivery plugin configuration is not valid at '#{entry}'. Valid format is: 'key:value'."
127
+ end
128
+ end
129
+
130
+ opts.separator ""
131
+ opts.separator "Logging options:"
132
+
133
+ opts.on("--debug", "Prints debug information while building. Default: false.") { |v| options[:debug] = v }
134
+ opts.on("--trace", "Prints trace information while building. Default: false.") { |v| options[:trace] = v }
135
+ opts.on("-b", "--backtrace", "Prints full backtrace if errors occur whilst building. Default: true if console log is set to debug or trace, otherwise false.") { |v| options[:backtrace] = v }
136
+
137
+ opts.separator ""
138
+ opts.separator 'Common options:'
139
+
140
+ opts.on_tail('--help', 'Show this message.') do
141
+ puts opts
142
+ exit
143
+ end
144
+ opts.on_tail('--version', 'Print the version.') do
145
+ puts "BoxGrinder Build #{File.read("#{File.dirname(__FILE__)}/../CHANGELOG").match(/^v(.*)/)[1]}"
146
+
147
+ [:os, :platform, :delivery].each do |type|
148
+ puts
149
+ puts "Available #{type} plugins:"
150
+ BoxGrinder::PluginManager.instance.plugins[type].each do |name, plugin_info|
151
+ puts " - #{name} plugin for #{plugin_info[:full_name]}"
152
+ end
153
+ end
154
+
155
+ exit
156
+ end
157
+ end
158
+ end
159
+
160
+ opts = process_options(options)
161
+
162
+ begin
163
+ opts.parse!
164
+ if ARGV.empty? or ARGV.size > 1
165
+ puts opts
166
+ puts
167
+ puts 'No or more than one appliance definition file specified.'
168
+ abort
169
+ end
170
+
171
+ appliance_definition_file = ARGV.first
172
+
173
+ unless File.exists?(appliance_definition_file)
174
+ puts "Appliance definition file '#{appliance_definition_file}' could not be found."
175
+ abort
176
+ end
177
+
178
+ options.log_level = :debug if options.debug
179
+ options.log_level = :trace if options.trace
180
+ options.backtrace = :true if [:debug, :trace].include?(options.log_level)
181
+
182
+ log = BoxGrinder::LogHelper.new(:level => options.log_level)
183
+
184
+ begin
185
+ BoxGrinder::Appliance.new(appliance_definition_file, BoxGrinder::Config.new(options), :log => log).create
186
+ rescue Exception => e
187
+ if options.backtrace
188
+ log.fatal e
189
+ else # demote backtrace to debug so that it is in file log only
190
+ log.fatal "#{e.message}. See the log file for detailed information."
191
+ log.debug e.backtrace.join($/)
192
+ end
193
+ end
194
+ rescue => e
195
+ puts opts
196
+ puts
197
+ puts e.message
198
+ abort
199
+ end
@@ -2,19 +2,19 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{boxgrinder-build}
5
- s.version = "0.8.1"
5
+ s.version = "0.9.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Marek Goldmann"]
9
- s.date = %q{2011-02-22}
10
- s.default_executable = %q{boxgrinder}
9
+ s.date = %q{2011-03-09}
10
+ s.default_executable = %q{boxgrinder-build}
11
11
  s.description = %q{A tool for creating appliances from simple plain text files for various virtual environments.}
12
12
  s.email = %q{info@boxgrinder.org}
13
- s.executables = ["boxgrinder"]
14
- s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "bin/boxgrinder", "lib/boxgrinder-build.rb", "lib/boxgrinder-build/appliance.rb", "lib/boxgrinder-build/helpers/appliance-customize-helper.rb", "lib/boxgrinder-build/helpers/augeas-helper.rb", "lib/boxgrinder-build/helpers/guestfs-helper.rb", "lib/boxgrinder-build/helpers/image-helper.rb", "lib/boxgrinder-build/helpers/linux-helper.rb", "lib/boxgrinder-build/helpers/package-helper.rb", "lib/boxgrinder-build/helpers/plugin-helper.rb", "lib/boxgrinder-build/helpers/thor-helper.rb", "lib/boxgrinder-build/managers/plugin-manager.rb", "lib/boxgrinder-build/plugins/base-plugin.rb"]
15
- s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "bin/boxgrinder", "boxgrinder-build.gemspec", "lib/boxgrinder-build.rb", "lib/boxgrinder-build/appliance.rb", "lib/boxgrinder-build/helpers/appliance-customize-helper.rb", "lib/boxgrinder-build/helpers/augeas-helper.rb", "lib/boxgrinder-build/helpers/guestfs-helper.rb", "lib/boxgrinder-build/helpers/image-helper.rb", "lib/boxgrinder-build/helpers/linux-helper.rb", "lib/boxgrinder-build/helpers/package-helper.rb", "lib/boxgrinder-build/helpers/plugin-helper.rb", "lib/boxgrinder-build/helpers/thor-helper.rb", "lib/boxgrinder-build/managers/plugin-manager.rb", "lib/boxgrinder-build/plugins/base-plugin.rb", "rubygem-boxgrinder-build.spec", "spec/Rakefile", "spec/appliance-spec.rb", "spec/helpers/appliance-customize-helper-spec.rb", "spec/helpers/augeas-helper-spec.rb", "spec/helpers/guestfs-helper-spec.rb", "spec/helpers/image-helper-spec.rb", "spec/helpers/linux-helper-spec.rb", "spec/helpers/package-helper-spec.rb", "spec/helpers/plugin-helper-spec.rb", "spec/managers/plugin-manager-spec.rb", "spec/plugins/base-plugin-spec.rb"]
16
- s.homepage = %q{http://www.jboss.org/boxgrinder}
17
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Boxgrinder-build", "--main", "README"]
13
+ s.executables = ["boxgrinder-build"]
14
+ s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.md", "bin/boxgrinder-build", "lib/boxgrinder-build.rb", "lib/boxgrinder-build/appliance.rb", "lib/boxgrinder-build/helpers/appliance-customize-helper.rb", "lib/boxgrinder-build/helpers/augeas-helper.rb", "lib/boxgrinder-build/helpers/guestfs-helper.rb", "lib/boxgrinder-build/helpers/image-helper.rb", "lib/boxgrinder-build/helpers/linux-helper.rb", "lib/boxgrinder-build/helpers/package-helper.rb", "lib/boxgrinder-build/helpers/plugin-helper.rb", "lib/boxgrinder-build/managers/plugin-manager.rb", "lib/boxgrinder-build/plugins/base-plugin.rb", "lib/boxgrinder-build/plugins/delivery/ebs/ebs-plugin.rb", "lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb", "lib/boxgrinder-build/plugins/delivery/s3/s3-plugin.rb", "lib/boxgrinder-build/plugins/delivery/s3/src/cert-ec2.pem", "lib/boxgrinder-build/plugins/delivery/sftp/sftp-plugin.rb", "lib/boxgrinder-build/plugins/delivery/usb/usb-plugin.rb", "lib/boxgrinder-build/plugins/os/centos/centos-plugin.rb", "lib/boxgrinder-build/plugins/os/fedora/fedora-plugin.rb", "lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb", "lib/boxgrinder-build/plugins/os/rpm-based/kickstart.rb", "lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb", "lib/boxgrinder-build/plugins/os/rpm-based/rpm-dependency-validator.rb", "lib/boxgrinder-build/plugins/os/rpm-based/src/appliance.ks.erb", "lib/boxgrinder-build/plugins/os/rpm-based/src/base.repo", "lib/boxgrinder-build/plugins/os/rpm-based/src/motd.init", "lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb", "lib/boxgrinder-build/plugins/platform/ec2/src/fstab_32bit", "lib/boxgrinder-build/plugins/platform/ec2/src/fstab_64bit", "lib/boxgrinder-build/plugins/platform/ec2/src/ifcfg-eth0", "lib/boxgrinder-build/plugins/platform/ec2/src/menu.lst", "lib/boxgrinder-build/plugins/platform/ec2/src/rc_local", "lib/boxgrinder-build/plugins/platform/virtualbox/virtualbox-plugin.rb", "lib/boxgrinder-build/plugins/platform/vmware/src/README-enterprise", "lib/boxgrinder-build/plugins/platform/vmware/src/README-personal", "lib/boxgrinder-build/plugins/platform/vmware/src/base.vmdk", "lib/boxgrinder-build/plugins/platform/vmware/src/base.vmx", "lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb"]
15
+ s.files = ["CHANGELOG", "LICENSE", "Manifest", "README.md", "Rakefile", "bin/boxgrinder-build", "boxgrinder-build.gemspec", "lib/boxgrinder-build.rb", "lib/boxgrinder-build/appliance.rb", "lib/boxgrinder-build/helpers/appliance-customize-helper.rb", "lib/boxgrinder-build/helpers/augeas-helper.rb", "lib/boxgrinder-build/helpers/guestfs-helper.rb", "lib/boxgrinder-build/helpers/image-helper.rb", "lib/boxgrinder-build/helpers/linux-helper.rb", "lib/boxgrinder-build/helpers/package-helper.rb", "lib/boxgrinder-build/helpers/plugin-helper.rb", "lib/boxgrinder-build/managers/plugin-manager.rb", "lib/boxgrinder-build/plugins/base-plugin.rb", "lib/boxgrinder-build/plugins/delivery/ebs/ebs-plugin.rb", "lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb", "lib/boxgrinder-build/plugins/delivery/s3/s3-plugin.rb", "lib/boxgrinder-build/plugins/delivery/s3/src/cert-ec2.pem", "lib/boxgrinder-build/plugins/delivery/sftp/sftp-plugin.rb", "lib/boxgrinder-build/plugins/delivery/usb/usb-plugin.rb", "lib/boxgrinder-build/plugins/os/centos/centos-plugin.rb", "lib/boxgrinder-build/plugins/os/fedora/fedora-plugin.rb", "lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb", "lib/boxgrinder-build/plugins/os/rpm-based/kickstart.rb", "lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb", "lib/boxgrinder-build/plugins/os/rpm-based/rpm-dependency-validator.rb", "lib/boxgrinder-build/plugins/os/rpm-based/src/appliance.ks.erb", "lib/boxgrinder-build/plugins/os/rpm-based/src/base.repo", "lib/boxgrinder-build/plugins/os/rpm-based/src/motd.init", "lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb", "lib/boxgrinder-build/plugins/platform/ec2/src/fstab_32bit", "lib/boxgrinder-build/plugins/platform/ec2/src/fstab_64bit", "lib/boxgrinder-build/plugins/platform/ec2/src/ifcfg-eth0", "lib/boxgrinder-build/plugins/platform/ec2/src/menu.lst", "lib/boxgrinder-build/plugins/platform/ec2/src/rc_local", "lib/boxgrinder-build/plugins/platform/virtualbox/virtualbox-plugin.rb", "lib/boxgrinder-build/plugins/platform/vmware/src/README-enterprise", "lib/boxgrinder-build/plugins/platform/vmware/src/README-personal", "lib/boxgrinder-build/plugins/platform/vmware/src/base.vmdk", "lib/boxgrinder-build/plugins/platform/vmware/src/base.vmx", "lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb", "rubygem-boxgrinder-build.spec", "spec/Rakefile", "spec/appliance-spec.rb", "spec/helpers/appliance-customize-helper-spec.rb", "spec/helpers/augeas-helper-spec.rb", "spec/helpers/guestfs-helper-spec.rb", "spec/helpers/image-helper-spec.rb", "spec/helpers/linux-helper-spec.rb", "spec/helpers/package-helper-spec.rb", "spec/helpers/plugin-helper-spec.rb", "spec/managers/plugin-manager-spec.rb", "spec/plugins/base-plugin-spec.rb", "spec/plugins/delivery/ebs/ebs-plugin-spec.rb", "spec/plugins/delivery/ebs/ebs.yaml", "spec/plugins/delivery/local/local-plugin-spec.rb", "spec/plugins/delivery/s3/s3-plugin-spec.rb", "spec/plugins/delivery/sftp/sftp-plugin-spec.rb", "spec/plugins/os/centos/centos-plugin-spec.rb", "spec/plugins/os/fedora/fedora-plugin-spec.rb", "spec/plugins/os/rhel/rhel-plugin-spec.rb", "spec/plugins/os/rpm-based/kickstart-spec.rb", "spec/plugins/os/rpm-based/rpm-based-os-plugin-spec.rb", "spec/plugins/os/rpm-based/rpm-dependency-validator-spec.rb", "spec/plugins/os/rpm-based/src/jeos-f13-plain.ks", "spec/plugins/os/rpm-based/src/jeos-f13-without-version.ks", "spec/plugins/os/rpm-based/src/jeos-f13.ks", "spec/plugins/platform/ec2/ec2-plugin-spec.rb", "spec/plugins/platform/virtualbox/virtualbox-plugin-spec.rb", "spec/plugins/platform/vmware/vmware-plugin-spec.rb"]
16
+ s.homepage = %q{http://boxgrinder.org/}
17
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Boxgrinder-build", "--main", "README.md"]
18
18
  s.require_paths = ["lib"]
19
19
  s.rubyforge_project = %q{BoxGrinder Build}
20
20
  s.rubygems_version = %q{1.3.7}
@@ -25,14 +25,26 @@ Gem::Specification.new do |s|
25
25
  s.specification_version = 3
26
26
 
27
27
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
28
- s.add_runtime_dependency(%q<thor>, [">= 0.13"])
29
- s.add_runtime_dependency(%q<boxgrinder-core>, ["~> 0.2.1"])
28
+ s.add_runtime_dependency(%q<boxgrinder-core>, ["~> 0.3.0"])
29
+ s.add_runtime_dependency(%q<aws>, [">= 0"])
30
+ s.add_runtime_dependency(%q<amazon-ec2>, [">= 0"])
31
+ s.add_runtime_dependency(%q<net-sftp>, [">= 0"])
32
+ s.add_runtime_dependency(%q<net-ssh>, [">= 0"])
33
+ s.add_runtime_dependency(%q<progressbar>, [">= 0"])
30
34
  else
31
- s.add_dependency(%q<thor>, [">= 0.13"])
32
- s.add_dependency(%q<boxgrinder-core>, ["~> 0.2.1"])
35
+ s.add_dependency(%q<boxgrinder-core>, ["~> 0.3.0"])
36
+ s.add_dependency(%q<aws>, [">= 0"])
37
+ s.add_dependency(%q<amazon-ec2>, [">= 0"])
38
+ s.add_dependency(%q<net-sftp>, [">= 0"])
39
+ s.add_dependency(%q<net-ssh>, [">= 0"])
40
+ s.add_dependency(%q<progressbar>, [">= 0"])
33
41
  end
34
42
  else
35
- s.add_dependency(%q<thor>, [">= 0.13"])
36
- s.add_dependency(%q<boxgrinder-core>, ["~> 0.2.1"])
43
+ s.add_dependency(%q<boxgrinder-core>, ["~> 0.3.0"])
44
+ s.add_dependency(%q<aws>, [">= 0"])
45
+ s.add_dependency(%q<amazon-ec2>, [">= 0"])
46
+ s.add_dependency(%q<net-sftp>, [">= 0"])
47
+ s.add_dependency(%q<net-ssh>, [">= 0"])
48
+ s.add_dependency(%q<progressbar>, [">= 0"])
37
49
  end
38
50
  end
@@ -62,11 +62,11 @@ module BoxGrinder
62
62
  def validate_definition
63
63
  ApplianceConfigValidator.new(@appliance_config).validate
64
64
 
65
- raise "No operating system plugins installed. Install one or more operating system plugin. See http://community.jboss.org/docs/DOC-15081 and http://community.jboss.org/docs/DOC-15214 for more info." if PluginManager.instance.plugins[:os].empty?
65
+ raise "No operating system plugins installed. Install one or more operating system plugin. See http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#Operating_system_plugins for more info." if PluginManager.instance.plugins[:os].empty?
66
66
 
67
67
  os_plugin = PluginManager.instance.plugins[:os][@appliance_config.os.name.to_sym]
68
68
 
69
- raise "Not supported operating system selected: #{@appliance_config.os.name}. Make sure you have installed right operating system plugin, see http://community.jboss.org/docs/DOC-15214. Supported OSes are: #{PluginManager.instance.plugins[:os].keys.join(", ")}" if os_plugin.nil?
69
+ raise "Not supported operating system selected: #{@appliance_config.os.name}. Make sure you have installed right operating system plugin, see http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#Operating_system_plugins. Supported OSes are: #{PluginManager.instance.plugins[:os].keys.join(", ")}" if os_plugin.nil?
70
70
  raise "Not supported operating system version selected: #{@appliance_config.os.version}. Supported versions are: #{os_plugin[:versions].join(", ")}" unless @appliance_config.os.version.nil? or os_plugin[:versions].include?(@appliance_config.os.version)
71
71
  end
72
72
 
@@ -84,7 +84,7 @@ module BoxGrinder
84
84
 
85
85
  def create
86
86
  @log.debug "Launching new BoxGrinder build..."
87
- @log.trace "Used configuration: #{@config.to_yaml}"
87
+ @log.trace "Used configuration: #{@config.to_yaml.gsub(/(\S*(key|account|cert|username|host)\S*).*:(.*)/, '\1' + ": <REDACTED>")}"
88
88
 
89
89
  PluginHelper.new(@config, :log => @log).load_plugins
90
90
  read_definition
@@ -94,7 +94,7 @@ module BoxGrinder
94
94
  end
95
95
 
96
96
  def execute_os_plugin
97
- raise "No operating system plugins installed. Install one or more operating system plugin. See http://community.jboss.org/docs/DOC-15081 and http://community.jboss.org/docs/DOC-15214 for more info." if PluginManager.instance.plugins[:os].empty?
97
+ raise "No operating system plugins installed. Install one or more operating system plugin. See http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#Operating_system_plugins for more info." if PluginManager.instance.plugins[:os].empty?
98
98
 
99
99
  os_plugin, os_plugin_info = PluginManager.instance.initialize_plugin(:os, @appliance_config.os.name.to_sym)
100
100
  os_plugin.init(@config, @appliance_config, :log => @log, :plugin_info => os_plugin_info)
@@ -117,7 +117,7 @@ module BoxGrinder
117
117
  return previous_plugin_output
118
118
  end
119
119
 
120
- raise "No platform plugins installed. Install one or more platform plugin. See http://community.jboss.org/docs/DOC-15081 and http://community.jboss.org/docs/DOC-15214 for more info." if PluginManager.instance.plugins[:platform].empty?
120
+ raise "No platform plugins installed. Install one or more platform plugin. See http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#Platform_plugins for more info." if PluginManager.instance.plugins[:platform].empty?
121
121
 
122
122
  platform_plugin, platform_plugin_info = PluginManager.instance.initialize_plugin(:platform, @config.platform)
123
123
  platform_plugin.init(@config, @appliance_config, :log => @log, :plugin_info => platform_plugin_info, :previous_plugin_info => previous_plugin_output[:plugin_info], :previous_deliverables => previous_plugin_output[:deliverables])
@@ -140,7 +140,7 @@ module BoxGrinder
140
140
  return
141
141
  end
142
142
 
143
- raise "No delivery plugins installed. Install one or more delivery plugin. See http://community.jboss.org/docs/DOC-15081 and http://community.jboss.org/docs/DOC-15214 for more info" if PluginManager.instance.plugins[:delivery].empty?
143
+ raise "No delivery plugins installed. Install one or more delivery plugin. See http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#Delivery_plugins for more info" if PluginManager.instance.plugins[:delivery].empty?
144
144
 
145
145
  delivery_plugin, delivery_plugin_info = PluginManager.instance.initialize_plugin(:delivery, @config.delivery)
146
146
  delivery_plugin.init(@config, @appliance_config, :log => @log, :plugin_info => delivery_plugin_info, :previous_plugin_info => previous_plugin_output[:plugin_info], :previous_deliverables => previous_plugin_output[:deliverables])
@@ -66,7 +66,8 @@ module Guestfs
66
66
  output = sh_original(command)
67
67
  puts output
68
68
  rescue => e
69
- puts "Error occurred while executing above command. Appliance may not work properly."
69
+ puts "Error occurred while executing above command, aborting."
70
+ raise e
70
71
  end
71
72
 
72
73
  output
@@ -250,8 +251,9 @@ module BoxGrinder
250
251
  def sh(cmd, options = {})
251
252
  arch = options[:arch] || `uname -m`.chomp.strip
252
253
 
253
- @log.debug "Executing #{cmd}"
254
- @guestfs.sh("setarch #{arch} << SETARCH_EOF\n#{cmd.gsub('$', '\$')}\nSETARCH_EOF\n")
254
+ @log.debug "Executing '#{cmd}' command..."
255
+ @guestfs.sh("setarch #{arch} << 'SETARCH_EOF'\n#{cmd}\nSETARCH_EOF")
256
+ @log.debug "Command '#{cmd}' executed."
255
257
  end
256
258
 
257
259
  def augeas(&block)
@@ -52,6 +52,9 @@ module BoxGrinder
52
52
  @exec_helper.execute("mount #{loop_device} '#{mount_dir}#{mount_point}'")
53
53
  end
54
54
 
55
+ # Give some time to mount the images
56
+ sleep 2
57
+
55
58
  @log.trace "Mounts:\n#{mounts}"
56
59
 
57
60
  mounts
@@ -64,6 +67,9 @@ module BoxGrinder
64
67
 
65
68
  @exec_helper.execute("umount -d #{mounts['/']}")
66
69
 
70
+ # Give some time to umount the image
71
+ sleep 2
72
+
67
73
  FileUtils.rm_rf(mount_dir)
68
74
  end
69
75
 
@@ -20,6 +20,19 @@ require 'rubygems'
20
20
  require 'boxgrinder-build/managers/plugin-manager'
21
21
  require 'boxgrinder-core/helpers/log-helper'
22
22
 
23
+ require 'boxgrinder-build/plugins/delivery/s3/s3-plugin'
24
+ require 'boxgrinder-build/plugins/delivery/sftp/sftp-plugin'
25
+ require 'boxgrinder-build/plugins/delivery/ebs/ebs-plugin'
26
+ require 'boxgrinder-build/plugins/delivery/local/local-plugin'
27
+
28
+ require 'boxgrinder-build/plugins/platform/vmware/vmware-plugin'
29
+ require 'boxgrinder-build/plugins/platform/ec2/ec2-plugin'
30
+ require 'boxgrinder-build/plugins/platform/virtualbox/virtualbox-plugin'
31
+
32
+ require 'boxgrinder-build/plugins/os/centos/centos-plugin'
33
+ require 'boxgrinder-build/plugins/os/rhel/rhel-plugin'
34
+ require 'boxgrinder-build/plugins/os/fedora/fedora-plugin'
35
+
23
36
  module BoxGrinder
24
37
  class PluginHelper
25
38
  def initialize( config, options = {} )
@@ -42,9 +55,7 @@ module BoxGrinder
42
55
  end
43
56
 
44
57
  def read_and_require
45
- plugins = %w(boxgrinder-build-fedora-os-plugin boxgrinder-build-rhel-os-plugin boxgrinder-build-centos-os-plugin boxgrinder-build-ec2-platform-plugin boxgrinder-build-vmware-platform-plugin boxgrinder-build-virtualbox-platform-plugin boxgrinder-build-s3-delivery-plugin boxgrinder-build-sftp-delivery-plugin boxgrinder-build-local-delivery-plugin boxgrinder-build-ebs-delivery-plugin) + @options.additional_plugins
46
-
47
- plugins.flatten.each do |plugin|
58
+ @options.additional_plugins.each do |plugin|
48
59
  @log.trace "Loading plugin '#{plugin}'..."
49
60
 
50
61
  begin
@@ -52,7 +63,7 @@ module BoxGrinder
52
63
  @log.trace "- OK"
53
64
  rescue LoadError => e
54
65
  @log.trace "- Not found: #{e.message.strip.chomp}"
55
- @log.warn "Specified plugin: '#{plugin}' wasn't found. Make sure its name is correct, skipping..." unless plugin.match(/^boxgrinder-build-(.*)-plugin/)
66
+ @log.warn "Specified plugin: '#{plugin}' wasn't found. Make sure its name is correct, skipping..."
56
67
  end
57
68
  end
58
69
  end
@@ -20,6 +20,7 @@ require 'rubygems'
20
20
  require 'boxgrinder-core/helpers/exec-helper'
21
21
  require 'boxgrinder-core/helpers/log-helper'
22
22
  require 'boxgrinder-build/helpers/image-helper'
23
+ require 'boxgrinder-build/managers/plugin-manager'
23
24
  require 'ostruct'
24
25
  require 'hashery/opencascade'
25
26
  require 'fileutils'