packer-config 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bdd9616df0548b2607fc93a93880270f58ca46fa
4
- data.tar.gz: 9a184d7d17f0a6682aefd1f17fbf3d66a53978ff
3
+ metadata.gz: e83b6084bc9fc5e7f733b5cd914555e1f5ec5b21
4
+ data.tar.gz: 58691f783c9828674fa806d3c14ca589f4b01269
5
5
  SHA512:
6
- metadata.gz: c3b494a1807f093cd67c9e700d9c622941cef01b5c3d613aa74f59d55ada1665372deac186da75fbc224c49adbc31d6a8f636a3509e3993804729de9465cd2df
7
- data.tar.gz: d93976dd629da5c2437d2f071e51ad4db552fe886adf388a231de2a015f8db473216deb74e4950bba610a9187e1f460c140902ddcd9a488f380929c0768c4f50
6
+ metadata.gz: 485f6738bda938b9ca79e9f594df1e0daab586380a0cd51a8b3747ccf1338784d1751d92a02c9229608614f892528964f68146ebc8aaa2af64659d782333896f
7
+ data.tar.gz: aa530dfdd9d9ce3024c2498c0d64ecfafc38467ff9ab8bf1a1f2946a6046d74b7d4ee1f901551a21982d3b9908a9fbcbc89e21890041fba010d6e05d2b1d4f6c
@@ -38,10 +38,21 @@ Lint/EndAlignment:
38
38
  Lint/Loop:
39
39
  Enabled: false
40
40
 
41
+ Lint/UnusedMethodArgument:
42
+ Exclude:
43
+ - 'lib/packer/dataobject.rb'
44
+ - 'lib/packer/envvar.rb'
45
+ - 'lib/packer/macro.rb'
46
+ - 'lib/packer/provisioners/powershell.rb'
47
+
41
48
  Lint/Void:
42
49
  Exclude:
43
50
  - dashboard/spec/**/*
44
51
 
52
+ Style/FileName:
53
+ Exclude:
54
+ - 'lib/packer-config.rb'
55
+
45
56
  Style/AccessModifierIndentation:
46
57
  Enabled: false
47
58
 
@@ -60,6 +71,15 @@ Style/AlignParameters:
60
71
  Metrics/BlockNesting:
61
72
  Enabled: false
62
73
 
74
+ Metrics/AbcSize:
75
+ Max: 30
76
+
77
+ Metrics/ClassLength:
78
+ Max: 150
79
+
80
+ Metrics/MethodLength:
81
+ Max: 27
82
+
63
83
  Style/BracesAroundHashParameters:
64
84
  Enabled: false
65
85
 
@@ -171,6 +191,9 @@ Style/WhileUntilDo:
171
191
  Style/WhileUntilModifier:
172
192
  Enabled: false
173
193
 
194
+ Style/IndentHash:
195
+ Enabled: false
196
+
174
197
  # As of rubocop 0.21, it thinks kwargs are useless assignments
175
198
  UselessAssignment:
176
199
  Enabled: false
@@ -6,84 +6,6 @@
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 3
10
- Lint/IneffectiveAccessModifier:
11
- Exclude:
12
- - 'lib/packer/builder.rb'
13
- - 'lib/packer/postprocessor.rb'
14
- - 'lib/packer/provisioner.rb'
15
-
16
- # Offense count: 1
17
- # Cop supports --auto-correct.
18
- # Configuration parameters: IgnoreEmptyBlocks.
19
- Lint/UnusedBlockArgument:
20
- Exclude:
21
- - 'lib/packer/runner.rb'
22
-
23
- # Offense count: 8
24
- # Cop supports --auto-correct.
25
- # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
26
- Lint/UnusedMethodArgument:
27
- Exclude:
28
- - 'lib/packer/dataobject.rb'
29
- - 'lib/packer/envvar.rb'
30
- - 'lib/packer/macro.rb'
31
- - 'lib/packer/provisioners/powershell.rb'
32
-
33
- # Offense count: 2
34
- Lint/UselessAccessModifier:
35
- Exclude:
36
- - 'lib/packer/postprocessor.rb'
37
- - 'lib/packer/provisioner.rb'
38
-
39
- # Offense count: 8
40
- Metrics/AbcSize:
41
- Max: 30
42
-
43
- # Offense count: 4
44
- # Configuration parameters: CountComments.
45
- Metrics/ClassLength:
46
- Max: 150
47
-
48
- # Offense count: 7
49
- # Configuration parameters: CountComments.
50
- Metrics/MethodLength:
51
- Max: 27
52
-
53
- # Offense count: 1
54
- # Cop supports --auto-correct.
55
- # Configuration parameters: SingleLineConditionsOnly.
56
- Style/ConditionalAssignment:
57
- Exclude:
58
- - 'lib/packer/dataobject.rb'
59
-
60
- # Offense count: 9
61
- # Cop supports --auto-correct.
62
- Style/DeprecatedHashMethods:
63
- Exclude:
64
- - 'lib/packer-config.rb'
65
- - 'lib/packer/dataobject.rb'
66
- - 'lib/packer/postprocessor.rb'
67
- - 'lib/packer/provisioner.rb'
68
-
69
- # Offense count: 1
70
- # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
71
- Style/FileName:
72
- Exclude:
73
- - 'lib/packer-config.rb'
74
-
75
- # Offense count: 1
76
- Style/IfInsideElse:
77
- Exclude:
78
- - 'lib/packer/dataobject.rb'
79
-
80
- # Offense count: 6
81
- # Cop supports --auto-correct.
82
- # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
83
- # SupportedStyles: special_inside_parentheses, consistent, align_braces
84
- Style/IndentHash:
85
- Enabled: false
86
-
87
9
  # Offense count: 31
