vagrant-config_builder 0.11.0 → 0.12.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b242f323d273ed6a555d016d2281609563d28620
4
- data.tar.gz: badb6da19a3ec43aea229f162ea616b5e04be7c5
3
+ metadata.gz: d978845f673cd4fd8fee29c4baa0976fba50b612
4
+ data.tar.gz: 16164ce3af929e4005c44b8725e9da99528799be
5
5
  SHA512:
6
- metadata.gz: c78a02cc55ebf0fc674ca2cc3e0038350fd3ffacdd55bbaa659c18e88dcf008f630ba3e1bf9c8c48c07ef3e442383815edac8393582b6a44c34772b7210a940a
7
- data.tar.gz: ab497c2f941c60880b6aafa1c586dda6d3f4acfe3a4c6f762d8f8506f7c3066223a9ff89786160796924fc692479b0b60cb701f285992304b2602cc453e7fc49
6
+ metadata.gz: 47df11d730c5af000107adf333349a41aa35c53f35d9b02eacea19a5a768e031f11fc636f0f25563e47000231d94fbed2bac7b59083f4b8b8acd9c1f805aefa7
7
+ data.tar.gz: ebb29afcc5e993b0ab1379f73c811bb86d82852caa2ae163ac49a2646cf9aa61a5d155e19a81be7636a538cd4106e52f522f6af495740174204f6cdbdee21bc2
data/CHANGELOG CHANGED
@@ -1,6 +1,26 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ 0.12.0
5
+ ------
6
+
7
+ 2014-10-07
8
+
9
+ This is a backwards feature release.
10
+
11
+ * (GH-22) Support for VMware Workstation providers.
12
+
13
+ * (GH-24) New YAML loader which pre-processes data using ERB to enable
14
+ dynamic interpolation of values.
15
+
16
+ * (GH-25) Support for VMware vSphere providers.
17
+
18
+ * (GH-28) Support for libvirt providers.
19
+
20
+ * Support for the file provisioner.
21
+
22
+ Thanks to Nan Liu and Lukas Stanek for their contributions to this release.
23
+
4
24
  0.11.0
5
25
  ------
6
26
 
data/README.markdown CHANGED
@@ -19,44 +19,88 @@ for clarity.
19
19
 
20
20
  #### Directory structure
21
21
 
22
- .
23
- ├── config
24
- │   ├── roles.yaml
25
- │   └── vms.yaml
26
- └── Vagrantfile
22
+ ```shell
23
+ .
24
+ ├── config
25
+ │   ├── roles.yaml
26
+ │   └── vms.yaml
27
+ └── Vagrantfile
28
+ ```
27
29
 
28
30
  #### Vagrantfile
29
31
 
30
- require 'config_builder'
31
- Vagrant.configure('2', &ConfigBuilder.load(
32
- :yaml,
33
- :yamldir,
34
- File.expand_path('../config', __FILE__)
35
- ))
32
+ For pure yaml configurations, use yaml loader:
33
+ ```ruby
34
+ require 'config_builder'
35
+ Vagrant.configure('2', &ConfigBuilder.load(
36
+ :yaml,
37
+ :yamldir,
38
+ File.expand_path('../config', __FILE__)
39
+ ))
40
+ ```
41
+
42
+ For yaml erb configurations, use yaml_erb loader:
43
+ ```ruby
44
+ require 'config_builder'
45
+ Vagrant.configure('2', &ConfigBuilder.load(
46
+ :yaml_erb,
47
+ :yamldir,
48
+ File.expand_path('../config', __FILE__)
49
+ ))
50
+ ```
51
+
52
+ The yaml_erb loader would allow configuration such as:
53
+ ```yaml
54
+ ---
55
+ roles:
56
+ puppet_apply:
57
+ provisioners:
58
+ - type: puppet
59
+ manifests_path: 'tests'
60
+ module_path: 'spec/fixtures/modules'
61
+ manifest_file: <%= ENV['VAGRANT_MANIFEST'] || 'init.pp' %>
62
+ ```
36
63
 
37
64
  #### config/roles.yaml
