packer-config 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +2 -0
  4. data/COPYRIGHT +10 -0
  5. data/Gemfile +0 -14
  6. data/README.md +20 -9
  7. data/RELEASENOTES.md +8 -0
  8. data/Rakefile +0 -14
  9. data/lib/packer-config.rb +1 -14
  10. data/lib/packer/builder.rb +5 -15
  11. data/lib/packer/builders/all.rb +2 -14
  12. data/lib/packer/builders/amazon.rb +0 -13
  13. data/lib/packer/builders/docker.rb +1 -14
  14. data/lib/packer/builders/null.rb +40 -0
  15. data/lib/packer/builders/virtualbox.rb +1 -14
  16. data/lib/packer/dataobject.rb +0 -14
  17. data/lib/packer/envvar.rb +1 -15
  18. data/lib/packer/macro.rb +1 -15
  19. data/lib/packer/postprocessor.rb +0 -13
  20. data/lib/packer/postprocessors/all.rb +1 -14
  21. data/lib/packer/postprocessors/docker.rb +1 -14
  22. data/lib/packer/postprocessors/vagrant.rb +1 -14
  23. data/lib/packer/provisioner.rb +24 -19
  24. data/lib/packer/provisioners/all.rb +7 -14
  25. data/lib/packer/provisioners/ansible.rb +55 -0
  26. data/lib/packer/provisioners/chef/client.rb +75 -0
  27. data/lib/packer/provisioners/chef/solo.rb +67 -0
  28. data/lib/packer/provisioners/file.rb +1 -14
  29. data/lib/packer/provisioners/puppet/masterless.rb +48 -0
  30. data/lib/packer/provisioners/puppet/server.rb +47 -0
  31. data/lib/packer/provisioners/salt.rb +39 -0
  32. data/lib/packer/provisioners/shell.rb +1 -14
  33. data/packer-config.gemspec +4 -17
  34. data/spec/integration/centos_vagrant_spec.rb +4 -4
  35. data/spec/packer/builder_spec.rb +1 -14
  36. data/spec/packer/builders/amazon_spec.rb +1 -14
  37. data/spec/packer/builders/docker_spec.rb +1 -14
  38. data/spec/packer/builders/null_spec.rb +25 -0
  39. data/spec/packer/builders/virtualbox_spec.rb +1 -14
  40. data/spec/packer/dataobject_spec.rb +0 -13
  41. data/spec/packer/envvar_spec.rb +1 -14
  42. data/spec/packer/macro_spec.rb +1 -14
  43. data/spec/packer/postprocessor_spec.rb +1 -14
  44. data/spec/packer/postprocessors/docker_import_spec.rb +1 -14
  45. data/spec/packer/postprocessors/docker_push_spec.rb +1 -14
  46. data/spec/packer/postprocessors/vagrant_spec.rb +1 -14
  47. data/spec/packer/provisioner_spec.rb +2 -15
  48. data/spec/packer/provisioners/ansible_spec.rb +48 -0
  49. data/spec/packer/provisioners/chef/client_spec.rb +66 -0
  50. data/spec/packer/provisioners/chef/solo_spec.rb +98 -0
  51. data/spec/packer/provisioners/file_spec.rb +1 -14
  52. data/spec/packer/provisioners/puppet/masterless_spec.rb +141 -0
  53. data/spec/packer/provisioners/puppet/server_spec.rb +137 -0
  54. data/spec/packer/provisioners/salt_spec.rb +114 -0
  55. data/spec/packer/provisioners/shell_spec.rb +1 -14
  56. data/spec/packer/runner_spec.rb +0 -13
  57. data/spec/packer_config_spec.rb +0 -13
  58. data/spec/spec_helper.rb +0 -13
  59. data/spec/unit_helper.rb +0 -13
  60. metadata +27 -4