88
10
  # Cop supports --auto-correct.
89
11
  Style/MutableConstant:
@@ -97,55 +19,8 @@ Style/MutableConstant:
97
19
  - 'spec/packer/postprocessor_spec.rb'
98
20
  - 'spec/packer/provisioner_spec.rb'
99
21
 
100
- # Offense count: 2
101
- # Cop supports --auto-correct.
102
- Style/NegatedIf:
103
- Exclude:
104
- - 'lib/packer/dataobject.rb'
105
-
106
- # Offense count: 9
107
- Style/NestedParenthesizedCalls:
108
- Exclude:
109
- - 'spec/packer/envvar_spec.rb'
110
- - 'spec/packer/macro_spec.rb'
111
- - 'spec/packer/runner_spec.rb'
112
- - 'spec/packer_config_spec.rb'
113
-
114
- # Offense count: 1
115
- # Cop supports --auto-correct.
116
- # Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
117
- # SupportedStyles: skip_modifier_ifs, always
118
- Style/Next:
119
- Exclude:
120
- - 'lib/packer/dataobject.rb'
121
-
122
- # Offense count: 1
123
- # Cop supports --auto-correct.
124
- Style/NumericLiterals:
125
- MinDigits: 6
126
-
127
22
  # Offense count: 34
128
23
  # Cop supports --auto-correct.
129
24
  # Configuration parameters: PreferredDelimiters.
130
25
  Style/PercentLiteralDelimiters:
131
26
  Enabled: false
