packer-config 1.6.3 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.rubocop.yml +5 -4
- data/.travis.yml +0 -3
- data/COPYRIGHT +1 -0
- data/Gemfile +8 -7
- data/README.md +10 -13
- data/RELEASENOTES.md +9 -0
- data/lib/packer-config.rb +3 -1
- data/lib/packer/builder.rb +2 -0
- data/lib/packer/dataobject.rb +8 -0
- data/lib/packer/postprocessor.rb +6 -2
- data/lib/packer/postprocessors/all.rb +1 -0
- data/lib/packer/postprocessors/manifest.rb +26 -0
- data/lib/packer/postprocessors/shell-local.rb +3 -0
- data/lib/packer/provisioner.rb +2 -0
- data/lib/packer/runner.rb +1 -0
- data/lib/packer/version.rb +1 -1
- data/packer-config.gemspec +2 -2
- data/spec/integration/centos_vagrant_spec.rb +8 -12
- data/spec/integration/scripts/kickstart/centos-7-ks.cfg +98 -0
- data/spec/integration/scripts/minimize.sh +34 -5
- data/spec/integration/scripts/sshd.sh +18 -2
- data/spec/integration/scripts/vagrant.sh +17 -6
- data/spec/integration/scripts/vmtools.sh +13 -31
- data/spec/packer/postprocessors/manifest_spec.rb +65 -0
- metadata +10 -6
- data/spec/integration/scripts/kickstart/centos-6.10-ks.cfg +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f853df0259e71190114be57ce09149fefc507e0b
|
4
|
+
data.tar.gz: 2951764a66b04437211c990a05698b6bcf5da3b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca00142e7263ca83347baa0a8580920ebc5936fc4536b86e8dd5c9a569d84b32814eb583055faba62c41957e5f47ffdf1789b236f317a2dc1a308675fa223732
|
7
|
+
data.tar.gz: c092c380ef0409401fb3717e3e3eb73c78b62421b7c1fb2d8202c0e8327e3c8489ddd470f42414403a8634089dcc8dcae25e704658a232fcf5bd5e2725be9f76
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require: rubocop-performance
|
1
2
|
inherit_from: .rubocop_todo.yml
|
2
3
|
|
3
4
|
Documentation:
|
@@ -119,6 +120,9 @@ Layout/EmptyLines:
|
|
119
120
|
Layout/EmptyLinesAroundAccessModifier:
|
120
121
|
Enabled: false
|
121
122
|
|
123
|
+
Style/FrozenStringLiteralComment:
|
124
|
+
Enabled: false
|
125
|
+
|
122
126
|
Style/GuardClause:
|
123
127
|
Enabled: false
|
124
128
|
|
@@ -146,9 +150,6 @@ Style/MultilineIfThen:
|
|
146
150
|
Style/MultilineTernaryOperator:
|
147
151
|
Enabled: false
|
148
152
|
|
149
|
-
Style/MultilineTernaryOperator:
|
150
|
-
Enabled: false
|
151
|
-
|
152
153
|
Style/NilComparison:
|
153
154
|
Enabled: false
|
154
155
|
|
@@ -194,7 +195,7 @@ Style/WhileUntilDo:
|
|
194
195
|
Style/WhileUntilModifier:
|
195
196
|
Enabled: false
|
196
197
|
|
197
|
-
Layout/
|
198
|
+
Layout/IndentFirstHashElement:
|
198
199
|
Enabled: false
|
199
200
|
|
200
201
|
# As of rubocop 0.21, it thinks kwargs are useless assignments
|
data/.travis.yml
CHANGED
data/COPYRIGHT
CHANGED
@@ -9,6 +9,7 @@ Including, but not limited to:
|
|
9
9
|
Enzo Rivello
|
10
10
|
Edwin Biemond
|
11
11
|
Andrei Shiniti Nakagawa
|
12
|
+
Kevin Formsma
|
12
13
|
|
13
14
|
For licensing information please see LICENSE. Copyright holders contributing to
|
14
15
|
this project agree to have their contributions licensed under the terms of the
|
data/Gemfile
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
group :development, :test do
|
4
|
-
gem 'bundler'
|
5
|
-
gem 'fakefs'
|
6
|
-
gem 'rake'
|
7
|
-
gem 'rspec'
|
8
|
-
gem 'rspec-mocks'
|
9
|
-
gem 'rubocop'
|
10
|
-
gem '
|
4
|
+
gem 'bundler'
|
5
|
+
gem 'fakefs'
|
6
|
+
gem 'rake'
|
7
|
+
gem 'rspec'
|
8
|
+
gem 'rspec-mocks'
|
9
|
+
gem 'rubocop'
|
10
|
+
gem 'rubocop-performance'
|
11
|
+
gem 'rubygems-tasks'
|
11
12
|
end
|
12
13
|
|
13
14
|
gemspec
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ Bonus: you can really go to town with templates when it's all done in Ruby.
|
|
25
25
|
|
26
26
|
## Requires
|
27
27
|
|
28
|
-
* [Packer](http://packer.io) version 0.
|
28
|
+
* [Packer](http://packer.io) version 1.0.0 or higher
|
29
29
|
|
30
30
|
### Builders
|
31
31
|
|
@@ -67,6 +67,7 @@ The following [Packer post-processors](http://www.packer.io/docs/templates/post-
|
|
67
67
|
* [docker-tag](http://www.packer.io/docs/post-processors/docker-tag.html)
|
68
68
|
* [vagrant](http://www.packer.io/docs/post-processors/vagrant.html)
|
69
69
|
* [compress](https://www.packer.io/docs/post-processors/compress.html)
|
70
|
+
* [manifest](https://www.packer.io/docs/post-processors/manifest.html)
|
70
71
|
|
71
72
|
## Examples
|
72
73
|
|
@@ -74,11 +75,12 @@ The following [Packer post-processors](http://www.packer.io/docs/templates/post-
|
|
74
75
|
|
75
76
|
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.
|
76
77
|
|
77
|
-
CENTOS_VERSION = '
|
78
|
+
CENTOS_VERSION = '7'
|
78
79
|
|
79
80
|
pconfig = Packer::Config.new "centos-#{CENTOS_VERSION}-vagrant.json"
|
80
81
|
pconfig.description "CentOS #{CENTOS_VERSION} VirtualBox Vagrant"
|
81
|
-
pconfig.add_variable 'mirror', 'http://mirrors.sonic.net/centos
|
82
|
+
pconfig.add_variable 'mirror', 'http://mirrors.sonic.net/centos'
|
83
|
+
pconfig.add_variable 'mirror', 'http://ftp.pbone.net/pub/centos'
|
82
84
|
pconfig.add_variable 'my_version', '0.0.1'
|
83
85
|
pconfig.add_variable 'chef_version', 'latest'
|
84
86
|
|
@@ -89,9 +91,9 @@ This example is based on the integration test [spec/integration/centos_vagrant_s
|
|
89
91
|
builder.guest_additions_path "VBoxGuestAdditions_#{pconfig.macro.Version}.iso"
|
90
92
|
builder.guest_os_type "RedHat_64"
|
91
93
|
builder.http_directory "scripts/kickstart"
|
92
|
-
builder.iso_checksum '
|
93
|
-
builder.iso_checksum_type '
|
94
|
-
builder.iso_url "#{pconfig.variable 'mirror'}/
|
94
|
+
builder.iso_checksum '38d5d51d9d100fd73df031ffd6bd8b1297ce24660dc8c13a3b8b4534a4bd291c'
|
95
|
+
builder.iso_checksum_type 'sha256'
|
96
|
+
builder.iso_url "#{pconfig.variable 'mirror'}/#{CENTOS_VERSION}/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso"
|
95
97
|
builder.output_directory "centos-#{CENTOS_VERSION}-x86_64-virtualbox"
|
96
98
|
builder.shutdown_command "echo 'vagrant'|sudo -S /sbin/halt -h -p"
|
97
99
|
builder.communicator "ssh"
|
@@ -122,13 +124,8 @@ This example is based on the integration test [spec/integration/centos_vagrant_s
|
|
122
124
|
|
123
125
|
provisioner = pconfig.add_provisioner Packer::Provisioner::SHELL
|
124
126
|
provisioner.scripts [
|
125
|
-
'scripts/fix-slow-dns.sh',
|
126
127
|
'scripts/sshd.sh',
|
127
|
-
'scripts/vagrant.sh'
|
128
|
-
'scripts/vmtools.sh',
|
129
|
-
'scripts/chef.sh',
|
130
|
-
'scripts/cleanup.sh',
|
131
|
-
'scripts/minimize.sh'
|
128
|
+
'scripts/vagrant.sh'
|
132
129
|
]
|
133
130
|
provisioner.environment_vars [
|
134
131
|
"CHEF_VERSION=#{pconfig.variable 'chef_version'}",
|
@@ -160,4 +157,4 @@ Please see [TODO.md](TODO.md) for the short list of big things I thought worth w
|
|
160
157
|
|
161
158
|
## Contact Me
|
162
159
|
|
163
|
-
Questions or comments about `packer-config`? Hit me up at ian.chesal@gmail.com
|
160
|
+
Questions or comments about `packer-config`? Hit me up at ian.chesal@gmail.com.
|
data/RELEASENOTES.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# packer-config Release Notes
|
2
2
|
|
3
|
+
## 1.6.4
|
4
|
+
|
5
|
+
* Add support for the manifest post-provisioner (via [arothian])
|
6
|
+
* Fix broken test and development environments
|
7
|
+
* Fix broken integration test, update to CentOS 7
|
8
|
+
* Minimum Ruby version updated to 2.4.0
|
9
|
+
* Minimum Packer version updated to 1.0.0
|
10
|
+
|
3
11
|
## 1.6.3
|
4
12
|
|
5
13
|
* Add support for the shell-local provisioner (via [shinitiandrei])
|
@@ -70,3 +78,4 @@
|
|
70
78
|
[enzor]: https://github.com/enzor
|
71
79
|
[biemond]: https://github.com/biemond
|
72
80
|
[shinitiandrei]: https://github.com/shinitiandrei
|
81
|
+
[arothian]: https://github.com/arothian
|
data/lib/packer-config.rb
CHANGED
@@ -21,7 +21,7 @@ module Packer
|
|
21
21
|
attr_reader :envvar
|
22
22
|
attr_reader :output_file
|
23
23
|
|
24
|
-
PACKER_VERSION = '0.
|
24
|
+
PACKER_VERSION = '1.0.0'
|
25
25
|
|
26
26
|
def initialize(file)
|
27
27
|
super()
|
@@ -42,6 +42,7 @@ module Packer
|
|
42
42
|
if self.builders.empty?
|
43
43
|
raise DataValidationError.new("At least one builder is required")
|
44
44
|
end
|
45
|
+
|
45
46
|
self.builders.each(&:validate)
|
46
47
|
self.provisioners.each(&:validate)
|
47
48
|
self.postprocessors.each(&:validate)
|
@@ -156,6 +157,7 @@ module Packer
|
|
156
157
|
unless self.variables.key? name
|
157
158
|
raise UndefinedVariableError.new("No variable named #{name} has been defined -- did you forget to call add_variable?")
|
158
159
|
end
|
160
|
+
|
159
161
|
"{{user `#{name}`}}"
|
160
162
|
end
|
161
163
|
|
data/lib/packer/builder.rb
CHANGED
@@ -30,6 +30,7 @@ module Packer
|
|
30
30
|
unless validate_type(type)
|
31
31
|
raise UnrecognizedBuilderTypeError.new("Unrecognized builder type #{type}")
|
32
32
|
end
|
33
|
+
|
33
34
|
{
|
34
35
|
AMAZON_EBS => Packer::Builder::Amazon::EBS,
|
35
36
|
AMAZON_INSTANCE => Packer::Builder::Amazon::Instance,
|
@@ -63,6 +64,7 @@ module Packer
|
|
63
64
|
# See: https://packer.io/docs/templates/communicator.html
|
64
65
|
def communicator(comm)
|
65
66
|
raise(DataValidationError, "unknown communicator protocol #{comm}") unless communicators.include? comm
|
67
|
+
|
66
68
|
self.__add_string('communicator', comm)
|
67
69
|
end
|
68
70
|
|
data/lib/packer/dataobject.rb
CHANGED
@@ -75,15 +75,18 @@ module Packer
|
|
75
75
|
def __add_array_of_strings(key, values, exclusives = [])
|
76
76
|
self.__exclusive_key_error(key, exclusives)
|
77
77
|
raise TypeError.new() unless Array.try_convert(values)
|
78
|
+
|
78
79
|
self.data[key.to_s] = values.to_ary.map(&:to_s)
|
79
80
|
end
|
80
81
|
|
81
82
|
def __add_array_of_array_of_strings(key, values, exclusives = [])
|
82
83
|
self.__exclusive_key_error(key, exclusives)
|
83
84
|
raise TypeError.new() unless Array.try_convert(values)
|
85
|
+
|
84
86
|
self.data[key.to_s] = []
|
85
87
|
values.each do |v|
|
86
88
|
raise TypeError.new() unless Array.try_convert(v)
|
89
|
+
|
87
90
|
self.data[key.to_s].push(v.to_ary.map(&:to_s))
|
88
91
|
end
|
89
92
|
end
|
@@ -91,9 +94,11 @@ module Packer
|
|
91
94
|
def __add_array_of_hashes(key, values, exclusives = [])
|
92
95
|
self.__exclusive_key_error(key, exclusives)
|
93
96
|
raise TypeError.new() unless Array.try_convert(values)
|
97
|
+
|
94
98
|
self.data[key.to_s] = []
|
95
99
|
values.each do |v|
|
96
100
|
raise TypeError.new() unless v.is_a?(Hash)
|
101
|
+
|
97
102
|
self.data[key.to_s].push({})
|
98
103
|
v.keys.each do |k|
|
99
104
|
self.data[key.to_s][-1][k] = v[k].to_s
|
@@ -104,6 +109,7 @@ module Packer
|
|
104
109
|
def __add_array_of_ints(key, values, exclusives = [])
|
105
110
|
self.__exclusive_key_error(key, exclusives)
|
106
111
|
raise TypeError.new() unless Array.try_convert(values)
|
112
|
+
|
107
113
|
self.data[key.to_s] = values.to_ary.map(&:to_i)
|
108
114
|
end
|
109
115
|
|
@@ -126,6 +132,7 @@ module Packer
|
|
126
132
|
def __add_hash(key, data, exclusives = [])
|
127
133
|
self.__exclusive_key_error(key, exclusives)
|
128
134
|
raise TypeError.new() unless data.is_a?(Hash)
|
135
|
+
|
129
136
|
self.data[key.to_s] = {}
|
130
137
|
data.keys.each do |k|
|
131
138
|
self.data[key.to_s][k] = data[k].to_s
|
@@ -136,6 +143,7 @@ module Packer
|
|
136
143
|
def __add_json(key, data, exclusives = [])
|
137
144
|
self.__exclusive_key_error(key, exclusives)
|
138
145
|
raise TypeError.new() unless data.is_a?(Hash)
|
146
|
+
|
139
147
|
self.data[key.to_s] = {}
|
140
148
|
data.keys.each do |k|
|
141
149
|
self.data[key.to_s][k] = data[k]
|
data/lib/packer/postprocessor.rb
CHANGED
@@ -11,6 +11,7 @@ module Packer
|
|
11
11
|
VAGRANT = 'vagrant'
|
12
12
|
COMPRESS = 'compress'
|
13
13
|
SHELL_LOCAL = 'shell-local'
|
14
|
+
MANIFEST = 'manifest'
|
14
15
|
|
15
16
|
VALID_POST_PROCESSOR_TYPES = [
|
16
17
|
DOCKER_IMPORT,
|
@@ -19,7 +20,8 @@ module Packer
|
|
19
20
|
DOCKER_TAG,
|
20
21
|
COMPRESS,
|
21
22
|
VAGRANT,
|
22
|
-
SHELL_LOCAL
|
23
|
+
SHELL_LOCAL,
|
24
|
+
MANIFEST
|
23
25
|
]
|
24
26
|
|
25
27
|
class UnrecognizedPostProcessorTypeError < StandardError
|
@@ -29,6 +31,7 @@ module Packer
|
|
29
31
|
unless validate_type(type)
|
30
32
|
raise UnrecognizedPostProcessorTypeError.new("Unrecognized post-processor type #{type}")
|
31
33
|
end
|
34
|
+
|
32
35
|
{
|
33
36
|
DOCKER_IMPORT => Packer::PostProcessor::DockerImport,
|
34
37
|
DOCKER_PUSH => Packer::PostProcessor::DockerPush,
|
@@ -36,7 +39,8 @@ module Packer
|
|
36
39
|
DOCKER_TAG => Packer::PostProcessor::DockerTag,
|
37
40
|
COMPRESS => Packer::PostProcessor::Compress,
|
38
41
|
SHELL_LOCAL => Packer::PostProcessor::ShellLocal,
|
39
|
-
VAGRANT => Packer::PostProcessor::Vagrant
|
42
|
+
VAGRANT => Packer::PostProcessor::Vagrant,
|
43
|
+
MANIFEST => Packer::PostProcessor::Manifest
|
40
44
|
}.fetch(type).new
|
41
45
|
end
|
42
46
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Encoding: utf-8
|
2
|
+
require 'packer/postprocessor'
|
3
|
+
require 'packer/dataobject'
|
4
|
+
|
5
|
+
module Packer
|
6
|
+
class PostProcessor < Packer::DataObject
|
7
|
+
class Manifest < PostProcessor
|
8
|
+
def initialize
|
9
|
+
super
|
10
|
+
self.data['type'] = MANIFEST
|
11
|
+
end
|
12
|
+
|
13
|
+
def output(file)
|
14
|
+
self.__add_string('output', file)
|
15
|
+
end
|
16
|
+
|
17
|
+
def strip_path(bool)
|
18
|
+
self.__add_boolean('strip_path', bool)
|
19
|
+
end
|
20
|
+
|
21
|
+
def custom_data(data)
|
22
|
+
self.__add_hash('custom_data', data)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/packer/provisioner.rb
CHANGED
@@ -37,6 +37,7 @@ module Packer
|
|
37
37
|
unless validate_type(type)
|
38
38
|
raise UnrecognizedProvisionerTypeError.new("Unrecognized provisioner type #{type}")
|
39
39
|
end
|
40
|
+
|
40
41
|
{
|
41
42
|
SHELL => Packer::Provisioner::Shell,
|
42
43
|
WINDOWS_SHELL => Packer::Provisioner::WindowsShell,
|
@@ -81,6 +82,7 @@ module Packer
|
|
81
82
|
|
82
83
|
def override(builddefinition, values)
|
83
84
|
raise TypeError.new() unless values.is_a?(Hash)
|
85
|
+
|
84
86
|
unless self.data.key? 'override'
|
85
87
|
self.data['override'] = {}
|
86
88
|
end
|
data/lib/packer/runner.rb
CHANGED
data/lib/packer/version.rb
CHANGED
data/packer-config.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'packer/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'packer-config'
|
8
8
|
spec.version = Packer::VERSION
|
9
|
-
spec.authors = ["Ian Chesal", "Fraser Cobb", "Greg Poirier", "Matasano Security", "Greg Diamond", "Enzo Rivello", "Edwin Biemond", "Andrei Shiniti Nakagawa"]
|
9
|
+
spec.authors = ["Ian Chesal", "Fraser Cobb", "Greg Poirier", "Matasano Security", "Greg Diamond", "Enzo Rivello", "Edwin Biemond", "Andrei Shiniti Nakagawa", "Kevin Formsma"]
|
10
10
|
spec.email = %w(ian.chesal@gmail.com)
|
11
11
|
spec.summary = 'An object model to build packer.io configurations in Ruby.'
|
12
12
|
spec.description = <<-END
|
@@ -19,7 +19,7 @@ syntax for referencing variables and whatnot in the JSON.
|
|
19
19
|
END
|
20
20
|
spec.homepage = 'https://github.com/ianchesal/packer-config'
|
21
21
|
spec.license = 'Apache-2.0'
|
22
|
-
spec.required_ruby_version = '>= 2.
|
22
|
+
spec.required_ruby_version = '>= 2.4.0'
|
23
23
|
|
24
24
|
spec.files = `git ls-files -z`.split("\x0")
|
25
25
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
@@ -2,12 +2,13 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
RSpec.describe Packer::Config do
|
5
|
-
it 'can build a centos-
|
6
|
-
CENTOS_VERSION = '
|
5
|
+
it 'can build a centos-7 Vagrant base box' do
|
6
|
+
CENTOS_VERSION = '7'
|
7
7
|
|
8
8
|
pconfig = Packer::Config.new "centos-#{CENTOS_VERSION}-vagrant.json"
|
9
9
|
pconfig.description "CentOS #{CENTOS_VERSION} VirtualBox Vagrant"
|
10
|
-
pconfig.add_variable 'mirror', 'http://mirrors.sonic.net/centos
|
10
|
+
pconfig.add_variable 'mirror', 'http://mirrors.sonic.net/centos'
|
11
|
+
pconfig.add_variable 'mirror', 'http://ftp.pbone.net/pub/centos'
|
11
12
|
pconfig.add_variable 'my_version', '0.0.1'
|
12
13
|
pconfig.add_variable 'chef_version', 'latest'
|
13
14
|
|
@@ -18,9 +19,9 @@ RSpec.describe Packer::Config do
|
|
18
19
|
builder.guest_additions_path "VBoxGuestAdditions_#{pconfig.macro.Version}.iso"
|
19
20
|
builder.guest_os_type "RedHat_64"
|
20
21
|
builder.http_directory "scripts/kickstart"
|
21
|
-
builder.iso_checksum '
|
22
|
-
builder.iso_checksum_type '
|
23
|
-
builder.iso_url "#{pconfig.variable 'mirror'}/
|
22
|
+
builder.iso_checksum '38d5d51d9d100fd73df031ffd6bd8b1297ce24660dc8c13a3b8b4534a4bd291c'
|
23
|
+
builder.iso_checksum_type 'sha256'
|
24
|
+
builder.iso_url "#{pconfig.variable 'mirror'}/#{CENTOS_VERSION}/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso"
|
24
25
|
builder.output_directory "centos-#{CENTOS_VERSION}-x86_64-virtualbox"
|
25
26
|
builder.shutdown_command "echo 'vagrant'|sudo -S /sbin/halt -h -p"
|
26
27
|
builder.communicator "ssh"
|
@@ -51,13 +52,8 @@ RSpec.describe Packer::Config do
|
|
51
52
|
|
52
53
|
provisioner = pconfig.add_provisioner Packer::Provisioner::SHELL
|
53
54
|
provisioner.scripts [
|
54
|
-
'scripts/fix-slow-dns.sh',
|
55
55
|
'scripts/sshd.sh',
|
56
|
-
'scripts/vagrant.sh'
|
57
|
-
'scripts/vmtools.sh',
|
58
|
-
'scripts/chef.sh',
|
59
|
-
'scripts/cleanup.sh',
|
60
|
-
'scripts/minimize.sh'
|
56
|
+
'scripts/vagrant.sh'
|
61
57
|
]
|
62
58
|
provisioner.environment_vars [
|
63
59
|
"CHEF_VERSION=#{pconfig.variable 'chef_version'}",
|
@@ -0,0 +1,98 @@
|
|
1
|
+
install
|
2
|
+
cdrom
|
3
|
+
lang en_US.UTF-8
|
4
|
+
keyboard us
|
5
|
+
network --bootproto=dhcp --onboot=on --device=eth0
|
6
|
+
rootpw vagrant
|
7
|
+
firewall --disabled
|
8
|
+
selinux --permissive
|
9
|
+
timezone UTC
|
10
|
+
unsupported_hardware
|
11
|
+
bootloader --location=mbr --append="net.ifnames=0 biosdevname=0"
|
12
|
+
text
|
13
|
+
skipx
|
14
|
+
zerombr
|
15
|
+
clearpart --all --initlabel
|
16
|
+
autopart
|
17
|
+
auth --enableshadow --passalgo=sha512 --kickstart
|
18
|
+
firstboot --disabled
|
19
|
+
reboot --eject
|
20
|
+
user --name=vagrant --plaintext --password vagrant
|
21
|
+
|
22
|
+
%packages --nobase --ignoremissing --excludedocs --instLangs=en_US.utf8
|
23
|
+
# vagrant needs this to copy initial files via scp
|
24
|
+
openssh-clients
|
25
|
+
sudo
|
26
|
+
kernel-headers
|
27
|
+
kernel-devel
|
28
|
+
gcc
|
29
|
+
make
|
30
|
+
perl
|
31
|
+
selinux-policy-devel
|
32
|
+
wget
|
33
|
+
nfs-utils
|
34
|
+
net-tools
|
35
|
+
bzip2
|
36
|
+
deltarpm
|
37
|
+
-fprintd-pam
|
38
|
+
-intltool
|
39
|
+
|
40
|
+
# unnecessary firmware
|
41
|
+
-aic94xx-firmware
|
42
|
+
-alsa-firmware
|
43
|
+
-alsa-tools-firmware
|
44
|
+
-ivtv-firmware
|
45
|
+
-iwl100-firmware
|
46
|
+
-iwl105-firmware
|
47
|
+
-iwl135-firmware
|
48
|
+
-iwl1000-firmware
|
49
|
+
-iwl2000-firmware
|
50
|
+
-iwl2030-firmware
|
51
|
+
-iwl3160-firmware
|
52
|
+
-iwl3945-firmware
|
53
|
+
-iwl4965-firmware
|
54
|
+
-iwl5000-firmware
|
55
|
+
-iwl5150-firmware
|
56
|
+
-iwl6000-firmware
|
57
|
+
-iwl6000g2a-firmware
|
58
|
+
-iwl6000g2b-firmware
|
59
|
+
-iwl6050-firmware
|
60
|
+
-iwl7260-firmware
|
61
|
+
-iwl7265-firmware
|
62
|
+
%end
|
63
|
+
|
64
|
+
%post
|
65
|
+
# sudo
|
66
|
+
echo "%vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant
|
67
|
+
chmod 0440 /etc/sudoers.d/vagrant
|
68
|
+
|
69
|
+
#Enable hyper-v daemons only if using hyper-v virtualization
|
70
|
+
if [ $(virt-what) == "hyperv" ]; then
|
71
|
+
yum -y install hyperv-daemons cifs-utils
|
72
|
+
systemctl enable hypervvssd
|
73
|
+
systemctl enable hypervkvpd
|
74
|
+
fi
|
75
|
+
|
76
|
+
# Since we disable consistent network naming, we need to make sure the eth0
|
77
|
+
# configuration file is in place so it will come up.
|
78
|
+
# Delete other network configuration first because RHEL/C7 networking will not
|
79
|
+
# restart successfully if there are configuration files for devices that do not
|
80
|
+
# exist.
|
81
|
+
rm -f /etc/sysconfig/network-scripts/ifcfg-e*
|
82
|
+
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << _EOF_
|
83
|
+
TYPE=Ethernet
|
84
|
+
PROXY_METHOD=none
|
85
|
+
BROWSER_ONLY=no
|
86
|
+
BOOTPROTO=dhcp
|
87
|
+
DEFROUTE=yes
|
88
|
+
IPV4_FAILURE_FATAL=no
|
89
|
+
IPV6INIT=yes
|
90
|
+
IPV6_AUTOCONF=yes
|
91
|
+
IPV6_DEFROUTE=yes
|
92
|
+
IPV6_FAILURE_FATAL=no
|
93
|
+
IPV6_ADDR_GEN_MODE=stable-privacy
|
94
|
+
NAME=eth0
|
95
|
+
DEVICE=eth0
|
96
|
+
ONBOOT=yes
|
97
|
+
_EOF_
|
98
|
+
%end
|
@@ -2,8 +2,37 @@
|
|
2
2
|
|
3
3
|
# From: https://github.com/opscode/bento
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
case "$PACKER_BUILDER_TYPE" in
|
6
|
+
qemu) exit 0 ;;
|
7
|
+
esac
|
8
|
+
|
9
|
+
# Whiteout root
|
10
|
+
count=$(df --sync -kP / | tail -n1 | awk -F ' ' '{print $4}')
|
11
|
+
count=$(($count-1))
|
12
|
+
dd if=/dev/zero of=/tmp/whitespace bs=1M count=$count || echo "dd exit code $? is suppressed";
|
13
|
+
rm /tmp/whitespace
|
14
|
+
|
15
|
+
# Whiteout /boot
|
16
|
+
count=$(df --sync -kP /boot | tail -n1 | awk -F ' ' '{print $4}')
|
17
|
+
count=$(($count-1))
|
18
|
+
dd if=/dev/zero of=/boot/whitespace bs=1M count=$count || echo "dd exit code $? is suppressed";
|
19
|
+
rm /boot/whitespace
|
20
|
+
|
21
|
+
set +e
|
22
|
+
swapuuid="`/sbin/blkid -o value -l -s UUID -t TYPE=swap`";
|
23
|
+
case "$?" in
|
24
|
+
2|0) ;;
|
25
|
+
*) exit 1 ;;
|
26
|
+
esac
|
27
|
+
set -e
|
28
|
+
|
29
|
+
if [ "x${swapuuid}" != "x" ]; then
|
30
|
+
# Whiteout the swap partition to reduce box size
|
31
|
+
# Swap is disabled till reboot
|
32
|
+
swappart="`readlink -f /dev/disk/by-uuid/$swapuuid`";
|
33
|
+
/sbin/swapoff "$swappart";
|
34
|
+
dd if=/dev/zero of="$swappart" bs=1M || echo "dd exit code $? is suppressed";
|
35
|
+
/sbin/mkswap -U "$swapuuid" "$swappart";
|
36
|
+
fi
|
37
|
+
|
38
|
+
sync;
|
@@ -2,5 +2,21 @@
|
|
2
2
|
|
3
3
|
# From: https://github.com/opscode/bento
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
SSHD_CONFIG="/etc/ssh/sshd_config"
|
6
|
+
|
7
|
+
# ensure that there is a trailing newline before attempting to concatenate
|
8
|
+
sed -i -e '$a\' "$SSHD_CONFIG"
|
9
|
+
|
10
|
+
USEDNS="UseDNS no"
|
11
|
+
if grep -q -E "^[[:space:]]*UseDNS" "$SSHD_CONFIG"; then
|
12
|
+
sed -i "s/^\s*UseDNS.*/${USEDNS}/" "$SSHD_CONFIG"
|
13
|
+
else
|
14
|
+
echo "$USEDNS" >>"$SSHD_CONFIG"
|
15
|
+
fi
|
16
|
+
|
17
|
+
GSSAPI="GSSAPIAuthentication no"
|
18
|
+
if grep -q -E "^[[:space:]]*GSSAPIAuthentication" "$SSHD_CONFIG"; then
|
19
|
+
sed -i "s/^\s*GSSAPIAuthentication.*/${GSSAPI}/" "$SSHD_CONFIG"
|
20
|
+
else
|
21
|
+
echo "$GSSAPI" >>"$SSHD_CONFIG"
|
22
|
+
fi
|
@@ -2,9 +2,20 @@
|
|
2
2
|
|
3
3
|
# From: https://github.com/opscode/bento
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
# set a default HOME_DIR environment variable if not set
|
6
|
+
HOME_DIR="${HOME_DIR:-/home/vagrant}";
|
7
|
+
|
8
|
+
pubkey_url="https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub";
|
9
|
+
mkdir -p $HOME_DIR/.ssh;
|
10
|
+
if command -v wget >/dev/null 2>&1; then
|
11
|
+
wget --no-check-certificate "$pubkey_url" -O $HOME_DIR/.ssh/authorized_keys;
|
12
|
+
elif command -v curl >/dev/null 2>&1; then
|
13
|
+
curl --insecure --location "$pubkey_url" > $HOME_DIR/.ssh/authorized_keys;
|
14
|
+
elif command -v fetch >/dev/null 2>&1; then
|
15
|
+
fetch -am -o $HOME_DIR/.ssh/authorized_keys "$pubkey_url";
|
16
|
+
else
|
17
|
+
echo "Cannot download vagrant public key";
|
18
|
+
exit 1;
|
19
|
+
fi
|
20
|
+
chown -R vagrant $HOME_DIR/.ssh;
|
21
|
+
chmod -R go-rwsx $HOME_DIR/.ssh;
|
@@ -2,38 +2,20 @@
|
|
2
2
|
|
3
3
|
# From: https://github.com/opscode/bento
|
4
4
|
|
5
|
-
|
5
|
+
# set a default HOME_DIR environment variable if not set
|
6
|
+
HOME_DIR="${HOME_DIR:-/home/vagrant}";
|
6
7
|
|
8
|
+
case "$PACKER_BUILDER_TYPE" in
|
7
9
|
virtualbox-iso|virtualbox-ovf)
|
8
|
-
|
9
|
-
VER
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
umount /tmp/vbox
|
16
|
-
|
17
|
-
rm
|
18
|
-
chkconfig --add /etc/init.d/vboxadd
|
19
|
-
chkconfig --level 345 vboxadd on
|
20
|
-
;;
|
21
|
-
|
22
|
-
vmware-iso|vmware-ovf)
|
23
|
-
mkdir /tmp/vmfusion
|
24
|
-
mkdir /tmp/vmfusion-archive
|
25
|
-
mount -o loop /home/vagrant/linux.iso /tmp/vmfusion
|
26
|
-
tar xzf /tmp/vmfusion/VMwareTools-*.tar.gz -C /tmp/vmfusion-archive
|
27
|
-
/tmp/vmfusion-archive/vmware-tools-distrib/vmware-install.pl --default
|
28
|
-
umount /tmp/vmfusion
|
29
|
-
rm -rf /tmp/vmfusion
|
30
|
-
rm -rf /tmp/vmfusion-archive
|
31
|
-
rm /home/vagrant/*.iso
|
10
|
+
VER="`cat $HOME_DIR/.vbox_version`";
|
11
|
+
ISO="VBoxGuestAdditions_$VER.iso";
|
12
|
+
mkdir -p /tmp/vbox;
|
13
|
+
mount -o loop $HOME_DIR/$ISO /tmp/vbox;
|
14
|
+
sh /tmp/vbox/VBoxLinuxAdditions.run \
|
15
|
+
|| echo "VBoxLinuxAdditions.run exited $? and is suppressed." \
|
16
|
+
"For more read https://www.virtualbox.org/ticket/12479";
|
17
|
+
umount /tmp/vbox;
|
18
|
+
rm -rf /tmp/vbox;
|
19
|
+
rm -f $HOME_DIR/*.iso;
|
32
20
|
;;
|
33
|
-
|
34
|
-
*)
|
35
|
-
echo "Unknown Packer Builder Type >>$PACKER_BUILDER_TYPE<< selected."
|
36
|
-
echo "Known are virtualbox-iso|virtualbox-ovf|vmware-iso|vmware-ovf."
|
37
|
-
;;
|
38
|
-
|
39
21
|
esac
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# Encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
RSpec.describe Packer::PostProcessor::Manifest do
|
5
|
+
let(:postprocessor) do
|
6
|
+
Packer::PostProcessor.get_postprocessor(Packer::PostProcessor::MANIFEST)
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:some_string) do
|
10
|
+
'some string'
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:some_array_of_ints) do
|
14
|
+
[1, 2, 3]
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:hash_of_strings) do
|
18
|
+
{
|
19
|
+
my_custom_data: 'example',
|
20
|
+
my_other_data: 'hidden'
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#initialize' do
|
25
|
+
it 'has a type of manifest' do
|
26
|
+
expect(postprocessor.data['type']).to eq(Packer::PostProcessor::MANIFEST)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#output' do
|
31
|
+
it 'accepts a string' do
|
32
|
+
postprocessor.output(some_string)
|
33
|
+
expect(postprocessor.data['output']).to eq(some_string)
|
34
|
+
postprocessor.data.delete('output')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'converts any argument passed to a string' do
|
38
|
+
postprocessor.output(some_array_of_ints)
|
39
|
+
expect(postprocessor.data['output']).to eq(some_array_of_ints.to_s)
|
40
|
+
postprocessor.data.delete('output')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#strip_path' do
|
45
|
+
it 'accepts any truthy value and converts it to true' do
|
46
|
+
postprocessor.strip_path('this is true')
|
47
|
+
expect(postprocessor.data['strip_path']).to be_truthy
|
48
|
+
postprocessor.data.delete('strip_path')
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'accepts any non-truthy value and converts it to false' do
|
52
|
+
postprocessor.strip_path(false)
|
53
|
+
expect(postprocessor.data['strip_path']).to be_falsey
|
54
|
+
postprocessor.data.delete('strip_path')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#custom_data' do
|
59
|
+
it 'adds a hash of strings to the key' do
|
60
|
+
postprocessor.custom_data(hash_of_strings)
|
61
|
+
expect(postprocessor.data['custom_data']).to eq(hash_of_strings)
|
62
|
+
postprocessor.data.delete('custom_data')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
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.
|
4
|
+
version: 1.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Chesal
|
@@ -12,10 +12,11 @@ authors:
|
|
12
12
|
- Enzo Rivello
|
13
13
|
- Edwin Biemond
|
14
14
|
- Andrei Shiniti Nakagawa
|
15
|
+
- Kevin Formsma
|
15
16
|
autorequire:
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
|
-
date:
|
19
|
+
date: 2019-05-04 00:00:00.000000000 Z
|
19
20
|
dependencies: []
|
20
21
|
description: |
|
21
22
|
Building the Packer JSON configurations in raw JSON can be quite an adventure.
|
@@ -59,6 +60,7 @@ files:
|
|
59
60
|
- lib/packer/postprocessors/all.rb
|
60
61
|
- lib/packer/postprocessors/compress.rb
|
61
62
|
- lib/packer/postprocessors/docker.rb
|
63
|
+
- lib/packer/postprocessors/manifest.rb
|
62
64
|
- lib/packer/postprocessors/shell-local.rb
|
63
65
|
- lib/packer/postprocessors/vagrant.rb
|
64
66
|
- lib/packer/provisioner.rb
|
@@ -85,7 +87,7 @@ files:
|
|
85
87
|
- spec/integration/scripts/cleanup.sh
|
86
88
|
- spec/integration/scripts/fix-slow-dns.sh
|
87
89
|
- spec/integration/scripts/hello.sh
|
88
|
-
- spec/integration/scripts/kickstart/centos-
|
90
|
+
- spec/integration/scripts/kickstart/centos-7-ks.cfg
|
89
91
|
- spec/integration/scripts/minimize.sh
|
90
92
|
- spec/integration/scripts/sshd.sh
|
91
93
|
- spec/integration/scripts/vagrant.sh
|
@@ -106,6 +108,7 @@ files:
|
|
106
108
|
- spec/packer/postprocessors/docker_push_spec.rb
|
107
109
|
- spec/packer/postprocessors/docker_save_spec.rb
|
108
110
|
- spec/packer/postprocessors/docker_tag_spec.rb
|
111
|
+
- spec/packer/postprocessors/manifest_spec.rb
|
109
112
|
- spec/packer/postprocessors/shell_local_spec.rb
|
110
113
|
- spec/packer/postprocessors/vagrant_spec.rb
|
111
114
|
- spec/packer/provisioner_spec.rb
|
@@ -140,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
140
143
|
requirements:
|
141
144
|
- - ">="
|
142
145
|
- !ruby/object:Gem::Version
|
143
|
-
version: 2.
|
146
|
+
version: 2.4.0
|
144
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
148
|
requirements:
|
146
149
|
- - ">="
|
@@ -148,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
151
|
version: '0'
|
149
152
|
requirements: []
|
150
153
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.6.
|
154
|
+
rubygems_version: 2.6.14.1
|
152
155
|
signing_key:
|
153
156
|
specification_version: 4
|
154
157
|
summary: An object model to build packer.io configurations in Ruby.
|
@@ -161,7 +164,7 @@ test_files:
|
|
161
164
|
- spec/integration/scripts/cleanup.sh
|
162
165
|
- spec/integration/scripts/fix-slow-dns.sh
|
163
166
|
- spec/integration/scripts/hello.sh
|
164
|
-
- spec/integration/scripts/kickstart/centos-
|
167
|
+
- spec/integration/scripts/kickstart/centos-7-ks.cfg
|
165
168
|
- spec/integration/scripts/minimize.sh
|
166
169
|
- spec/integration/scripts/sshd.sh
|
167
170
|
- spec/integration/scripts/vagrant.sh
|
@@ -182,6 +185,7 @@ test_files:
|
|
182
185
|
- spec/packer/postprocessors/docker_push_spec.rb
|
183
186
|
- spec/packer/postprocessors/docker_save_spec.rb
|
184
187
|
- spec/packer/postprocessors/docker_tag_spec.rb
|
188
|
+
- spec/packer/postprocessors/manifest_spec.rb
|
185
189
|
- spec/packer/postprocessors/shell_local_spec.rb
|
186
190
|
- spec/packer/postprocessors/vagrant_spec.rb
|
187
191
|
- spec/packer/provisioner_spec.rb
|
@@ -1,71 +0,0 @@
|
|
1
|
-
install
|
2
|
-
cdrom
|
3
|
-
lang en_US.UTF-8
|
4
|
-
keyboard us
|
5
|
-
network --bootproto=dhcp
|
6
|
-
rootpw vagrant
|
7
|
-
firewall --disabled
|
8
|
-
selinux --permissive
|
9
|
-
timezone UTC
|
10
|
-
unsupported_hardware
|
11
|
-
bootloader --location=mbr
|
12
|
-
text
|
13
|
-
skipx
|
14
|
-
zerombr
|
15
|
-
clearpart --all --initlabel
|
16
|
-
autopart
|
17
|
-
auth --enableshadow --passalgo=sha512 --kickstart
|
18
|
-
firstboot --disabled
|
19
|
-
reboot
|
20
|
-
user --name=vagrant --plaintext --password vagrant
|
21
|
-
|
22
|
-
%packages --nobase --ignoremissing --excludedocs
|
23
|
-
# vagrant needs this to copy initial files via scp
|
24
|
-
openssh-clients
|
25
|
-
sudo
|
26
|
-
kernel-headers
|
27
|
-
kernel-devel
|
28
|
-
gcc
|
29
|
-
make
|
30
|
-
perl
|
31
|
-
curl
|
32
|
-
wget
|
33
|
-
nfs-utils
|
34
|
-
man
|
35
|
-
-fprintd-pam
|
36
|
-
-intltool
|
37
|
-
|
38
|
-
# unnecessary firmware
|
39
|
-
-aic94xx-firmware
|
40
|
-
-atmel-firmware
|
41
|
-
-b43-openfwwf
|
42
|
-
-bfa-firmware
|
43
|
-
-ipw2100-firmware
|
44
|
-
-ipw2200-firmware
|
45
|
-
-ivtv-firmware
|
46
|
-
-iwl100-firmware
|
47
|
-
-iwl1000-firmware
|
48
|
-
-iwl3945-firmware
|
49
|
-
-iwl4965-firmware
|
50
|
-
-iwl5000-firmware
|
51
|
-
-iwl5150-firmware
|
52
|
-
-iwl6000-firmware
|
53
|
-
-iwl6000g2a-firmware
|
54
|
-
-iwl6050-firmware
|
55
|
-
-libertas-usb8388-firmware
|
56
|
-
-ql2100-firmware
|
57
|
-
-ql2200-firmware
|
58
|
-
-ql23xx-firmware
|
59
|
-
-ql2400-firmware
|
60
|
-
-ql2500-firmware
|
61
|
-
-rt61pci-firmware
|
62
|
-
-rt73usb-firmware
|
63
|
-
-xorg-x11-drv-ati-firmware
|
64
|
-
-zd1211-firmware
|
65
|
-
|
66
|
-
%post
|
67
|
-
# update root certs
|
68
|
-
wget -O/etc/pki/tls/certs/ca-bundle.crt http://curl.haxx.se/ca/cacert.pem
|
69
|
-
# sudo
|
70
|
-
echo "%vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant
|
71
|
-
sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
|