vagrant-masonry 0.13.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 +7 -0
- data/.gitignore +3 -0
- data/.yardopts +6 -0
- data/CHANGELOG +190 -0
- data/Gemfile +16 -0
- data/LICENSE +15 -0
- data/README.md +129 -0
- data/docs/GettingStarted.markdown +175 -0
- data/examples/Vagrantfile +1 -0
- data/examples/roles.yaml +29 -0
- data/examples/vms.yaml +12 -0
- data/lib/config_builder.rb +24 -0
- data/lib/config_builder/action/load_extensions.rb +14 -0
- data/lib/config_builder/class_registry.rb +72 -0
- data/lib/config_builder/extension_handler.rb +22 -0
- data/lib/config_builder/filter.rb +6 -0
- data/lib/config_builder/filter/boxes.rb +22 -0
- data/lib/config_builder/filter/roles.rb +149 -0
- data/lib/config_builder/filter_stack.rb +37 -0
- data/lib/config_builder/loader.rb +23 -0
- data/lib/config_builder/loader/yaml.rb +44 -0
- data/lib/config_builder/loader/yaml_erb.rb +24 -0
- data/lib/config_builder/model.rb +67 -0
- data/lib/config_builder/model/base.rb +101 -0
- data/lib/config_builder/model/network/forwarded_port.rb +37 -0
- data/lib/config_builder/model/network/private_network.rb +15 -0
- data/lib/config_builder/model/provider/azure.rb +66 -0
- data/lib/config_builder/model/provider/libvirt.rb +108 -0
- data/lib/config_builder/model/provider/virtualbox.rb +35 -0
- data/lib/config_builder/model/provider/vmware.rb +40 -0
- data/lib/config_builder/model/provider/vmware_fusion.rb +8 -0
- data/lib/config_builder/model/provider/vmware_workstation.rb +8 -0
- data/lib/config_builder/model/provider/vsphere.rb +30 -0
- data/lib/config_builder/model/provisioner/file.rb +24 -0
- data/lib/config_builder/model/provisioner/puppet.rb +37 -0
- data/lib/config_builder/model/provisioner/puppet_server.rb +27 -0
- data/lib/config_builder/model/provisioner/shell.rb +27 -0
- data/lib/config_builder/model/root.rb +69 -0
- data/lib/config_builder/model/ssh.rb +110 -0
- data/lib/config_builder/model/synced_folder.rb +43 -0
- data/lib/config_builder/model/vm.rb +235 -0
- data/lib/config_builder/model/winrm.rb +56 -0
- data/lib/config_builder/model_delegator.rb +30 -0
- data/lib/config_builder/plugin.rb +15 -0
- data/lib/config_builder/runner.rb +33 -0
- data/lib/config_builder/version.rb +3 -0
- data/lib/vagrant-masonry.rb +1 -0
- data/spec/config_builder/filter/boxes_spec.rb +87 -0
- data/spec/config_builder/filter/roles_spec.rb +287 -0
- data/spec/config_builder/loader/yaml_spec.rb +76 -0
- data/spec/config_builder/model/provider/vmware_fusion_spec.rb +29 -0
- data/spec/spec_helper.rb +4 -0
- data/templates/locales/en.yml +11 -0
- data/vagrant-masonry.gemspec +24 -0
- metadata +128 -0
@@ -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
|
@@ -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
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# @see http://docs.vagrantup.com/v2/provisioning/puppet_apply.html
|
2
|
+
class ConfigBuilder::Model::Provisioner::Puppet < ConfigBuilder::Model::Base
|
3
|
+
|
4
|
+
# @!attribute [rw] manifests_path
|
5
|
+
# @return [String] The path to the puppet manifests.
|
6
|
+
attr_accessor :manifests_path
|
7
|
+
|
8
|
+
# @!attribute [rw] manifest_file
|
9
|
+
# @return [String] The name of the manifest to apply
|
10
|
+
attr_accessor :manifest_file
|
11
|
+
|
12
|
+
# @!attribute [rw] module_path
|
13
|
+
# @return [String] A colon separated set of filesystem paths for Puppet
|
14
|
+
attr_accessor :module_path
|
15
|
+
|
16
|
+
# @!attribute [rw] facter
|
17
|
+
# @return [Hash] A hash of values to use as facts
|
18
|
+
attr_accessor :facter
|
19
|
+
|
20
|
+
# @!attribute [rw] options
|
21
|
+
# @return [String] An arbitrary set of arguments for the `puppet` command
|
22
|
+
attr_accessor :options
|
23
|
+
|
24
|
+
def to_proc
|
25
|
+
Proc.new do |vm_config|
|
26
|
+
vm_config.provision :puppet do |puppet_config|
|
27
|
+
with_attr(:manifests_path) { |val| puppet_config.manifests_path = val }
|
28
|
+
with_attr(:manifest_file) { |val| puppet_config.manifest_file = val }
|
29
|
+
with_attr(:module_path) { |val| puppet_config.module_path = val }
|
30
|
+
with_attr(:facter) { |val| puppet_config.facter = val }
|
31
|
+
with_attr(:options) { |val| puppet_config.options = val }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
ConfigBuilder::Model::Provisioner.register('puppet', self)
|
37
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# @see http://docs.vagrantup.com/v2/provisioning/puppet_agent.html
|
2
|
+
class ConfigBuilder::Model::Provisioner::PuppetServer < ConfigBuilder::Model::Base
|
3
|
+
|
4
|
+
# @!attribute [rw] puppet_server
|
5
|
+
# @return [String]
|
6
|
+
attr_accessor :puppet_server
|
7
|
+
|
8
|
+
# @!attribute [rw] node_name
|
9
|
+
# @return [String]
|
10
|
+
attr_accessor :node_name
|
11
|
+
|
12
|
+
# @!attribute [rw] options
|
13
|
+
# @return [String]
|
14
|
+
attr_accessor :options
|
15
|
+
|
16
|
+
def to_proc
|
17
|
+
Proc.new do |vm_config|
|
18
|
+
vm_config.provision :puppet_server do |puppet_config|
|
19
|
+
with_attr(:puppet_server) { |val| puppet_config.puppet_server = val }
|
20
|
+
with_attr(:node_name) { |val| puppet_config.node_name = val }
|
21
|
+
with_attr(:options) { |val| puppet_config.options = val }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
ConfigBuilder::Model::Provisioner.register('puppet_server', self)
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# @see http://docs.vagrantup.com/v2/provisioning/shell.html
|
2
|
+
class ConfigBuilder::Model::Provisioner::Shell < ConfigBuilder::Model::Base
|
3
|
+
|
4
|
+
# @!attribute [rw] inline
|
5
|
+
# @return [String] The inline shell command to run
|
6
|
+
def_model_attribute :inline
|
7
|
+
|
8
|
+
# @!attribute [rw] path
|
9
|
+
# @return [String] The path to the shell script to run
|
10
|
+
def_model_attribute :path
|
11
|
+
|
12
|
+
# @!attribute [rw] args
|
13
|
+
# @return [String] A string acting as an argument vector to the command.
|
14
|
+
def_model_attribute :args
|
15
|
+
|
16
|
+
def to_proc
|
17
|
+
Proc.new do |vm_config|
|
18
|
+
vm_config.provision :shell do |shell_config|
|
19
|
+
with_attr(:inline) { |val| shell_config.inline = val }
|
20
|
+
with_attr(:path) { |val| shell_config.path = val }
|
21
|
+
with_attr(:args) { |val| shell_config.args = val }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
ConfigBuilder::Model::Provisioner.register('shell', self)
|
27
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# Model the root level Vagrant config object
|
2
|
+
#
|
3
|
+
# @see http://docs.vagrantup.com/v2/vagrantfile/index.html
|
4
|
+
class ConfigBuilder::Model::Root < ConfigBuilder::Model::Base
|
5
|
+
|
6
|
+
include ConfigBuilder::ModelDelegator
|
7
|
+
|
8
|
+
def_model_delegator :vagrant
|
9
|
+
def_model_delegator :vms
|
10
|
+
|
11
|
+
# @!attribute [rw] ssh
|
12
|
+
# @return [Hash<Symbol, Object>] The ssh configuration for all VMs
|
13
|
+
# @example
|
14
|
+
# >> config.ssh
|
15
|
+
# => {
|
16
|
+
# :username => 'administrator',
|
17
|
+
# :password => 'vagrant',
|
18
|
+
# }
|
19
|
+
def_model_delegator :ssh
|
20
|
+
|
21
|
+
# @!attribute [rw] winrm
|
22
|
+
# @return [Hash<Symbol, Object>] The winrm configuration for all VMs
|
23
|
+
# @example
|
24
|
+
# >> config.winrm
|
25
|
+
# => {
|
26
|
+
# :username => 'administrator',
|
27
|
+
# :password => 'vagrant',
|
28
|
+
# }
|
29
|
+
def_model_delegator :winrm
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
@defaults = {:vms => [], :vagrant => {}}
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_proc
|
36
|
+
Proc.new do |root_config|
|
37
|
+
eval_models(root_config)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def eval_vms(root_config)
|
44
|
+
attr(:vms).each do |hash|
|
45
|
+
v = ConfigBuilder::Model::VM.new_from_hash(hash)
|
46
|
+
v.call(root_config)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def eval_vagrant(root_config)
|
51
|
+
if attr(:vagrant).has_key? :host
|
52
|
+
root_config.vagrant.host = attr(:vagrant)[:host]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def eval_ssh(root_config)
|
57
|
+
with_attr(:ssh) do |ssh_config|
|
58
|
+
f = ConfigBuilder::Model::SSH.new_from_hash(ssh_config)
|
59
|
+
f.call(root_config)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def eval_winrm(root_config)
|
64
|
+
if attr(:winrm)
|
65
|
+
f = ConfigBuilder::Model::WinRM.new_from_hash(attr(:winrm))
|
66
|
+
f.call(root_config)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# Vagrant SSH credential model
|
2
|
+
#
|
3
|
+
# @see http://docs.vagrantup.com/v2/vagrantfile/ssh_settings.html
|
4
|
+
class ConfigBuilder::Model::SSH < ConfigBuilder::Model::Base
|
5
|
+
# @!attribute [rw] username
|
6
|
+
# @return [String] This sets the username that Vagrant will SSH as by
|
7
|
+
# default. Providers are free to override this if they detect a more
|
8
|
+
# appropriate user. By default this is "vagrant," since that is what most
|
9
|
+
# public boxes are made as.
|
10
|
+
def_model_attribute :username
|
11
|
+
|
12
|
+
# @!attribute [rw] password
|
13
|
+
# @return [String] This sets a password that Vagrant will use to
|
14
|
+
# authenticate the SSH user. Note that Vagrant recommends you use
|
15
|
+
# key-based authentiation rather than a password (see #private_key_path)
|
16
|
+
# below. If you use a password, Vagrant will automatically insert a
|
17
|
+
# keypair if `insert_key` is true.
|
18
|
+
def_model_attribute :password
|
19
|
+
|
20
|
+
# @!attribute [rw] host
|
21
|
+
# @return [String] The hostname or IP to SSH into. By default this is
|
22
|
+
# empty, because the provider usually figures this out for you.
|
23
|
+
def_model_attribute :host
|
24
|
+
|
25
|
+
# @!attribute [rw] port
|
26
|
+
# @return [Fixnum] The port to SSH into. By default this is port 22.
|
27
|
+
def_model_attribute :port
|
28
|
+
|
29
|
+
# @!attribute [rw] guest_port
|
30
|
+
# @return [Fixnum] The port on the guest that SSH is running on. This is
|
31
|
+
# used by some providers to detect forwarded ports for SSH. For example,
|
32
|
+
# if this is set to 22 (the default), and Vagrant detects a forwarded
|
33
|
+
# port to port 22 on the guest from port 4567 on the host, Vagrant will
|
34
|
+
# attempt to use port 4567 to talk to the guest if there is no other
|
35
|
+
# option.
|
36
|
+
def_model_attribute :guest_port
|
37
|
+
|
38
|
+
# @!attribute [rw] private_key_path
|
39
|
+
# @return [String] The path to the private key to use to SSH into the guest
|
40
|
+
# machine. By default this is the insecure private key that ships with
|
41
|
+
# Vagrant, since that is what public boxes use. If you make your own
|
42
|
+
# custom box with a custom SSH key, this should point to that private
|
43
|
+
# key.
|
44
|
+
#
|
45
|
+
# You can also specify multiple private keys by setting this to be an
|
46
|
+
# array. This is useful, for example, if you use the default private key
|
47
|
+
# to bootstrap the machine, but replace it with perhaps a more secure key
|
48
|
+
# later.
|
49
|
+
def_model_attribute :private_key_path
|
50
|
+
|
51
|
+
# @!attribute [rw] forward_agent
|
52
|
+
# @return [Boolean] If `true`, agent forwarding over SSH connections is
|
53
|
+
# enabled. Defaults to `false`.
|
54
|
+
def_model_attribute :forward_agent
|
55
|
+
|
56
|
+
# @!attribute [rw] forward_x11
|
57
|
+
# @return [Boolean] If `true`, X11 forwarding over SSH connections is
|
58
|
+
# enabled. Defaults to `false`.
|
59
|
+
def_model_attribute :forward_x11
|
60
|
+
|
61
|
+
# @!attribute [rw] insert_key
|
62
|
+
# @return [Boolean] If `true`, Vagrant will automatically insert an insecure
|
63
|
+
# keypair to use for SSH. By default, this is `true`. This only has an
|
64
|
+
# effect if you don't already use private keys for authentication.
|
65
|
+
def_model_attribute :insert_key
|
66
|
+
|
67
|
+
# @!attribute [rw] proxy_command
|
68
|
+
# @return [String] A command-line command to execute that receives the data
|
69
|
+
# to send to SSH on stdin. This can be used to proxy the SSH connection.
|
70
|
+
# `%h` in the command is replaced with the host and `%p` is replaced with
|
71
|
+
# the port.
|
72
|
+
def_model_attribute :proxy_command
|
73
|
+
|
74
|
+
# @!attribute [rw] pty
|
75
|
+
# @return [Boolean] If `true`, pty will be used for provisioning. Defaults
|
76
|
+
# to `false`.
|
77
|
+
#
|
78
|
+
# This setting is an _advanced feature_ that should not be enabled unless
|
79
|
+
# absolutely necessary. It breaks some other features of Vagrant, and is
|
80
|
+
# really only exposed for cases where it is absolutely necessary. If you
|
81
|
+
# can find a way to not use a pty, that is recommended instead.
|
82
|
+
def_model_attribute :pty
|
83
|
+
|
84
|
+
# @!attribute [rw] shell
|
85
|
+
# @return [String] The shell to use when executing SSH commands from
|
86
|
+
# Vagrant. By default this is `bash -l`. Note that this has no effect on
|
87
|
+
# the shell you get when you run `vagrant ssh`. This configuration option
|
88
|
+
# only affects the shell to use when executing commands internally in
|
89
|
+
# Vagrant.
|
90
|
+
def_model_attribute :shell
|
91
|
+
|
92
|
+
def to_proc
|
93
|
+
Proc.new do |global_config|
|
94
|
+
ssh = global_config.ssh
|
95
|
+
|
96
|
+
with_attr(:username) { |val| ssh.username = val }
|
97
|
+
with_attr(:password) { |val| ssh.password = val }
|
98
|
+
with_attr(:host) { |val| ssh.host = val }
|
99
|
+
with_attr(:port) { |val| ssh.port = val }
|
100
|
+
with_attr(:guest_port) { |val| ssh.guest_port = val }
|
101
|
+
with_attr(:private_key_path) { |val| ssh.private_key_path = val }
|
102
|
+
with_attr(:forward_agent) { |val| ssh.forward_agent = val }
|
103
|
+
with_attr(:forward_x11) { |val| ssh.forward_x11 = val }
|
104
|
+
with_attr(:insert_key) { |val| ssh.insert_key = val }
|
105
|
+
with_attr(:proxy_command) { |val| ssh.proxy_command = val }
|
106
|
+
with_attr(:pty) { |val| ssh.pty = val }
|
107
|
+
with_attr(:shell) { |val| ssh.shell = val }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Vagrant shared folder model.
|
2
|
+
#
|
3
|
+
# @see http://docs.vagrantup.com/v2/synced-folders/index.html
|
4
|
+
class ConfigBuilder::Model::SyncedFolder < ConfigBuilder::Model::Base
|
5
|
+
|
6
|
+
# @!attribute [rw] host_path
|
7
|
+
# @return [String] The host file path to mount on the guest
|
8
|
+
def_model_attribute :host_path
|
9
|
+
|
10
|
+
# @!attribute [rw] guest_path
|
11
|
+
# @return [String] The guest file path to be used as the mount point
|
12
|
+
def_model_attribute :guest_path
|
13
|
+
|
14
|
+
# @!attribute [rw] extra
|
15
|
+
# A set of arbitrary options to pass to the virtualbox mount command.
|
16
|
+
# @return [String]
|
17
|
+
def_model_attribute :extra
|
18
|
+
|
19
|
+
# @!attribute [rw] disabled
|
20
|
+
# @return [Boolean] If the mount point should be disabled.
|
21
|
+
def_model_attribute :disabled
|
22
|
+
|
23
|
+
# @!attribute [rw] nfs
|
24
|
+
# @return [Boolean] If the mount point should use NFS
|
25
|
+
def_model_attribute :nfs
|
26
|
+
|
27
|
+
def to_proc
|
28
|
+
Proc.new do |vm_config|
|
29
|
+
vm_config.synced_folder(attr(:host_path), attr(:guest_path), folder_opts)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def folder_opts
|
36
|
+
h = {}
|
37
|
+
with_attr(:extra) { |val| h[:extra] = val }
|
38
|
+
with_attr(:disabled) { |val| h[:disabled] = val }
|
39
|
+
with_attr(:nfs) { |val| h[:nfs] = val }
|
40
|
+
|
41
|
+
h
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,235 @@
|
|
1
|
+
# @see http://docs.vagrantup.com/v2/vagrantfile/machine_settings.html
|
2
|
+
class ConfigBuilder::Model::VM < ConfigBuilder::Model::Base
|
3
|
+
|
4
|
+
include ConfigBuilder::ModelDelegator
|
5
|
+
|
6
|
+
# @!attribute [rw] provider
|
7
|
+
# @return [Hash<Symbol, Object>] The provider configuration for
|
8
|
+
# this VM
|
9
|
+
# @example
|
10
|
+
# >> vm.provider
|
11
|
+
# => {
|
12
|
+
# :type => 'virtualbox',
|
13
|
+
# :name => 'tiny-tina',
|
14
|
+
# :gui => false,
|
15
|
+
# }
|
16
|
+
def_model_delegator :provider
|
17
|
+
|
18
|
+
# @!attribute [rw] providers
|
19
|
+
# @return [Array<Hash{String, Symbol => Object}>] A collection of provider
|
20
|
+
# parameters that should be applied to a VM.
|
21
|
+
# @example
|
22
|
+
# >> vm.providers
|
23
|
+
# => [
|
24
|
+
# {:type => 'virtualbox', :customize => ['modifyvm', :id, '--memory', 1024]},
|
25
|
+
# {:type => 'vmware_fusion', :vmx => {:memsize => 1024}},
|
26
|
+
# ]
|
27
|
+
def_model_delegator :providers
|
28
|
+
|
29
|
+
# @!attribute [rw] provisioners
|
30
|
+
# @return [Array<Hash<Symbol, Object>>] A collection of provisioner
|
31
|
+
# parameters in the order that they should be applied
|
32
|
+
# of provisioner types, and a list of provisioner instances for each type
|
33
|
+
# @example
|
34
|
+
# >> vm.provisioners
|
35
|
+
# => [
|
36
|
+
# {:type => :shell, :path => '/vagrant/bin/magic.sh'},
|
37
|
+
# {:type => :shell, :inline => '/bin/echo hello world'},
|
38
|
+
#
|
39
|
+
# {:type => :puppet, :manifest => 'foo.pp'},
|
40
|
+
# {:type => :puppet, :manifest => 'bar.pp', :modulepath => '/vagrant/modules'},
|
41
|
+
# ]
|
42
|
+
def_model_delegator :provisioners
|
43
|
+
|
44
|
+
# @!attribute [rw] forwarded_ports
|
45
|
+
# @return [Array<Hash<Symbol, Object>>] A collection of port mappings
|
46
|
+
# @example
|
47
|
+
# >> vm.forwarded_ports
|
48
|
+
# => [
|
49
|
+
# {:guest => 80, :host => 20080},
|
50
|
+
# {:guest => 443, :host => 20443},
|
51
|
+
# ]
|
52
|
+
def_model_delegator :forwarded_ports
|
53
|
+
|
54
|
+
# @!attribute [rw] private_networks
|
55
|
+
# @return [Array<Hash<Symbol, Object>>] A collection of IP address network
|
56
|
+
# settings.
|
57
|
+
# @example
|
58
|
+
# >> vm.private_networks
|
59
|
+
# => [
|
60
|
+
# {:ip => '10.20.4.1'},
|
61
|
+
# {:ip => '192.168.100.5', :netmask => '255.255.255.128'},
|
62
|
+
# ]
|
63
|
+
def_model_delegator :private_networks
|
64
|
+
|
65
|
+
# @!attribute [rw] synced_folders
|
66
|
+
# @return [Array<Hash<Symbol, Object>>]
|
67
|
+
# @example
|
68
|
+
# >> vm.synced_folders
|
69
|
+
# => [
|
70
|
+
# {:host_path => 'manifests/', :guest_path => '/root/manifests', :disabled => false},
|
71
|
+
# {:host_path => 'modules/', :guest_path => '/root/modules'},
|
72
|
+
# ]
|
73
|
+
#
|
74
|
+
def_model_delegator :synced_folders
|
75
|
+
|
76
|
+
# @!attribute [rw] guest
|
77
|
+
# @return [String] The guest type to use for this VM
|
78
|
+
def_model_attribute :guest
|
79
|
+
|
80
|
+
# @!attribute [rw] box
|
81
|
+
# @return [String] This configures what box the machine will be brought up
|
82
|
+
# against. The value here should be the name of an installed box or a
|
83
|
+
# shorthand name of a box in Vagrant Cloud.
|
84
|
+
def_model_attribute :box
|
85
|
+
|
86
|
+
# @!attribute [rw] box_url
|
87
|
+
# @return [String, Array<String>] The URL that the configured box can be
|
88
|
+
# found at. If `box` is a shorthand to a box in Vagrant Cloud then this
|
89
|
+
# value doesn't need to be specified. Otherwise, it should point to the
|
90
|
+
# proper place where the box can be found if it isn't installed.
|
91
|
+
#
|
92
|
+
# This can also be an array of multiple URLs. The URLs will be tried in
|
93
|
+
# order. Note that any client certificates, insecure download settings,
|
94
|
+
# and so on will apply to all URLs in this list.
|
95
|
+
#
|
96
|
+
# The URLs can also be local files by using the file:// scheme. For
|
97
|
+
# example: "file:///tmp/test.box".
|
98
|
+
def_model_attribute :box_url
|
99
|
+
|
100
|
+
# @!attribute [rw] box_download_checksum
|
101
|
+
# @return [String] The checksum of the box specified by `box_url`.
|
102
|
+
# If not specified, no checksum comparison will be done. If specified,
|
103
|
+
# Vagrant will compare the checksum of the downloaded box to this value
|
104
|
+
# and error if they do not match. Checksum checking is only done when
|
105
|
+
# Vagrant must download the box.
|
106
|
+
#
|
107
|
+
# If this is specified, then `box_download_checksum_type` must also be
|
108
|
+
# specified.
|
109
|
+
def_model_attribute :box_download_checksum
|
110
|
+
|
111
|
+
# @!attribute [rw] box_download_checksum_type
|
112
|
+
# @return [String] The type of checksum specified by
|
113
|
+
# `box_download_checksum` (if any). Supported values are currently `md5`,
|
114
|
+
# `sha1`, and `sha256`.
|
115
|
+
def_model_attribute :box_download_checksum_type
|
116
|
+
|
117
|
+
# @!attribute [rw] box_download_client_cert
|
118
|
+
# @return [String] Path to a client certificate to use when downloading the
|
119
|
+
# box, if it is necessary. By default, no client certificate is used to
|
120
|
+
# download the box.
|
121
|
+
def_model_attribute :box_download_client_cert
|
122
|
+
|
123
|
+
# @!attribute [rw] box_download_insecure
|
124
|
+
# @return [Boolean] If `true`, then SSL certificates from the server will
|
125
|
+
# not be verified. By default, if the URL is an HTTPS URL, then SSL certs
|
126
|
+
# will be verified.
|
127
|
+
def_model_attribute :box_download_insecure
|
128
|
+
|
129
|
+
# @!attribute [rw] box_check_update
|
130
|
+
# @return [Boolean] If true, Vagrant will check for updates to the
|
131
|
+
# configured box on every `vagrant up`. If an update is found, Vagrant
|
132
|
+
# will tell the user. By default this is `true`. Updates will only be
|
133
|
+
# checked for boxes that properly support updates (boxes from Vagrant
|
134
|
+
# Cloud or some other versioned box).
|
135
|
+
def_model_attribute :box_check_update
|
136
|
+
|
137
|
+
# @!attribute [rw] box_version
|
138
|
+
# @return [String] The version of the box to use. This defaults to ">= 0"
|
139
|
+
# (the latest version available). This can contain an arbitrary list of
|
140
|
+
# constraints, separated by commas, such as: >= 1.0, < 1.5. When
|
141
|
+
# constraints are given, Vagrant will use the latest available box
|
142
|
+
# satisfying these constraints.
|
143
|
+
def_model_attribute :box_version
|
144
|
+
|
145
|
+
# @!attribute [rw] name
|
146
|
+
# @return [String] The name of the instantiated box in this environment
|
147
|
+
def_model_attribute :name
|
148
|
+
|
149
|
+
# @!attribute [rw] hostname
|
150
|
+
# @return [String] The hostname the machine should have.
|
151
|
+
def_model_attribute :hostname
|
152
|
+
|
153
|
+
# @!attribute [rw] communicator
|
154
|
+
# @return [String] The name of the communicator to use when sending
|
155
|
+
# commands to this box. Set to 'winrm' for Windows VMs.
|
156
|
+
def_model_attribute :communicator
|
157
|
+
|
158
|
+
def initialize
|
159
|
+
@defaults = {
|
160
|
+
:providers => [],
|
161
|
+
:provisioners => [],
|
162
|
+
:forwarded_ports => [],
|
163
|
+
:private_networks => [],
|
164
|
+
:synced_folders => [],
|
165
|
+
}
|
166
|
+
end
|
167
|
+
|
168
|
+
def to_proc
|
169
|
+
Proc.new do |global_config|
|
170
|
+
global_config.vm.define(attr(:name)) do |config|
|
171
|
+
vm_config = config.vm
|
172
|
+
|
173
|
+
with_attr(:box) { |val| vm_config.box = val }
|
174
|
+
with_attr(:box_url) { |val| vm_config.box_url = val }
|
175
|
+
with_attr(:box_download_checksum) { |val| vm_config.box_download_checksum = val }
|
176
|
+
with_attr(:box_download_checksum_type) { |val| vm_config.box_download_checksum_type = val }
|
177
|
+
with_attr(:box_download_client_cert) { |val| vm_config.box_download_client_cert = val }
|
178
|
+
with_attr(:box_download_insecure) { |val| vm_config.box_download_insecure = val }
|
179
|
+
with_attr(:box_check_update) { |val| vm_config.box_check_update = val }
|
180
|
+
with_attr(:box_version) { |val| vm_config.box_version = val }
|
181
|
+
|
182
|
+
with_attr(:hostname) { |val| vm_config.hostname = attr(:hostname) }
|
183
|
+
with_attr(:guest) { |val| vm_config.guest = attr(:guest) }
|
184
|
+
|
185
|
+
with_attr(:communicator) { |val| vm_config.communicator = attr(:communicator) }
|
186
|
+
|
187
|
+
eval_models(vm_config)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
private
|
193
|
+
|
194
|
+
def eval_provisioners(vm_config)
|
195
|
+
attr(:provisioners).each do |hash|
|
196
|
+
p = ConfigBuilder::Model::Provisioner.new_from_hash(hash)
|
197
|
+
p.call(vm_config)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def eval_providers(vm_config)
|
202
|
+
attr(:providers).each do |hash|
|
203
|
+
p = ConfigBuilder::Model::Provider.new_from_hash(hash)
|
204
|
+
p.call(vm_config)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def eval_provider(vm_config)
|
209
|
+
if attr(:provider)
|
210
|
+
p = ConfigBuilder::Model::Provider.new_from_hash(attr(:provider))
|
211
|
+
p.call(vm_config)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def eval_private_networks(vm_config)
|
216
|
+
attr(:private_networks).each do |hash|
|
217
|
+
n = ConfigBuilder::Model::Network::PrivateNetwork.new_from_hash(hash)
|
218
|
+
n.call(vm_config)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def eval_forwarded_ports(vm_config)
|
223
|
+
attr(:forwarded_ports).each do |hash|
|
224
|
+
f = ConfigBuilder::Model::Network::ForwardedPort.new_from_hash(hash)
|
225
|
+
f.call(vm_config)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def eval_synced_folders(vm_config)
|
230
|
+
attr(:synced_folders).each do |hash|
|
231
|
+
f = ConfigBuilder::Model::SyncedFolder.new_from_hash(hash)
|
232
|
+
f.call(vm_config)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|