132
-
133
- # Offense count: 6
134
- # Cop supports --auto-correct.
135
- # Configuration parameters: EnforcedStyle, SupportedStyles.
136
- # SupportedStyles: space, no_space
137
- Style/SpaceBeforeBlockBraces:
138
- Enabled: false
139
-
140
- # Offense count: 5
141
- # Cop supports --auto-correct.
142
- # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
143
- # SupportedStyles: space, no_space
144
- Style/SpaceInsideBlockBraces:
145
- Enabled: false
146
-
147
- # Offense count: 1
148
- # Cop supports --auto-correct.
149
- Style/UnneededInterpolation:
150
- Exclude:
151
- - 'lib/packer/runner.rb'
data/README.md CHANGED
@@ -69,27 +69,27 @@ The following [Packer post-processors](http://www.packer.io/docs/templates/post-
69
69
 
70
70
  ### Packing a Vagrant Basebox from a CentOS ISO Using VirtualBox
71
71
 
72
- This example is based on the integration test [spec/integration/centos_vagrant_spec.rb](spec/integration/centos_vagrant_spec.rb). It produces a Vagrant Basebox that's provisionable with [Chef](http://www.getchef.com/) and the packer config and provisioning is taken from the [Bento](https://github.com/opscode/bento) project from the OpsCode crew.
72
+ This example is based on the integration test [spec/integration/centos_vagrant_spec.rb](spec/integration/centos_vagrant_spec.rb). It produces a Vagrant Basebox that's provisionable with [Chef](http://www.getchef.com/) and the packer config and provisioning is based on work done in the [Bento](https://github.com/opscode/bento) project from the OpsCode crew.
73
73
 
74
- OS = 'centos-6.6'
74
+ CENTOS_VERSION = '6.8'
75
75
 
76
- pconfig = Packer::Config.new "#{OS}-vagrant.json"
77
- pconfig.description "#{OS} VirtualBox Vagrant"
76
+ pconfig = Packer::Config.new "centos-#{CENTOS_VERSION}-vagrant.json"
77
+ pconfig.description "CentOS #{CENTOS_VERSION} VirtualBox Vagrant"
78
78
  pconfig.add_variable 'mirror', 'http://mirrors.sonic.net/centos/'
79
79
  pconfig.add_variable 'my_version', '0.0.1'
80
80
  pconfig.add_variable 'chef_version', 'latest'
81
81
 
82
82
  builder = pconfig.add_builder Packer::Builder::VIRTUALBOX_ISO
83
- builder.boot_command ["<tab> text ks=http://#{pconfig.macro.HTTPIP}:#{pconfig.macro.HTTPPort}/#{OS}-ks.cfg<enter><wait>"]
83
+ builder.boot_command ["<tab> text ks=http://#{pconfig.macro.HTTPIP}:#{pconfig.macro.HTTPPort}/centos-#{CENTOS_VERSION}-ks.cfg<enter><wait>"]
84
84
  builder.boot_wait '10s'
85
- builder.disk_size 40960
85
+ builder.disk_size 40_960
86
86
  builder.guest_additions_path "VBoxGuestAdditions_#{pconfig.macro.Version}.iso"
87
87
  builder.guest_os_type "RedHat_64"
88
88
  builder.http_directory "scripts/kickstart"
89
- builder.iso_checksum '7bb8c1c23a4fdef93e6f0a6347d570e5764d0b38'
89
+ builder.iso_checksum 'afab3a588cda94cd768826e77ad4db2b5ee7c485'
90
90
  builder.iso_checksum_type 'sha1'
91
- builder.iso_url "#{pconfig.variable 'mirror'}/6.7/isos/x86_64/CentOS-6.7-x86_64-bin-DVD1.iso"
92
- builder.output_directory "#{OS}-x86_64-virtualbox"
91
+ builder.iso_url "#{pconfig.variable 'mirror'}/6/isos/x86_64/CentOS-#{CENTOS_VERSION}-x86_64-bin-DVD1.iso"
92
+ builder.output_directory "centos-#{CENTOS_VERSION}-x86_64-virtualbox"
93
93
  builder.shutdown_command "echo 'vagrant'|sudo -S /sbin/halt -h -p"
94
94
  builder.communicator "ssh"
95
95
  builder.ssh_password "vagrant"
@@ -111,7 +111,7 @@ This example is based on the integration test [spec/integration/centos_vagrant_s
111
111
  ]
112
112
  ]
113
113
  builder.virtualbox_version_file ".vbox_version"
114
- builder.vm_name "packer-#{OS}-x86_64"
114
+ builder.vm_name "packer-centos-#{CENTOS_VERSION}-x86_64"
115
115
 
116
116
  provisioner = pconfig.add_provisioner Packer::Provisioner::FILE
117
117
  provisioner.source 'scripts/hello.sh'
@@ -129,12 +129,12 @@ This example is based on the integration test [spec/integration/centos_vagrant_s
129
129
  ]
130
130
  provisioner.environment_vars [
131
131
  "CHEF_VERSION=#{pconfig.variable 'chef_version'}",
132
- "MY_VERSION=#{pconfig.variable 'my_version'}"
132
+ "MY_CENTOS_VERSION=#{pconfig.variable 'my_version'}"
133
133
  ]
134
134
  provisioner.execute_command "echo 'vagrant' | #{pconfig.macro.Vars} sudo -S -E bash '#{pconfig.macro.Path}'"
135
135
 
136
136
  postprocessor = pconfig.add_postprocessor Packer::PostProcessor::VAGRANT
137
- postprocessor.output File.join('builds', pconfig.macro.Provider, "#{OS}-x86_64-#{pconfig.variable 'my_version'}.box")
137
+ postprocessor.output File.join('builds', pconfig.macro.Provider, "centos-#{CENTOS_VERSION}-x86_64-#{pconfig.variable 'my_version'}.box")
138
138
 
139
139
  pconfig.validate
140
140
  pconfig.build
@@ -1,5 +1,9 @@
1
1
  # packer-config Release Notes
2
2
 
3
+ ## 1.6.1
4
+
5
+ * Added a verbose option to the `verify` method on `Packer::Config`. Closes issue #19.
6
+
3
7
  ## 1.6.0
4
8
 
5
9
  * Support for running Packer on Windows!
@@ -36,8 +36,8 @@ module Packer
36
36
  self.envvar = EnvVar.new
37
37
  end
38
38
 
39
- def validate
40
- super
39
+ def validate(verbose: false)
40
+ super()
41
41
  verify_packer_version
42
42
  if self.builders.empty?
43
43
  raise DataValidationError.new("At least one builder is required")
@@ -49,7 +49,7 @@ module Packer
49
49
  stdout = nil