38
65
 
39
- ---
40
- roles:
41
- bigvm:
42
- provider:
43
- type: virtualbox
44
- customize: [[modifyvm, !ruby/sym id, '--memory', 1024]]
66
+ ```yaml
67
+ ---
68
+ boxes:
69
+ centos-65-x64: http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-puppet.box
70
+ debian-73-x64: http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-puppet.box
71
+ roles:
72
+ bigvm:
73
+ provider:
74
+ type: virtualbox
75
+ customize: [[modifyvm, !ruby/sym id, '--memory', 1024]]
76
+ synced_folders:
77
+ - host_path: '.'
78
+ guest_path: '/vagrant'
79
+ disabled: true
80
+ smallvm:
81
+ provider:
82
+ type: vmware
83
+ vmx:
84
+ memsize: 512
85
+ numvcpus: 1
86
+ ```
45
87
 
46
88
  #### config/vms.yaml
47
89
 
48
- ---
49
- vms:
50
- -
51
- name: db
52
- private_networks: [ {ip: '10.20.1.2'} ]
53
- box: centos-5-i386
54
- hostname: db.puppetlabs.vm
55
- roles: bigvm
56
- -
57
- name: web
58
- private_networks: [ {ip: '10.20.1.3'} ]
59
- box: centos-5-i386
90
+ ```yaml
91
+ ---
92
+ vms:
93
+ -
94
+ name: db
95
+ private_networks: [ {ip: '10.20.1.2'} ]
96
+ box: centos-65-x64
97
+ hostname: db.puppetlabs.vm
98
+ roles: bigvm
99
+ -
100
+ name: web
101
+ private_networks: [ {ip: '10.20.1.3'} ]
102
+ box: debian-73-x64
103
+ ```
60
104
 
61
105
  Installation
62
106
  ------------
@@ -22,7 +22,7 @@ class ConfigBuilder::Loader::YAML
22
22
  rv = {}
23
23
 
24
24
  files.each do |file|
25
- contents = ::YAML.load_file(file)
25
+ contents = yamlfile(file)
26
26
  if contents.is_a? Hash
27
27
  rv = DeepMerge::deep_merge!(contents, rv, {:preserve_unmergables => false})
28
28
  end
@@ -0,0 +1,24 @@
1
+ require 'erb'
2
+
3
+ class ConfigBuilder::Loader::YAML_ERB < ConfigBuilder::Loader::YAML
4
+
5
+ # Load configuration from a YAML file with ERB interpolation first
6
+ #
7
+ # @param file_path [String]
8
+ #
9
+ # @example the following config file will be processed by ERB first so it can
10
+ # determine whether to use the environment variable 'VAGRANT_MANIFEST' or the
11
+ # default value 'init.pp' for the puppet manifest file.
12
+ #
13
+ # ---
14
+ # provisioner:
15
+ # - type: puppet
16
+ # manifest_file: <%= ENV['VAGRANT_MANIFEST'] || 'init.pp' >
17
+ #
18
+ # @return [Hash]
19
+ def yamlfile(file_path)
20
+ ::YAML.load(::ERB.new(File.read(file_path)).result)
21
+ end
22
+
23
+ ConfigBuilder::Loader.register(:yaml_erb, self)
24
+ end
@@ -18,5 +18,6 @@ module ConfigBuilder
18
18
  end
19
19
 
20
20
  require 'config_builder/loader/yaml'
21
+ require 'config_builder/loader/yaml_erb'
21
22
  end
22
23
  end