@@ -0,0 +1,47 @@
1
+ require 'packer/provisioner'
2
+ require 'packer/dataobject'
3
+
4
+ module Packer
5
+ class Provisioner < Packer::DataObject
6
+ class Puppet < Provisioner
7
+ class Server < Puppet
8
+ def initialize
9
+ super
10
+ self.data['type'] = PUPPET_SERVER
11
+ end
12
+
13
+ def client_cert_path(path)
14
+ self.__add_string('client_cert_path', path)
15
+ end
16
+
17
+ def client_private_key_path(path)
18
+ self.__add_string('client_private_key_path', path)
19
+ end
20
+
21
+ def facter(facts)
22
+ self.__add_hash('facter', facts)
23
+ end
24
+
25
+ def options(opts)
26
+ self.__add_string('options', opts)
27
+ end
28
+
29
+ def prevent_sudo(flag)
30
+ self.__add_boolean('prevent_sudo', flag)
31
+ end
32
+
33
+ def puppet_node(nodename)
34
+ self.__add_string('puppet_node', nodename)
35
+ end
36
+
37
+ def puppet_server(servername)
38
+ self.__add_string('puppet_server', servername)
39
+ end
40
+
41
+ def staging_directory(dirname)
42
+ self.__add_string('staging_directory', dirname)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,39 @@
1
+ # Encoding: utf-8
2
+ require 'packer/provisioner'
3
+ require 'packer/dataobject'
4
+
5
+ module Packer
6
+ class Provisioner < Packer::DataObject
7
+ class Salt < Provisioner
8
+ def initialize
9
+ super
10
+ self.data['type'] = SALT
11
+ self.add_required(['local_state_tree'])
12
+ end
13
+
14
+ def bootstrap_args(args)
15
+ self.__add_string('bootstrap_args', args)
16
+ end
17
+
18
+ def local_pillar_roots(dirname)
19
+ self.__add_string('local_pillar_roots', dirname)
20
+ end
21
+
22
+ def local_state_tree(dirname)
23
+ self.__add_string('local_state_tree', dirname)
24
+ end
25
+
26
+ def minion_config(filename)
27
+ self.__add_string('minion_config', filename)
28
+ end
29
+
30
+ def temp_config_dir(dirname)
31
+ self.__add_string('temp_config_dir', dirname)
32
+ end
33
+
34
+ def skip_bootstrap(bool)
35
+ self.__add_boolean('skip_bootstrap', bool)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,17 +1,4 @@
1
1
  # Encoding: utf-8
2
- # Copyright 2014 Ian Chesal
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
2
  require 'packer/provisioner'
16
3
  require 'packer/dataobject'
17
4
 
@@ -57,4 +44,4 @@ module Packer
57
44
  end
58
45
  end
59
46
  end
60
- end
47
+ end
@@ -1,25 +1,11 @@
1
1
  # Encoding: utf-8
2
- # Copyright 2014 Ian Chesal
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
2
  Gem::Specification.new do |spec|
17
3
  spec.name = "packer-config"
18
- spec.version = "0.0.4"
4
+ spec.version = "1.0.0"
19
5
  # For deploying alpha versions via Travis CI
20
6
  spec.version = "#{spec.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
21
- spec.authors = ["Ian Chesal"]
22
- spec.email = ["ian.chesal@gmail.colm"]
7
+ spec.authors = ["Ian Chesal", "Fraser Cobb"]
8
+ spec.email = ["ian.chesal@gmail.com"]
23
9
  spec.summary = 'An object model to build packer.io configurations in Ruby.'
24
10
  spec.description = <<-END
25
11
  Building the Packer JSON configurations in raw JSON can be quite an adventure.
@@ -31,6 +17,7 @@ syntax for referencing variables and whatnot in the JSON.
31
17
  END
32
18
  spec.homepage = "https://github.com/ianchesal/packer-config"
33
19
  spec.license = "Apache 2.0"
20
+ spec.required_ruby_version = '>= 2.0.0'
34
21
 