50
50
  Dir.chdir(File.dirname(self.output_file)) do
51
51
  begin
52
- stdout = Packer::Runner.run! self.packer, 'validate', File.basename(self.output_file), quiet: true
52
+ stdout = Packer::Runner.run! self.packer, 'validate', File.basename(self.output_file), quiet: !verbose
53
53
  rescue Packer::Runner::CommandExecutionError => e
54
54
  raise PackerBuildError.new(e.to_s)
55
55
  end
@@ -153,7 +153,7 @@ module Packer
153
153
  end
154
154
 
155
155
  def variable(name)
156
- unless self.variables.has_key? name
156
+ unless self.variables.key? name
157
157
  raise UndefinedVariableError.new("No variable named #{name} has been defined -- did you forget to call add_variable?")
158
158
  end
159
159
  "{{user `#{name}`}}"
@@ -144,5 +144,7 @@ module Packer
144
144
  def self.validate_type(type)
145
145
  VALID_BUILDER_TYPES.include? type
146
146
  end
147
+
148
+ private_class_method :validate_type
147
149
  end
148
150
  end
@@ -25,26 +25,23 @@ module Packer
25
25
  def validate_required
26
26
  self.required.each do |r|
27
27
  if (r.is_a? Array) && !r.empty?
28
- if r.length - (r - self.data.keys).length == 0
28
+ if (r.length - (r - self.data.keys).length).zero?
29
29
  raise DataValidationError.new("Missing one required setting from the set #{r}")
30
30
  end
31
31
  if r.length - (r - self.data.keys).length > 1
32
32
  raise DataValidationError.new("Found more than one exclusive setting in data from set #{r}")
33
33
  end
34
- else
35
- if ! self.data.keys.include? r
36
- raise DataValidationError.new("Missing required setting #{r}")
37
- end
34
+ elsif ! self.data.keys.include? r
35
+ raise DataValidationError.new("Missing required setting #{r}")
38
36
  end
39
37
  end
40
38
  end
41
39
 
42
40
  def validate_key_dependencies
43
41
  self.data.keys.each do |data_key|
44
- if self.key_dependencies.has_key? data_key
45
- if ! (self.key_dependencies[data_key] - self.data.keys).empty?
46
- raise DataValidationError.new("Key #{data_key} requires that keys be defined: #{self.key_dependencies[data_key]}")
47
- end
42
+ next unless self.key_dependencies.key? data_key
43
+ unless (self.key_dependencies[data_key] - self.data.keys).empty?
44
+ raise DataValidationError.new("Key #{data_key} requires that keys be defined: #{self.key_dependencies[data_key]}")
48
45
  end
49
46
  end
50
47
  end
@@ -68,7 +65,7 @@ module Packer
68
65
 
69
66
  def __exclusive_key_error(key, exclusives)
70
67
  exclusives.each do |e|
71
- if self.data.has_key? e
68
+ if self.data.key? e
72
69
  raise ExclusiveKeyError.new("Only one of #{exclusives} can be used at a time")
73
70
  end
74
71
  end
@@ -123,11 +120,7 @@ module Packer
123
120
 
124
121
  def __add_boolean(key, bool, exclusives = [])
125
122
  self.__exclusive_key_error(key, exclusives)
126
- if bool
127
- self.data[key.to_s] = true
128
- else
129
- self.data[key.to_s] = false
130
- end
123
+ self.data[key.to_s] = bool ? true : false
131
124
  end
132
125
 
133
126
  def __add_hash(key, data, exclusives = [])
@@ -1,10 +1,16 @@
1
1
  # Encoding: utf-8
2
+ # rubocop:disable Style/MethodMissing
3
+
2
4
  module Packer
3
5
  class EnvVar
4
6
  def method_missing(method_name, *args)
5
7
  "{{env `#{method_name}`}}"
6
8
  end
7
9
 
10
+ def respond_to_missing?(method_name, include_private = false)
11
+ true
12
+ end
13
+
8
14
  def respond_to?(symbol, include_private=false)
9
15
  # We literally respond to everything...
10
16
  true
@@ -1,4 +1,6 @@
1
1
  # Encoding: utf-8
2
+ # rubocop:disable Style/MethodMissing
3
+
2
4
  module Packer
3
5
  class Macro
4
6
  def method_missing(method_name, *args)
@@ -6,6 +8,10 @@ module Packer
6
8
  "{{ .#{name} }}"
7
9
  end
8
10
 
11
+ def respond_to_missing?(method_name, include_private = false)
12
+ true
13
+ end
14
+
9
15
  def respond_to?(symbol, include_private=false)
10
16
  # We literally respond to everything...