@@ -0,0 +1,108 @@
1
+ # @see http://github.com/pradels/vagrant-libvirt
2
+ class ConfigBuilder::Model::Provider::Libvirt < ConfigBuilder::Model::Base
3
+
4
+ # @!attribute [rw] uri
5
+ # @return [String] Manually specify URI
6
+ def_model_attribute :uri
7
+
8
+ # @!attribute [rw] driver
9
+ # @return [String] A hypervisor name to access via Libvirt.
10
+ def_model_attribute :driver
11
+
12
+ # @!attribute [rw] host
13
+ # @return [String] The name of the server, where libvirtd is running.
14
+ def_model_attribute :host
15
+
16
+ # @!attribute [rw] connect_via_ssh
17
+ # @return [String] If use ssh tunnel to connect to Libvirt.
18
+ def_model_attribute :connect_via_ssh
19
+
20
+ # @!attribute [rw] socket
21
+ # @return [String] Path towards the libvirt socket
22
+ def_model_attribute :socket
23
+
24
+ # @!attribute [rw] username
25
+ # @return [String] The username to access Libvirt.
26
+ def_model_attribute :username
27
+
28
+ # @!attribute [rw] password
29
+ # @return [String] Password for Libvirt connection.
30
+ def_model_attribute :password
31
+
32
+ # @!attribute [rw] id_ssh_key_file
33
+ # @return [String] ID SSH key file
34
+ def_model_attribute :id_ssh_key_file
35
+
36
+ # @!attribute [rw] storage_pool_name
37
+ # @return [String] Libvirt storage pool name, where box image and instance
38
+ # snapshots will be stored.
39
+ def_model_attribute :storage_pool_name
40
+
41
+ # @!attribute [rw] random_hostname
42
+ # @return [String] Turn on to prevent hostname conflicts
43
+ def_model_attribute :random_hostname
44
+
45
+ # @!attribute [rw] management_network_name
46
+ # @return [String] Libvirt default network name
47
+ def_model_attribute :management_network_name
48
+
49
+ # @!attribute [rw] management_network_address
50
+ # @return [String] Libvirt default network address
51
+ def_model_attribute :management_network_address
52
+
53
+ # @!attribute [rw] default_prefix
54
+ # @return [String] Default host prefix (alternative to use project folder
55
+ # name)
56
+ def_model_attribute :default_prefix
57
+
58
+ # Domain specific settings used while creating new domain.
59
+ def_model_attribute :memory
60
+ def_model_attribute :cpus
61
+ def_model_attribute :cpu_mode
62
+ def_model_attribute :disk_bus
63
+ def_model_attribute :nested
64
+ def_model_attribute :volume_cache
65
+ def_model_attribute :kernel
66
+ def_model_attribute :cmd_line
67
+ def_model_attribute :initrd
68
+
69
+ def initialize
70
+ @defaults = {}
71
+ end
72
+
73
+ def to_proc
74
+ Proc.new do |vm_config|
75
+ vm_config.provider 'libvirt' do |vb_config|
76
+
77
+ with_attr(:uri) { |val| vb_config.host = val }
78
+ with_attr(:driver) { |val| vb_config.host = val }
79
+ with_attr(:host) { |val| vb_config.host = val }
80
+ with_attr(:connect_via_ssh) { |val| vb_config.connect_via_ssh = val }
81
+ with_attr(:socket) { |val| vb_config.socket = val }
82
+ with_attr(:username) { |val| vb_config.username = val }
83
+ with_attr(:password) { |val| vb_config.username = val }
84
+ with_attr(:id_ssh_key_file) { |val| vb_config.id_ssh_key_file = val }
85
+ with_attr(:storage_pool_name) { |val| vb_config.storage_pool_name = val }
86
+ with_attr(:random_hostname) { |val| vb_config.random_hostname = val }
87
+ with_attr(:management_network_name) { |val|
88
+ vb_config.username = val
89
+ }
90
+ with_attr(:management_network_address) { |val|
91
+ vb_config.username = val
92
+ }
93
+ with_attr(:default_prefix) { |val| vb_config.username = val }
94
+ with_attr(:memory) { |val| vb_config.memory = val }
95
+ with_attr(:cpus) { |val| vb_config.cpus = val }
96
+ with_attr(:cpu_mode) { |val| vb_config.cpu_mode = val }
97
+ with_attr(:disk_bus) { |val| vb_config.disk_bus = val }
98
+ with_attr(:nested) { |val| vb_config.nested = val }
99
+ with_attr(:volume_cache) { |val| vb_config.volume_cache = val }
100
+ with_attr(:kernel) { |val| vb_config.kernel = val }
101
+ with_attr(:cmd_line) { |val| vb_config.cmd_line = val }
102
+ with_attr(:initrd) { |val| vb_config.initrd = val }
103
+ end
104
+ end
105
+ end
106
+
107
+ ConfigBuilder::Model::Provider.register('libvirt', self)
108
+ end
@@ -0,0 +1,40 @@
1
+ # @see http://docs.vagrantup.com/v2/vmware/configuration.html
2
+ class ConfigBuilder::Model::Provider::VMware < ConfigBuilder::Model::Base
3
+
4
+ # @!attribute [rw] vmx
5
+ # @return [Hash<String, String>] A hash of VMX options for the given VM
6
+ # @example
7
+ # model.vmx = {
8
+ # 'memsize' => '1024',
9
+ # 'numvcpus' => '2',
10
+ # }
11
+ def_model_attribute :vmx
12
+
13
+ # @!attribute [rw] gui
14
+ # @return [Boolean] Whether the GUI should be launched when the VM is created
15
+ def_model_attribute :gui
16
+
17
+ def initialize
18
+ @defaults = {
19
+ :gui => false,
20
+ :vmx => {},
21
+ }
22
+
23
+ @providers ||= %w[vmware_fusion vmware_workstation]
24
+ end
25
+
26
+ def to_proc
27
+ Proc.new do |vm_config|
28
+ @providers.each do |vmware_provider|
29
+ vm_config.provider vmware_provider do |config|
30
+ config.gui = attr(:gui)
31
+ attr(:vmx).each_pair do |key, value|
32
+ config.vmx[key] = value
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ ConfigBuilder::Model::Provider.register('vmware', self)
40
+ end
@@ -1,35 +1,7 @@
1
- # @see http://docs.vagrantup.com/v2/vmware/configuration.html
2
- class ConfigBuilder::Model::Provider::VMwareFusion < ConfigBuilder::Model::Base
3
-
4
- # @!attribute [rw] vmx
5
- # @return [Hash<String, String>] A hash of VMX options for the given VM
6
- # @example
7
- # model.vmx = {
8
- # 'memsize' => '1024',
9
- # 'numvcpus' => '2',
10
- # }
11
- def_model_attribute :vmx
12
-
13
- # @!attribute [rw] gui
14
- # @return [Boolean] Whether the GUI should be launched when the VM is created
15
- def_model_attribute :gui
16
-
1
+ class ConfigBuilder::Model::Provider::VMwareFusion < ConfigBuilder::Model::Provider::VMware
17
2
  def initialize
