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
@@ -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/postprocessors/all'
16
3
  require 'packer/dataobject'
17
4
 
@@ -1,16 +1,3 @@
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_relative 'docker'
16
- require_relative 'vagrant'
3
+ require_relative '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 'packer/postprocessor'
16
3
  require 'packer/dataobject'
17
4
 
@@ -32,4 +19,4 @@ module Packer
32
19
  end
33
20
  end
34
21
  end
35
- end
22
+ 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/postprocessor'
16
3
  require 'packer/dataobject'
17
4
 
@@ -44,4 +31,4 @@ module Packer
44
31
  end
45
32
  end
46
33
  end
47
- end
34
+ end
@@ -1,28 +1,27 @@
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/provisioners/all'
16
3
  require 'packer/dataobject'
17
4
 
18
5
  module Packer
19
6
  class Provisioner < Packer::DataObject
20
- SHELL = 'shell'
21
- FILE = 'file'
7
+ SHELL = 'shell'
8
+ FILE = 'file'
9
+ SALT = 'salt-masterless'
10
+ ANSIBLE = 'ansible-local'
11
+ CHEF_CLIENT = 'chef-client'
12
+ CHEF_SOLO = 'chef-solo'
13
+ PUPPET_MASTERLESS = 'puppet-masterless'
14
+ PUPPET_SERVER = 'puppet-server'
22
15
 
23
16
  VALID_PROVISIONER_TYPES = [
24
17
  SHELL,
25
- FILE
18
+ FILE,
19
+ SALT,
20
+ ANSIBLE,
21
+ CHEF_CLIENT,
22
+ CHEF_SOLO,
23
+ PUPPET_MASTERLESS,
24
+ PUPPET_SERVER
26
25
  ]
27
26
 
28
27
  class UnrecognizedProvisionerTypeError < StandardError
@@ -33,8 +32,14 @@ module Packer
33
32
  raise UnrecognizedProvisionerTypeError.new("Unrecognized provisioner type #{type}")
34
33
  end
35
34
  {
36
- SHELL => Packer::Provisioner::Shell,
37
- FILE => Packer::Provisioner::File,
35
+ SHELL => Packer::Provisioner::Shell,
36
+ FILE => Packer::Provisioner::File,
37
+ SALT => Packer::Provisioner::Salt,
38
+ ANSIBLE => Packer::Provisioner::Ansible,
39
+ CHEF_CLIENT => Packer::Provisioner::Chef::Client,
40
+ CHEF_SOLO => Packer::Provisioner::Chef::Solo,
41
+ PUPPET_MASTERLESS => Packer::Provisioner::Puppet::Masterless,
42
+ PUPPET_SERVER => Packer::Provisioner::Puppet::Server
38
43
  }.fetch(type).new
39
44
  end
40
45
 
@@ -82,4 +87,4 @@ module Packer
82
87
  VALID_PROVISIONER_TYPES.include? type
83
88
  end
84
89
  end