11
17
  true
@@ -44,14 +44,14 @@ module Packer
44
44
  end
45
45
 
46
46
  def only(buildname)
47
- unless self.data.has_key? 'only'
47
+ unless self.data.key? 'only'
48
48
  self.data['only'] = []
49
49
  end
50
50
  self.data['only'] << buildname.to_s
51
51
  end
52
52
 
53
53
  def except(buildname)
54
- unless self.data.has_key? 'except'
54
+ unless self.data.key? 'except'
55
55
  self.data['except'] = []
56
56
  end
57
57
  self.data['except'] << buildname.to_s
@@ -61,9 +61,10 @@ module Packer
61
61
  self.__add_boolean('keep_input_artifact', bool)
62
62
  end
63
63
 
64
- private
65
64
  def self.validate_type(type)
66
65
  VALID_POST_PROCESSOR_TYPES.include? type
67
66
  end
67
+
68
+ private_class_method :validate_type
68
69
  end
69
70
  end
@@ -62,14 +62,14 @@ module Packer
62
62
  end
63
63
 
64
64
  def only(buildname)
65
- unless self.data.has_key? 'only'
65
+ unless self.data.key? 'only'
66
66
  self.data['only'] = []
67
67
  end
68
68
  self.data['only'] << buildname.to_s
69
69
  end
70
70
 
71
71
  def except(buildname)
72
- unless self.data.has_key? 'except'
72
+ unless self.data.key? 'except'
73
73
  self.data['except'] = []
74
74
  end
75
75
  self.data['except'] << buildname.to_s
@@ -81,19 +81,20 @@ module Packer
81
81
 
82
82
  def override(builddefinition, values)
83
83
  raise TypeError.new() unless values.is_a?(Hash)
84
- unless self.data.has_key? 'override'
84
+ unless self.data.key? 'override'
85
85
  self.data['override'] = {}
86
86
  end
87
- if self.data.has_key? @data['override'][builddefinition]
87
+ if self.data.key? @data['override'][builddefinition]
88
88
  self.data['override'][builddefinition].merge! values
89
89
  else
90
90
  self.data['override'][builddefinition] = values
91
91
  end
92
92
  end
93
93
 
94
- private
95
94
  def self.validate_type(type)
96
95
  VALID_PROVISIONER_TYPES.include? type
97
96
  end
97
+
98
+ private_class_method :validate_type
98
99
  end
99
- end
100
+ end
@@ -17,12 +17,12 @@ module Packer
17
17
  else
18
18
  # Run but stream as well as capture stdout to the screen
19
19
  # see: http://stackoverflow.com/a/1162850/83386
20
- Open3.popen3(cmd) do |std_in, std_out, std_err, thread|
20
+ Open3.popen3(cmd) do |_std_in, std_out, std_err, thread|
21
21
  # read each stream from a new thread
22
22
  Thread.new do
23
23
  until (raw = std_out.getc).nil? do
24
24
  stdout << raw
25
- $stdout.write "#{raw}"
25
+ $stdout.write raw.to_s
26
26
  end
27
27
  end
28
28
  Thread.new do
@@ -35,6 +35,7 @@ module Packer
35
35
  status = thread.value
36
36
  end
37
37
  end
38
+ # rubocop:disable Style/NumericPredicate
38
39
  raise CommandExecutionError.new(stderr) unless status == 0
39
40
  stdout
40
41
  end
@@ -1,3 +1,3 @@
1
1
  module Packer
2
- VERSION = "1.6.0"
2
+ VERSION = '1.6.1'.freeze
3
3
  end
@@ -18,7 +18,7 @@ correct JSON format. It also saved me having to remember the esoteric Packer
18
18
  syntax for referencing variables and whatnot in the JSON.
19
19
  END
20
20
  spec.homepage = 'https://github.com/ianchesal/packer-config'
21
- spec.license = 'Apache 2.0'
21
+ spec.license = 'Apache-2.0'
22
22
  spec.required_ruby_version = '>= 2.0.0'
23
23
 
24
24
  spec.files = `git ls-files -z`.split("\x0")
@@ -2,26 +2,26 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  RSpec.describe Packer::Config do
5
- it 'can build a centos-6.5 Vagrant base box' do
6
- OS = 'centos-6.6'
5
+ it 'can build a centos-6.7 Vagrant base box' do
6
+ CENTOS_VERSION = '6.8'
7
7
 
8
- pconfig = Packer::Config.new "#{OS}-vagrant.json"
9
- pconfig.description "#{OS} VirtualBox Vagrant"
8
+ pconfig = Packer::Config.new "centos-#{CENTOS_VERSION}-vagrant.json"
9
+ pconfig.description "CentOS #{CENTOS_VERSION} VirtualBox Vagrant"
10
10
  pconfig.add_variable 'mirror', 'http://mirrors.sonic.net/centos/'