35
22
  spec.files = `git ls-files -z`.split("\x0")
36
23
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -3,11 +3,11 @@ require 'spec_helper'
3
3
 
4
4
  RSpec.describe Packer::Config do
5
5
  it 'can build a centos-6.5 Vagrant base box' do
6
- OS = 'centos-6.5'
6
+ OS = 'centos-6.6'
7
7
 
8
8
  pconfig = Packer::Config.new "#{OS}-vagrant.json"
9
9
  pconfig.description "#{OS} VirtualBox Vagrant"
10
- pconfig.add_variable 'mirror', 'http://mirrors.kernel.org/centos'
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
 
@@ -18,9 +18,9 @@ RSpec.describe Packer::Config do
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 '32c7695b97f7dcd1f59a77a71f64f2957dddf738'
21
+ builder.iso_checksum '08be09fd7276822bd3468af8f96198279ffc41f0'
22
22
  builder.iso_checksum_type 'sha1'
23
- builder.iso_url "#{pconfig.variable 'mirror'}/6.5/isos/x86_64/CentOS-6.5-x86_64-bin-DVD1.iso"
23
+ builder.iso_url "#{pconfig.variable 'mirror'}/6.6/isos/x86_64/CentOS-6.6-x86_64-bin-DVD1.iso"
24
24
  builder.output_directory "#{OS}-x86_64-virtualbox"
25
25
  builder.shutdown_command "echo 'vagrant'|sudo -S /sbin/halt -h -p"
26
26
  builder.ssh_password "vagrant"
@@ -1,17 +1,4 @@
1
1
  # Encoding: utf-8
2
- # Copyright 2014 Ian Chesal
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
2
  require 'spec_helper'
16
3
 
17
4
  RSpec.describe Packer::Builder do
@@ -36,4 +23,4 @@ RSpec.describe Packer::Builder do
36
23
  builder.data.delete('name')
37
24
  end
38
25
  end
39
- end
26
+ end
@@ -1,17 +1,4 @@
1
1
  # Encoding: utf-8
2
- # Copyright 2014 Ian Chesal
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
2
  require 'spec_helper'
16
3
 
17
4
  RSpec.describe Packer::Builder::Amazon do
@@ -85,4 +72,4 @@ RSpec.describe Packer::Builder::Amazon::Instance do
85
72
  expect(builder.data['type']).to eq(Packer::Builder::AMAZON_INSTANCE)
86
73
  end
87
74
  end
88
- end
75
+ end
@@ -1,17 +1,4 @@
1
1
  # Encoding: utf-8
2
- # Copyright 2014 Ian Chesal
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
2
  require 'spec_helper'
16
3
 
17
4
  RSpec.describe Packer::Builder::Docker do
@@ -22,4 +9,4 @@ RSpec.describe Packer::Builder::Docker do
22
9
  expect(builder.data['type']).to eq(Packer::Builder::DOCKER)
23
10
  end
24
11
  end
25
- end
12
+ end
@@ -0,0 +1,25 @@
1
+ # Encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe Packer::Builder::Null do
5
+ let(:builder) { Packer::Builder.get_builder(Packer::Builder::NULL) }
6
+ let(:some_string) { 'some string' }
7
+
8
+ it 'requires a number of parameters to be valid' do
9
+ expect{ builder.validate }.to raise_error
10
+ builder.host :some_string
11
+ expect{ builder.validate }.to raise_error
12
+ builder.ssh_password :some_string
13
+ expect{ builder.validate }.to raise_error
14
+ builder.ssh_private_key_file :some_string
15
+ expect{ builder.validate }.to raise_error
16
+ builder.ssh_username :some_string
17
+ expect(builder.validate).to be_truthy
18
+ end
19
+
20
+ describe '#initialize' do
21
+ it 'has a type of null' do
22
+ expect(builder.data['type']).to eq(Packer::Builder::NULL)
23
+ end
24
+ end
25
+ end
@@ -1,17 +1,4 @@
1
1
  # Encoding: utf-8