85
- end
90
+ end
@@ -1,16 +1,9 @@
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_relative 'file'
16
- require_relative 'shell'
3
+ require_relative 'shell'
4
+ require_relative 'salt'
5
+ require_relative 'ansible'
6
+ require_relative 'chef/client'
7
+ require_relative 'chef/solo'
8
+ require_relative 'puppet/server'
9
+ require_relative 'puppet/masterless'
@@ -0,0 +1,55 @@
1
+ # Encoding: utf-8
2
+ require 'packer/provisioner'
3
+ require 'packer/dataobject'
4
+
5
+ module Packer
6
+ class Provisioner < Packer::DataObject
7
+ class Ansible < Provisioner
8
+ def initialize
9
+ super
10
+ self.data['type'] = ANSIBLE
11
+ self.add_required(['playbook_file'])
12
+ end
13
+
14
+ def playbook_file(filename)
15
+ self.__add_string('playbook_file', filename)
16
+ end
17
+
18
+ def command(cmd)
19
+ self.__add_string('command', cmd)
20
+ end
21
+
22
+ def extra_arguments(args)
23
+ self.__add_array_of_strings('extra_arguments', args)
24
+ end
25
+
26
+ def inventory_file(filename)
27
+ self.__add_string('inventory_file', filename)
28
+ end
29
+
30
+ def playbook_dir(dirname)
31
+ self.__add_string('playbook_dir', dirname)
32
+ end
33
+
34
+ def playbook_paths(paths)
35
+ self.__add_array_of_strings('playbook_paths', paths)
36
+ end
37
+
38
+ def group_vars(vars)
39
+ self.__add_string('group_vars', vars)
40
+ end
41
+
42
+ def host_vars(vars)
43
+ self.__add_string('host_vars', vars)
44
+ end
45
+
46
+ def role_paths(paths)
47
+ self.__add_array_of_strings('role_paths', paths)
48
+ end
49
+
50
+ def staging_directory(dirname)
51
+ self._add_string('staging_directory', dirname)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,75 @@
1
+ # Encoding: utf-8
2
+ require 'packer/provisioner'
3
+ require 'packer/dataobject'
4
+
5
+ module Packer
6
+ class Provisioner < Packer::DataObject
7
+ class Chef < Provisioner
8
+ class Client < Chef
9
+ def initialize
10
+ super
11
+ self.data['type'] = CHEF_CLIENT
12
+ self.add_required(['server_url'])
13
+ end
14
+
15
+ def server_url(url)
16
+ self.__add_string('server_url', url)
17
+ end
18
+
19
+ def chef_environment(env)
20
+ self.__add_string('chef_environment', env)
21
+ end
22
+
23
+ def config_template(filename)
24
+ self.__add_string('config_template', filename)
25
+ end
26
+
27
+ def execute_command(command)
28
+ self.__add_string('execute_command', command)
29
+ end
30
+
31
+ def install_command(command)
32
+ self.__add_string('install_command', command)
33
+ end
34
+
35
+ # TODO How to support json?
36
+
37
+ def node_name(name)
38
+ self.__add_string('node_name', name)
39
+ end
40
+
41
+ def prevent_sudo(bool)
42
+ self.__add_boolean('prevent_sudo', bool)
43
+ end
44
+
45
+ def run_list(list)
46
+ self.__add_array_of_strings('run_list', list)
47
+ end
48
+
49
+ def skip_clean_client(bool)
50
+ self.__add_bool('skip_clean_client', bool)
51
+ end
52
+
53
+ def skip_clean_node(bool)
54
+ self.__add_bool('skip_clean_node', bool)
55
+ end
56
+
57
+ def skip_install(bool)
58
+ self.__add_bool('skip_install', bool)
59
+ end
60
+
61
+ def staging_directory(dirname)
62
+ self.__add_string('staging_directory', dirname)
63
+ end
64
+
65
+ def validation_client_name(name)
66
+ self.__add_string('validation_client_name', name)
67
+ end
68
+
69
+ def validation_key_path(path)
70
+ self.__add_string('validation_key_path', path)
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,67 @@
1
+ # Encoding: utf-8
2
+ require 'packer/provisioner'
3
+ require 'packer/dataobject'
4
+
5
+ module Packer
6
+ class Provisioner < Packer::DataObject
7
+ class Chef < Provisioner
8
+ class Solo < Chef
9
+ def initialize
10
+ super
11
+ self.data['type'] = CHEF_SOLO
12
+ self.add_required([])
13
+ end
14
+
15
+ def config_template(filename)
16
+ self.__add_string('config_template', filename)
17
+ end
18
+
19
+ def cookbook_paths(paths)
20
+ self.__add_array_of_strings('cookbook_paths', paths)
21
+ end
22
+
23
+ def data_bags_path(path)
24
+ self.__add_string('data_bags_path', path)
25
+ end
26
+
27
+ def encrypted_data_bag_secret_path(path)
28
+ self.__add_string('encrypted_data_bag_secret_path', path)
29
+ end
30
+
31
+ def execute_command(command)
32
+ self.__add_string('execute_command', command)
33
+ end
34
+
35
+ def install_command(command)
36
+ self.__add_string('install_command', command)
37
+ end
38
+
39
+ # TODO How to handle json?
40
+
41
+ def prevent_sudo(bool)
42
+ self.__add_boolean('prevent_sudo', bool)
43
+ end
44
+
45
+ def remote_cookbook_paths(paths)
46
+ self.__add_array_of_strings('remote_cookbook_paths', paths)
47
+ end
48
+
49
+ def roles_path(path)
50
+ self.__add_string('roles_path', path)
51
+ end
52
+
53
+ def run_list(runlist)
54
+ self.__add_array_of_strings('run_list', runlist)
55
+ end
56
+
57
+ def skip_install(bool)
58
+ self.__add_boolean('skip_install', bool)
59
+ end
60
+
61
+ def staging_directory(dirname)
62
+ self.__add_string('staging_directory', dirname)
63
+ end
64
+ end
65
+ end
66
+ end
67
+ 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
 
@@ -33,4 +20,4 @@ module Packer
33
20
  end
34
21
  end
35
22
  end
36
- end
23
+ end
@@ -0,0 +1,48 @@
1
+ require 'packer/provisioner'
2
+ require 'packer/dataobject'
3
+
4
+ module Packer
5
+ class Provisioner < Packer::DataObject
6
+ class Puppet < Provisioner
7
+ class Masterless < Puppet
8
+ def initialize
9
+ super
10
+ self.data['type'] = PUPPET_MASTERLESS
11
+ self.add_required(['manifest_file'])
12
+ end
13
+
14
+ def manifest_file(filename)
15
+ self.__add_string('manifest_file', filename)
16
+ end
17
+
18
+ def execute_command(command)
19
+ self.__add_string('execute_command', command)
20
+ end
21
+
22
+ def facter(facts)
23
+ self.__add_hash('facter', facts)
24
+ end
25
+
26
+ def hiera_config_path(path)
27
+ self.__add_string('hiera_config_path', path)
28
+ end
29
+
30
+ def manifest_dir(path)
31
+ self.__add_string('manifest_dir', path)
32
+ end
33
+
34
+ def module_paths(paths)
35
+ self.__add_array_of_strings('module_paths',paths)
36
+ end
37
+
38
+ def prevent_sudo(flag)
39
+ self.__add_boolean('prevent_sudo', flag)
40
+ end
41
+
42
+ def staging_directory(dirname)
43
+ self.__add_string('staging_directory', dirname)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end