11
11
  pconfig.add_variable 'my_version', '0.0.1'
12
12
  pconfig.add_variable 'chef_version', 'latest'
13
13
 
14
14
  builder = pconfig.add_builder Packer::Builder::VIRTUALBOX_ISO
15
- builder.boot_command ["<tab> text ks=http://#{pconfig.macro.HTTPIP}:#{pconfig.macro.HTTPPort}/#{OS}-ks.cfg<enter><wait>"]
15
+ builder.boot_command ["<tab> text ks=http://#{pconfig.macro.HTTPIP}:#{pconfig.macro.HTTPPort}/centos-#{CENTOS_VERSION}-ks.cfg<enter><wait>"]
16
16
  builder.boot_wait '10s'
17
- builder.disk_size 40960
17
+ builder.disk_size 40_960
18
18
  builder.guest_additions_path "VBoxGuestAdditions_#{pconfig.macro.Version}.iso"
19
19
  builder.guest_os_type "RedHat_64"
20
20
  builder.http_directory "scripts/kickstart"
21
- builder.iso_checksum '7bb8c1c23a4fdef93e6f0a6347d570e5764d0b38'
21
+ builder.iso_checksum 'afab3a588cda94cd768826e77ad4db2b5ee7c485'
22
22
  builder.iso_checksum_type 'sha1'
23
- builder.iso_url "#{pconfig.variable 'mirror'}/6.7/isos/x86_64/CentOS-6.7-x86_64-bin-DVD1.iso"
24
- builder.output_directory "#{OS}-x86_64-virtualbox"
23
+ builder.iso_url "#{pconfig.variable 'mirror'}/6/isos/x86_64/CentOS-#{CENTOS_VERSION}-x86_64-bin-DVD1.iso"
24
+ builder.output_directory "centos-#{CENTOS_VERSION}-x86_64-virtualbox"
25
25
  builder.shutdown_command "echo 'vagrant'|sudo -S /sbin/halt -h -p"
26
26
  builder.communicator "ssh"
27
27
  builder.ssh_password "vagrant"
@@ -43,7 +43,7 @@ RSpec.describe Packer::Config do
43
43
  ]
44
44
  ]
45
45
  builder.virtualbox_version_file ".vbox_version"
46
- builder.vm_name "packer-#{OS}-x86_64"
46
+ builder.vm_name "packer-centos-#{CENTOS_VERSION}-x86_64"
47
47
 
48
48
  provisioner = pconfig.add_provisioner Packer::Provisioner::FILE
49
49
  provisioner.source 'scripts/hello.sh'
@@ -61,12 +61,12 @@ RSpec.describe Packer::Config do
61
61
  ]
62
62
  provisioner.environment_vars [
63
63
  "CHEF_VERSION=#{pconfig.variable 'chef_version'}",
64
- "MY_VERSION=#{pconfig.variable 'my_version'}"
64
+ "MY_CENTOS_VERSION=#{pconfig.variable 'my_version'}"
65
65
  ]
66
66
  provisioner.execute_command "echo 'vagrant' | #{pconfig.macro.Vars} sudo -S -E bash '#{pconfig.macro.Path}'"
67
67
 
68
68
  postprocessor = pconfig.add_postprocessor Packer::PostProcessor::VAGRANT
69
- postprocessor.output File.join('builds', pconfig.macro.Provider, "#{OS}-x86_64-#{pconfig.variable 'my_version'}.box")
69
+ postprocessor.output File.join('builds', pconfig.macro.Provider, "centos-#{CENTOS_VERSION}-x86_64-#{pconfig.variable 'my_version'}.box")
70
70
 
71
71
  Dir.chdir('spec/integration')
72
72
  expect(pconfig.validate).to be_truthy
@@ -19,7 +19,7 @@ RSpec.describe Packer::EnvVar do
19
19
  end
20
20
 
21
21
  it 'responds to anything' do
22
- expect(envvar.respond_to? 'anything').to be_truthy
23
- expect(envvar.respond_to? 'anything_else').to be_truthy
22
+ expect(envvar.respond_to?('anything')).to be_truthy
23
+ expect(envvar.respond_to?('anything_else')).to be_truthy
24
24
  end
25
25
  end
@@ -19,7 +19,7 @@ RSpec.describe Packer::Macro do
19
19
  end
20
20
 
21
21
  it 'responds to anything' do