2
- # Copyright 2014 Ian Chesal
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
2
  require 'spec_helper'
16
3
 
17
4
  RSpec.describe Packer::Builder::VirtualBoxISO do
@@ -41,4 +28,4 @@ RSpec.describe Packer::Builder::VirtualBoxISO do
41
28
  builder.data.delete('vboxmanage_post')
42
29
  end
43
30
  end
44
- end
31
+ end
@@ -1,17 +1,4 @@
1
1
  # Encoding: utf-8
2
- # Copyright 2014 Ian Chesal
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
2
  require 'spec_helper'
16
3
 
17
4
  RSpec.describe Packer::DataObject do
@@ -1,17 +1,4 @@
1
1
  # Encoding: utf-8
2
- # Copyright 2014 Ian Chesal
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
2
  require 'spec_helper'
16
3
 
17
4
  RSpec.describe Packer::EnvVar do
@@ -35,4 +22,4 @@ RSpec.describe Packer::EnvVar do
35
22
  expect(envvar.respond_to? 'anything').to be_truthy
36
23
  expect(envvar.respond_to? 'anything_else').to be_truthy
37
24
  end
38
- end
25
+ end
@@ -1,17 +1,4 @@
1
1
  # Encoding: utf-8
2
- # Copyright 2014 Ian Chesal
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
2
  require 'spec_helper'
16
3
 
17
4
  RSpec.describe Packer::Macro do
@@ -35,4 +22,4 @@ RSpec.describe Packer::Macro do
35
22
  expect(macro.respond_to? 'anything').to be_truthy
36
23
  expect(macro.respond_to? 'anything_else').to be_truthy
37
24
  end
38
- end
25
+ end
@@ -1,17 +1,4 @@
1
1
  # Encoding: utf-8
2
- # Copyright 2014 Ian Chesal
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
2
  require 'spec_helper'
16
3
 
17
4
  RSpec.describe Packer::PostProcessor do
@@ -69,4 +56,4 @@ RSpec.describe Packer::PostProcessor do
69
56
  postprocessor.data.delete('keep_input_artifact')
70
57
  end
71
58
  end
72
- end
59
+ end
@@ -1,17 +1,4 @@
1
1
  # Encoding: utf-8
2
- # Copyright 2014 Ian Chesal
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
2
  require 'spec_helper'
16
3
 
17
4
  RSpec.describe Packer::PostProcessor::DockerImport do
@@ -24,4 +11,4 @@ RSpec.describe Packer::PostProcessor::DockerImport do
24
11
  expect(postprocessor.data['type']).to eq(Packer::PostProcessor::DOCKER_IMPORT)
25
12
  end
26
13
  end
27
- end
14
+ end
@@ -1,17 +1,4 @@
1
1
  # Encoding: utf-8
2
- # Copyright 2014 Ian Chesal
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
2
  require 'spec_helper'
16
3
 
17
4
  RSpec.describe Packer::PostProcessor::DockerPush do
@@ -24,4 +11,4 @@ RSpec.describe Packer::PostProcessor::DockerPush do
24
11
  expect(postprocessor.data['type']).to eq(Packer::PostProcessor::DOCKER_PUSH)
25
12
  end
26
13
  end
27
- end
14
+ end
@@ -1,17 +1,4 @@
1
1
  # Encoding: utf-8
2
- # Copyright 2014 Ian Chesal
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
2
  require 'spec_helper'
16
3
 
17
4
  RSpec.describe Packer::PostProcessor::Vagrant do
@@ -24,4 +11,4 @@ RSpec.describe Packer::PostProcessor::Vagrant do
24
11
  expect(postprocessor.data['type']).to eq(Packer::PostProcessor::VAGRANT)
25
12
  end
26
13
  end
27
- end
14
+ end