racker 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ ## 0.2.0 (2016-03-01)
2
+
3
+ * Added support for output to STDOUT. The filename of '-' is used to signify outout should go to STDOUT. (PR#7) This feature will become the default functionality in the 0.3.0 release.
4
+ * Fixed issue where the `parallels` builder was not properly required.
5
+
1
6
  ## 0.1.6 (2014-09-16)
2
7
 
3
8
  * Fixed `uninitialized constant Racker::Builders::Null` bug.
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # Racker
2
+ [![Gem Version](https://badge.fury.io/rb/racker.svg)](http://badge.fury.io/rb/racker)
3
+ [![Build Status](https://travis-ci.org/aspring/racker.svg?branch=master)](https://travis-ci.org/aspring/racker)
2
4
 
3
5
  * Website: http://github.com/aspring/racker
4
6
 
@@ -15,24 +17,24 @@ Racker is able to take multiple Racker templates, merge them together, and gener
15
17
  ## Installation
16
18
 
17
19
  $ gem install racker
18
-
20
+
19
21
  ## Usage
20
22
  To generate a Packer template from a Racker template, run:
21
-
23
+
22
24
  $ racker rackertemplate1.rb packertemplate.json
23
-
25
+
24
26
  To generate a Packer template from multiple Racker templates, run:
25
-
27
+
26
28
  $ racker rackertemplate1.rb rackertemplate2.rb packertemplate.json
27
-
29
+
28
30
  To merge multiple templates you can keep adding Racker templates:
29
31
 
30
32
  $ racker rackertemplate1.rb rackertemplate2.rb rackertemplate3.rb packertemplate.json
31
33
 
32
- The output of the previous command will be the template 1 deep merged with template2, the result of this merge is deep merged with template 3 then output as a packer template.
34
+ The output of the previous command will be template 1 deep merged with template2, the result of this merge is deep merged with template 3 then output as a packer template.
33
35
 
34
36
  ## Racker Template Syntax
35
- The goal of Racker is to provide a template structure that allows for allowing full control of the template merging process to achieve the desired Packer template.
37
+ The goal of Racker is to provide a template structure that allows for allowing full control of the template merging process to achieve the desired Packer template.
36
38
 
37
39
  In order to do this Racker takes an opinionated stance on the following:
38
40
 
@@ -71,7 +73,7 @@ end
71
73
 
72
74
  #### Builders Namespace
73
75
 
74
- Racker templates support the `builders` namespace which is a hash, keyed by the name of the builder.
76
+ Racker templates support the `builders` namespace which is a hash, keyed by the name of the builder.
75
77
 
76
78
  All Packer arrays inside of this namespace should be represented as hashes in Racker. Racker will use the value when creating the template, the key is there purely for allowing you to override/knockout as necessary.
77
79
 
@@ -113,7 +115,7 @@ One of the sections of node in this builder is the `vboxmanage`. It has been co
113
115
 
114
116
  #### Provisioners Namespace
115
117
 
116
- Racker templates support the `provisioners` namespace which is a Fixnum keyed hash.
118
+ Racker templates support the `provisioners` namespace which is a Fixnum keyed hash.
117
119
 
118
120
  When generating the Packer template, Racker will order the provisioners based upon the Fixnum key, this allows complete control on the ordering of provisioners throughout Racker templates.
119
121
 
@@ -187,12 +189,25 @@ Racker offers 2 very basic example templates `example/template1.rb` and `example
187
189
  To experiement with these templates, after installing Racker, and cloning this repo you can execute the following:
188
190
 
189
191
  $ racker ./example/template1rb ./example/tempalte2.rb ./example/packer.json
190
-
192
+
191
193
  While these two templates are not all inclusive of the capabilities of Racker, it shows off the ability to have a basic template, and a second template that removes the pieces of the template that target Amazon, as well as adds two chef solo provisioner steps.
192
194
 
193
195
  ## Testing
194
196
 
195
- TODO: This section needs to be written
197
+ Run the tests with `rake`:
198
+ ```bash
199
+ # Ensure you've installed the bundle:
200
+ bundle install
201
+
202
+ # Run spec tests
203
+ bundle exec rake spec
204
+
205
+ # Run tests and generate code coverage statistics
206
+ bundle exec rake coverage
207
+
208
+ # Run RuboCop assessment
209
+ bundle exec rake rubocop
210
+ ```
196
211
 
197
212
  ## Outstanding Development
198
213
 
@@ -200,7 +215,6 @@ TODO: This section needs to be written
200
215
  * docker
201
216
  * qemu
202
217
  * Implement unit testing
203
- * Travis CI
204
218
  * Additional documentation work
205
219
  * Add capability to target specific packer versions should the packer template format change.
206
220
  * Add quick init to generate a basic Racker template
@@ -212,4 +226,4 @@ https://github.com/aspring/racker/issues
212
226
 
213
227
  ## License
214
228
 
215
- This project is available under the MIT license. See LICENSE for details.
229
+ This project is available under the MIT license. See LICENSE for details.
data/Rakefile CHANGED
@@ -24,10 +24,10 @@ task :coverage do
24
24
  end
25
25
 
26
26
  require 'rubocop/rake_task'
27
- Rubocop::RakeTask.new(:rubocop) do |t|
27
+ RuboCop::RakeTask.new(:rubocop) do |t|
28
28
  # Specify the files we will look at
29
29
  t.patterns = ['bin', File.join('{lib}','**', '*.rb')]
30
-
30
+
31
31
  # Do not fail on error
32
32
  t.fail_on_error = false
33
33
  end
data/bin/racker CHANGED
@@ -1,40 +1,27 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
3
 
4
- if RUBY_VERSION >= '1.9.2'
5
- require 'log4r'
6
-
7
- begin
8
- $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
9
- require 'racker'
10
-
11
- # Create the initial logger
12
- log = Log4r::Logger.new('racker')
4
+ if RUBY_VERSION < '1.9.2'
5
+ puts 'Racker supports only Ruby 1.9.2+'
6
+ exit(-1)
7
+ end
13
8
 
14
- # Set the output to STDOUT
15
- log.outputters = Log4r::Outputter.stdout
9
+ begin
10
+ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
11
+ require 'racker'
16
12
 
17
- # We set the initial log level to ERROR
18
- log.level = Log4r::ERROR
19
-
20
- # Let the CLI do its thing
21
- exit_code = Racker::CLI.new(ARGV.dup).execute!
13
+ logger = Racker::LogSupport.logger
14
+ # Let the CLI do its thing
15
+ exit_code = Racker::CLI.new(ARGV.dup).execute!
22
16
 
23
- log.info("Exit code: #{exit_code}")
24
- Kernel.exit!(exit_code)
25
- rescue Exception => e
26
- log = Log4r::Logger.new('racker')
27
- log.outputters = Log4r::Outputter.stdout
28
- log.error("Racker has encountered an unexpected error!")
29
- log.error()
30
- log.error("Details:")
31
- log.error(e.inspect)
32
- log.error(e.message)
33
- log.error(e.backtrace.join('\n'))
34
- exit e.status_code if e.respond_to?(:status_code)
35
- exit 999
36
- end
37
- else
38
- puts 'Racker supports only Ruby 1.9.2+'
39
- exit(-1)
17
+ logger.info("Exit code: #{exit_code}")
18
+ Kernel.exit!(exit_code)
19
+ rescue Exception => e
20
+ logger.error("Racker has encountered an unexpected error!")
21
+ logger.error()
22
+ logger.error("Details:")
23
+ logger.error(e.inspect)
24
+ logger.error(e.message)
25
+ logger.error(e.backtrace.join('\n'))
26
+ exit e.respond_to?(:status_code) ? e.status_code : 999
40
27
  end
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  # Internal
4
+ require 'racker/log_support'
4
5
  require 'racker/cli'
5
6
  require 'racker/processor'
6
7
  require 'racker/version'
@@ -6,18 +6,17 @@ module Racker
6
6
  # This is the Amazon builder
7
7
  class Amazon < Racker::Builders::Builder
8
8
  def to_packer(name, config)
9
- log = Log4r::Logger['racker']
10
- log.debug("Entering #{self.class}.#{__method__}")
9
+ logger.debug("Entering #{self.class}.#{__method__}")
11
10
  config = super(name, config)
12
11
 
13
12
  %w(ami_block_device_mappings ami_groups ami_product_codes ami_regions ami_users chroot_mounts copy_files launch_block_device_mappings security_group_ids).each do |key|
14
13
  if config.key? key
15
- log.info("Converting #{key} to packer value...")
14
+ logger.info("Converting #{key} to packer value...")
16
15
  config[key] = convert_hash_to_packer_value(config[key])
17
16
  end
18
17
  end
19
18
 
20
- log.debug("Leaving #{self.class}.#{__method__}")
19
+ logger.debug("Leaving #{self.class}.#{__method__}")
21
20
  config
22
21
  end
23
22
  end
@@ -5,15 +5,16 @@ module Racker
5
5
  module Builders
6
6
  # This is the Builder base class
7
7
  class Builder
8
+ include Racker::LogSupport
9
+
8
10
  def to_packer(name, config)
9
- log = Log4r::Logger['racker']
10
- log.debug("Entering #{self.class}.#{__method__}")
11
-
11
+ logger.debug("Entering #{self.class}.#{__method__}")
12
+
12
13
  # Set the name of the builder
13
- log.info("Setting config name to #{name}")
14
+ logger.info("Setting config name to #{name}")
14
15
  config['name'] = name
15
16
 
16
- log.debug("Leaving #{self.class}.#{__method__}")
17
+ logger.debug("Leaving #{self.class}.#{__method__}")
17
18
  config
18
19
  end
19
20
 
@@ -6,20 +6,19 @@ module Racker
6
6
  # This is the DigitalOcean builder
7
7
  class DigitalOcean < Racker::Builders::Builder
8
8
  def to_packer(name, config)
9
- log = Log4r::Logger['racker']
10
- log.debug("Entering #{self.class}.#{__method__}")
9
+ logger.debug("Entering #{self.class}.#{__method__}")
11
10
  config = super(name, config)
12
11
 
13
12
  # There are no special cases at this point
14
-
13
+
15
14
  # %w().each do |key|
16
15
  # if config.key? key
17
- # log.info("Converting #{key} to packer value...")
16
+ # logger.info("Converting #{key} to packer value...")
18
17
  # config[key] = convert_hash_to_packer_value(config[key])
19
18
  # end
20
19
  # end
21
20
 
22
- log.debug("Leaving #{self.class}.#{__method__}")
21
+ logger.debug("Leaving #{self.class}.#{__method__}")
23
22
  config
24
23
  end
25
24
  end
@@ -6,18 +6,17 @@ module Racker
6
6
  # This is the Docker builder
7
7
  class Docker < Racker::Builders::Builder
8
8
  def to_packer(name, config)
9
- log = Log4r::Logger['racker']
10
- log.debug("Entering #{self.class}.#{__method__}")
9
+ logger.debug("Entering #{self.class}.#{__method__}")
11
10
  config = super(name, config)
12
11
 
13
12
  %w(run_command).each do |key|
14
13
  if config.key? key
15
- log.info("Converting #{key} to packer value...")
14
+ logger.info("Converting #{key} to packer value...")
16
15
  config[key] = convert_hash_to_packer_value(config[key])
17
16
  end
18
17
  end
19
18
 
20
- log.debug("Leaving #{self.class}.#{__method__}")
19
+ logger.debug("Leaving #{self.class}.#{__method__}")
21
20
  config
22
21
  end
23
22
  end
@@ -6,20 +6,19 @@ module Racker
6
6
  # This is the Google builder
7
7
  class Google < Racker::Builders::Builder
8
8
  def to_packer(name, config)
9
- log = Log4r::Logger['racker']
10
- log.debug("Entering #{self.class}.#{__method__}")
9
+ logger.debug("Entering #{self.class}.#{__method__}")
11
10
  config = super(name, config)
12
11
 
13
12
  # There are no special cases at this point
14
-
13
+
15
14
  # %w().each do |key|
16
15
  # if config.key? key
17
- # log.info("Converting #{key} to packer value...")
16
+ # logger.info("Converting #{key} to packer value...")
18
17
  # config[key] = convert_hash_to_packer_value(config[key])
19
18
  # end
20
19
  # end
21
20
 
22
- log.debug("Leaving #{self.class}.#{__method__}")
21
+ logger.debug("Leaving #{self.class}.#{__method__}")
23
22
  config
24
23
  end
25
24
  end
@@ -6,20 +6,19 @@ module Racker
6
6
  # This is the Null builder
7
7
  class Null < Racker::Builders::Builder
8
8
  def to_packer(name, config)
9
- log = Log4r::Logger['racker']
10
- log.debug("Entering #{self.class}.#{__method__}")
9
+ logger.debug("Entering #{self.class}.#{__method__}")
11
10
  config = super(name, config)
12
11
 
13
12
  # There are no special cases at this point
14
-
13
+
15
14
  # %w().each do |key|
16
15
  # if config.key? key
17
- # log.info("Converting #{key} to packer value...")
16
+ # logger.info("Converting #{key} to packer value...")
18
17
  # config[key] = convert_hash_to_packer_value(config[key])
19
18
  # end
20
19
  # end
21
20
 
22
- log.debug("Leaving #{self.class}.#{__method__}")
21
+ logger.debug("Leaving #{self.class}.#{__method__}")
23
22
  config
24
23
  end
25
24
  end
@@ -6,18 +6,17 @@ module Racker
6
6
  # This is the OpenStack builder
7
7
  class OpenStack < Racker::Builders::Builder
8
8
  def to_packer(name, config)
9
- log = Log4r::Logger['racker']
10
- log.debug("Entering #{self.class}.#{__method__}")
9
+ logger.debug("Entering #{self.class}.#{__method__}")
11
10
  config = super(name, config)
12
11
 
13
12
  %w(security_groups).each do |key|
14
13
  if config.key? key
15
- log.info("Converting #{key} to packer value...")
14
+ logger.info("Converting #{key} to packer value...")
16
15
  config[key] = convert_hash_to_packer_value(config[key])
17
16
  end
18
17
  end
19
18
 
20
- log.debug("Leaving #{self.class}.#{__method__}")
19
+ logger.debug("Leaving #{self.class}.#{__method__}")
21
20
  config
22
21
  end
23
22
  end
@@ -6,18 +6,17 @@ module Racker
6
6
  # This is the Parallels builder
7
7
  class Parallels < Racker::Builders::Builder
8
8
  def to_packer(name, config)
9
- log = Log4r::Logger['racker']
10
- log.debug("Entering #{self.class}.#{__method__}")
9
+ logger.debug("Entering #{self.class}.#{__method__}")
11
10
  config = super(name, config)
12
11
 
13
12
  %w(boot_command floppy_files host_interfaces iso_urls prlctl).each do |key|
14
13
  if config.key? key
15
- log.info("Converting #{key} to packer value...")
14
+ logger.info("Converting #{key} to packer value...")
16
15
  config[key] = convert_hash_to_packer_value(config[key])
17
16
  end
18
17
  end
19
18
 
20
- log.debug("Leaving #{self.class}.#{__method__}")
19
+ logger.debug("Leaving #{self.class}.#{__method__}")
21
20
  config
22
21
  end
23
22
  end
@@ -6,18 +6,17 @@ module Racker
6
6
  # This is the QEMU builder
7
7
  class QEMU < Racker::Builders::Builder
8
8
  def to_packer(name, config)
9
- log = Log4r::Logger['racker']
10
- log.debug("Entering #{self.class}.#{__method__}")
9
+ logger.debug("Entering #{self.class}.#{__method__}")
11
10
  config = super(name, config)
12
11
 
13
12
  %w(boot_command floppy_files iso_urls qemuargs).each do |key|
14
13
  if config.key? key
15
- log.info("Converting #{key} to packer value...")
14
+ logger.info("Converting #{key} to packer value...")
16
15
  config[key] = convert_hash_to_packer_value(config[key])
17
16
  end
18
17
  end
19
18
 
20
- log.debug("Leaving #{self.class}.#{__method__}")
19
+ logger.debug("Leaving #{self.class}.#{__method__}")
21
20
  config
22
21
  end
23
22
  end
@@ -6,20 +6,19 @@ module Racker
6
6
  # This is the Virtualbox builder
7
7
  class Virtualbox < Racker::Builders::Builder
8
8
  def to_packer(name, config)
9
- log = Log4r::Logger['racker']
10
- log.debug("Entering #{self.class}.#{__method__}")
9
+ logger.debug("Entering #{self.class}.#{__method__}")
11
10
  config = super(name, config)
12
11
 
13
12
  %w(boot_command export_opts floppy_files import_flags iso_urls vboxmanage vboxmanage_post).each do |key|
14
13
  if config.key? key
15
- log.info("Converting #{key} to packer value...")
14
+ logger.info("Converting #{key} to packer value...")
16
15
  config[key] = convert_hash_to_packer_value(config[key])
17
16
  end
18
17
  end
19
18
 
20
- log.debug("Leaving #{self.class}.#{__method__}")
19
+ logger.debug("Leaving #{self.class}.#{__method__}")
21
20
  config
22
21
  end
23
22
  end
24
23
  end
25
- end
24
+ end
@@ -6,20 +6,19 @@ module Racker
6
6
  # This is the VMware builder
7
7
  class VMware < Racker::Builders::Builder
8
8
  def to_packer(name, config)
9
- log = Log4r::Logger['racker']
10
- log.debug("Entering #{self.class}.#{__method__}")
9
+ logger.debug("Entering #{self.class}.#{__method__}")
11
10
  config = super(name, config)
12
11
 
13
12
  %w(boot_command floppy_files iso_urls).each do |key|
14
13
  if config.key? key
15
- log.info("Converting #{key} to packer value...")
14
+ logger.info("Converting #{key} to packer value...")
16
15
  config[key] = convert_hash_to_packer_value(config[key])
17
16
  end
18
17
  end
19
18
 
20
- log.debug("Leaving #{self.class}.#{__method__}")
19
+ logger.debug("Leaving #{self.class}.#{__method__}")
21
20
  config
22
21
  end
23
22
  end
24
23
  end
25
- end
24
+ end