22
- expect(macro.respond_to? 'anything').to be_truthy
23
- expect(macro.respond_to? 'anything_else').to be_truthy
22
+ expect(macro.respond_to?('anything')).to be_truthy
23
+ expect(macro.respond_to?('anything_else')).to be_truthy
24
24
  end
25
25
  end
@@ -23,7 +23,7 @@ RSpec.describe Packer::Provisioner::Ansible do
23
23
  end
24
24
 
25
25
  it 'requires a playbook_file setting' do
26
- expect{ provisioner.validate }.to raise_error
26
+ expect { provisioner.validate }.to raise_error
27
27
  end
28
28
 
29
29
  describe '#initialize' do
@@ -23,7 +23,7 @@ RSpec.describe Packer::Provisioner::Chef::Client do
23
23
  end
24
24
 
25
25
  it 'requires a server_url setting' do
26
- expect{ provisioner.validate }.to raise_error
26
+ expect { provisioner.validate }.to raise_error
27
27
  end
28
28
 
29
29
  describe '#initialize' do
@@ -71,7 +71,7 @@ RSpec.describe Packer::Provisioner do
71
71
  end
72
72
 
73
73
  it 'raises an error if arguments cannot be made into a hash' do
74
- expect{ provisioner.facter(some_string) }.to raise_error
74
+ expect { provisioner.facter(some_string) }.to raise_error
75
75
  end
76
76
  end
77
77
 
@@ -23,7 +23,7 @@ RSpec.describe Packer::Provisioner::Salt do
23
23
  end
24
24
 
25
25
  it 'requires a local_state_tree setting' do
26
- expect{ provisioner.validate }.to raise_error
26
+ expect { provisioner.validate }.to raise_error
27
27
  end
28
28
 
29
29
  describe '#initialize' do
@@ -7,13 +7,13 @@ RSpec.describe Packer::Runner do
7
7
  it 'returns stdout on success' do
8
8
  open3 = class_double("Open3").as_stubbed_const(:transfer_nested_constants => true)
9
9
  expect(open3).to receive(:capture3).and_return(['output', 'error', 0])
10
- expect(described_class.run! 'true', quiet: true).to eq('output')
10
+ expect(described_class.run!('true', quiet: true)).to eq('output')
11
11
  end
12
12
 
13
13
  it 'raises an error on failure' do
14
14
  open3 = class_double("Open3").as_stubbed_const(:transfer_nested_constants => true)
15
15
  expect(open3).to receive(:capture3).and_return(['output', 'error', 1])
16
- expect{ described_class.run! 'false', quiet: true }.to raise_error
16
+ expect { described_class.run!('false', quiet: true) }.to raise_error
17
17
  end
18
18
  end
19
19
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  require 'fakefs/spec_helpers'
4
4
 
5
5
  RSpec.describe Packer::Config do
6
- let(:config_file) { 'config.json'}
6
+ let(:config_file) { 'config.json' }
7
7
  let(:packer) { Packer::Config.new(config_file) }
8
8
  let(:builder_type) { Packer::Builder::VIRTUALBOX_ISO }
9
9
  let(:provisioner_type) { Packer::Provisioner::FILE }
@@ -97,33 +97,33 @@ RSpec.describe Packer::Config do
97
97
 
98
98
  describe "#add_builder" do
99
99
  it 'returns a builder for a valid type' do
100
- expect(packer.add_builder builder_type).to be_a_kind_of(Packer::Builder)
100
+ expect(packer.add_builder(builder_type)).to be_a_kind_of(Packer::Builder)
101
101
  expect(packer.builders.length).to eq(1)
102
102
  packer.builders = []
103
103
  end
104
104
 
105
105
  it 'raises an error for an invalid type' do
106
- expect { packer.add_builder 'invalid' }.to raise_error
106
+ expect { packer.add_builder('invalid') }.to raise_error
107
107
  expect(packer.builders.length).to eq(0)
108
108
  end
109
109
  end
110
110
 
111
111
  describe "#add_provisioner" do
112
112
  it 'returns a provisioner for a valid type' do
113
- expect(packer.add_provisioner provisioner_type).to be_a_kind_of(Packer::Provisioner)
113
+ expect(packer.add_provisioner(provisioner_type)).to be_a_kind_of(Packer::Provisioner)
114
114
  expect(packer.provisioners.length).to eq(1)
115
115
  packer.provisioners = []
116
116
  end
117
117
 
118
118
  it 'raises an error for an invalid type' do
119
- expect { packer.add_provisioner 'invalid' }.to raise_error
119
+ expect { packer.add_provisioner('invalid') }.to raise_error
120
120
  expect(packer.provisioners.length).to eq(0)
121
121
  end
122
122
  end
123
123
 