18
- @defaults = {
19
- :gui => false,
20
- :vmx => {},
21
- }
22
- end
23
-
24
- def to_proc
25
- Proc.new do |vm_config|
26
- vm_config.provider 'vmware_fusion' do |fusion_config|
27
- fusion_config.gui = attr(:gui)
28
- attr(:vmx).each_pair do |key, value|
29
- fusion_config.vmx[key] = value
30
- end
31
- end
32
- end
3
+ @providers = %w[vmware_fusion]
4
+ super
33
5
  end
34
6
 
35
7
  ConfigBuilder::Model::Provider.register('vmware_fusion', self)
@@ -0,0 +1,8 @@
1
+ class ConfigBuilder::Model::Provider::VMwareWorkstation < ConfigBuilder::Model::Provider::VMware
2
+ def initialize
3
+ @providers = %w[vmware_workstation]
4
+ super
5
+ end
6
+
7
+ ConfigBuilder::Model::Provider.register('vmware_workstation', self)
8
+ end
@@ -0,0 +1,30 @@
1
+ # @see https://github.com/nsidc/vagrant-vsphere
2
+ class ConfigBuilder::Model::Provider::Vsphere< ConfigBuilder::Model::Base
3
+
4
+ VSPHERE_ATTRIBUTES = [ :host, :insecure, :user, :password, :data_center_name, :compute_resource_name, :resource_pool_name, :clone_from_vm, :template_name, :name, :vm_base_path, :customization_spec_name, :data_store_name, :linked_clone, :proxy_host, :proxy_port, :vlan ]
5
+
6
+ # @!attribute [rw]
7
+ # The mandatory attributes will be verified by vagrant-vsphere
8
+ # @see https://github.com/nsidc/vagrant-vsphere#configuration
9
+ VSPHERE_ATTRIBUTES.each do |key|
10
+ def_model_attribute attr
11
+ end
12
+
13
+ def initialize
14
+ @defaults = {
15
+ :insecure => false,
16
+ }
17
+ end
18
+
19
+ def to_proc
20
+ Proc.new do |vm_config|
21
+ vm_config.provider 'vsphere' do |config|
22
+ VSPHERE_ATTRIBUTES.each do |key|
23
+ config.send("#{key}=", attr(key)) if attr(key)
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ ConfigBuilder::Model::Provider.register('vsphere', self)
30
+ end
@@ -0,0 +1,24 @@
1
+ # @see http://docs.vagrantup.com/v2/provisioning/file.html
2
+ class ConfigBuilder::Model::Provisioner::File < ConfigBuilder::Model::Base
3
+ # @!attribute [rw] source
4
+ # @return [Source] Is the local path of the file to be uploaded.
5
+ def_model_attribute :source
6
+
7
+ # @!attribute [rw] destination
8
+ # @return [Source] Is the remote path on the guest machine where the file
9
+ # will be uploaded to. The file is uploaded as the SSH user over SCP, so
10
+ # this location must be writable to that user. The SSH user can be
11
+ # determined by running vagrant ssh-config, and defaults to "vagrant".
12
+ def_model_attribute :destination
13
+
14
+ def to_proc
15
+ Proc.new do |vm_config|
16
+ vm_config.provision :file do |file_config|
17
+ with_attr(:source) { |val| file_config.source = val }
18
+ with_attr(:destination) { |val| file_config.destination = val }
19
+ end
20
+ end
21
+ end
22
+
23
+ ConfigBuilder::Model::Provisioner.register('file', self)
24
+ end
@@ -39,7 +39,11 @@ module ConfigBuilder
39
39
  end