124
124
  describe "#add_postprocessor" do
125
125
  it 'returns a post-processor for a valid type' do
126
- expect(packer.add_postprocessor postprocessor_type).to be_a_kind_of(Packer::PostProcessor)
126
+ expect(packer.add_postprocessor(postprocessor_type)).to be_a_kind_of(Packer::PostProcessor)
127
127
  expect(packer.postprocessors.length).to eq(1)
128
128
  packer.postprocessors = []
129
129
  end
@@ -149,7 +149,7 @@ RSpec.describe Packer::Config do
149
149
  it 'creates a packer reference to a variable in the configuration' do
150
150
  expect(packer.variables).to eq({})
151
151
  packer.add_variable('key1', 'value1')
152
- expect(packer.variable 'key1').to eq('{{user `key1`}}')
152
+ expect(packer.variable('key1')).to eq('{{user `key1`}}')
153
153
  packer.data['variables'] = {}
154
154
  end
155
155
 
@@ -180,7 +180,7 @@ RSpec.describe Packer::Config do
180
180
 
181
181
  it 'raises an error if the version of Packer is not high enough' do
182
182
  expect(Packer::Runner).to receive(:run!).and_return('Packer v0.0.1')
183
- expect{ packer.verify_packer_version }.to raise_error
183
+ expect { packer.verify_packer_version }.to raise_error
184
184
  end
185
185
  end
186
186
  end
@@ -6,10 +6,10 @@ task :clean do
6
6
  FileList['spec/integration/packer_cache/*'].each do |f|
7
7
  FileUtils.rm_f(f)
8
8
  end
9
- Dir.glob('spec/integration/builds/*').select {|f| File.directory? f}.each do |d|
9
+ Dir.glob('spec/integration/builds/*').select { |f| File.directory? f }.each do |d|
10
10
  FileUtils.rm_rf(d)
11
11
  end
12
- Dir.glob('spec/integration/*.json').select {|f| File.file? f}.each do |d|
12
+ Dir.glob('spec/integration/*.json').select { |f| File.file? f }.each do |d|
13
13
  FileUtils.rm_f(d)
14
14
  end
15
15
  end
@@ -2,7 +2,7 @@ require 'rspec/core/rake_task'
2
2
 
3
3
  namespace :test do
4
4
  RSpec::Core::RakeTask.new(:spec) do |t|
5
- t.pattern = Dir['spec/**/*_spec.rb'].reject{ |f| f['/integration'] }
5
+ t.pattern = Dir['spec/**/*_spec.rb'].reject { |f| f['/integration'] }
6
6
  end
7
7
 
8
8
  RSpec::Core::RakeTask.new(:integration) do |t|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: packer-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Chesal
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2016-04-08 00:00:00.000000000 Z
16
+ date: 2016-09-15 00:00:00.000000000 Z
17
17
  dependencies: []
18
18
  description: |
19
19
  Building the Packer JSON configurations in raw JSON can be quite an adventure.
@@ -79,7 +79,7 @@ files:
79
79
  - spec/integration/scripts/cleanup.sh
80
80
  - spec/integration/scripts/fix-slow-dns.sh
81
81
  - spec/integration/scripts/hello.sh
82
- - spec/integration/scripts/kickstart/centos-6.6-ks.cfg
82
+ - spec/integration/scripts/kickstart/centos-6.8-ks.cfg
83
83
  - spec/integration/scripts/minimize.sh
84
84
  - spec/integration/scripts/sshd.sh
85
85
  - spec/integration/scripts/vagrant.sh
@@ -122,7 +122,7 @@ files:
122
122
  - tasks/rubygems.rake
123
123
  homepage: https://github.com/ianchesal/packer-config
124
124
  licenses:
125
- - Apache 2.0
125
+ - Apache-2.0
126
126
  metadata: {}
127
127
  post_install_message:
128
128
  rdoc_options: []
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  requirements: []
142
142
  rubyforge_project:
143
- rubygems_version: 2.4.6
143
+ rubygems_version: 2.5.1
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: An object model to build packer.io configurations in Ruby.
@@ -153,7 +153,7 @@ test_files:
153
153
  - spec/integration/scripts/cleanup.sh
154
154
  - spec/integration/scripts/fix-slow-dns.sh
155
155
  - spec/integration/scripts/hello.sh
156
- - spec/integration/scripts/kickstart/centos-6.6-ks.cfg
156
+ - spec/integration/scripts/kickstart/centos-6.8-ks.cfg
157
157
  - spec/integration/scripts/minimize.sh
158
158
  - spec/integration/scripts/sshd.sh
159
159
  - spec/integration/scripts/vagrant.sh