40
40
 
41
41
  require 'config_builder/model/provider/virtualbox'
42
+ require 'config_builder/model/provider/vmware'
42
43
  require 'config_builder/model/provider/vmware_fusion'
44
+ require 'config_builder/model/provider/vmware_workstation'
45
+ require 'config_builder/model/provider/libvirt'
46
+ require 'config_builder/model/provider/vsphere'
43
47
  end
44
48
 
45
49
  module Provisioner
@@ -1,3 +1,3 @@
1
1
  module ConfigBuilder
2
- VERSION = '0.11.0'
2
+ VERSION = '0.12.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-config_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Thebo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-17 00:00:00.000000000 Z
11
+ date: 2014-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deep_merge
@@ -64,12 +64,18 @@ files:
64
64
  - lib/config_builder/filter_stack.rb
65
65
  - lib/config_builder/loader.rb
66
66
  - lib/config_builder/loader/yaml.rb
67
+ - lib/config_builder/loader/yaml_erb.rb
67
68
  - lib/config_builder/model.rb
68
69
  - lib/config_builder/model/base.rb
69
70
  - lib/config_builder/model/network/forwarded_port.rb
70
71
  - lib/config_builder/model/network/private_network.rb
72
+ - lib/config_builder/model/provider/libvirt.rb
71
73
  - lib/config_builder/model/provider/virtualbox.rb
74
+ - lib/config_builder/model/provider/vmware.rb
72
75
  - lib/config_builder/model/provider/vmware_fusion.rb
76
+ - lib/config_builder/model/provider/vmware_workstation.rb
77
+ - lib/config_builder/model/provider/vsphere.rb
78
+ - lib/config_builder/model/provisioner/file.rb
73
79
  - lib/config_builder/model/provisioner/puppet.rb
74
80
  - lib/config_builder/model/provisioner/puppet_server.rb
75
81
  - lib/config_builder/model/provisioner/shell.rb