vagrant-config_builder 0.15.1 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +18 -4
  3. data/CHANGELOG +44 -0
  4. data/Gemfile +3 -4
  5. data/lib/config_builder/model/base.rb +182 -8
  6. data/lib/config_builder/model/network/forwarded_port.rb +34 -13
  7. data/lib/config_builder/model/network/private_network.rb +17 -1
  8. data/lib/config_builder/model/network/public_network.rb +39 -0
  9. data/lib/config_builder/model/nfs.rb +33 -0
  10. data/lib/config_builder/model/provider/aws.rb +16 -39
  11. data/lib/config_builder/model/provider/azure.rb +11 -33
  12. data/lib/config_builder/model/provider/base.rb +37 -0
  13. data/lib/config_builder/model/provider/libvirt.rb +33 -39
  14. data/lib/config_builder/model/provider/openstack.rb +69 -0
  15. data/lib/config_builder/model/provider/openstack_plugin.rb +46 -0
  16. data/lib/config_builder/model/provider/softlayer.rb +85 -0
  17. data/lib/config_builder/model/provider/virtualbox.rb +84 -17
  18. data/lib/config_builder/model/provider/vmware.rb +6 -4
  19. data/lib/config_builder/model/provider/vsphere.rb +33 -15
  20. data/lib/config_builder/model/provisioner/base.rb +33 -0
  21. data/lib/config_builder/model/provisioner/file.rb +1 -10
  22. data/lib/config_builder/model/provisioner/puppet.rb +32 -22
  23. data/lib/config_builder/model/provisioner/puppet_server.rb +21 -15
  24. data/lib/config_builder/model/provisioner/shell.rb +28 -10
  25. data/lib/config_builder/model/root.rb +28 -4
  26. data/lib/config_builder/model/ssh.rb +29 -11
  27. data/lib/config_builder/model/synced_folder.rb +83 -14
  28. data/lib/config_builder/model/vm.rb +111 -52
  29. data/lib/config_builder/model/winrm.rb +27 -7
  30. data/lib/config_builder/model.rb +9 -1
  31. data/lib/config_builder/model_delegator.rb +5 -24
  32. data/lib/config_builder/version.rb +1 -1
  33. data/spec/integration/vagrant/root_config_spec.rb +89 -0
  34. data/spec/integration/vagrant/vm_config_spec.rb +101 -0
  35. data/spec/integration/vagrant/vm_provider_spec.rb +57 -0
  36. data/spec/integration/vagrant/vm_provisioner_spec.rb +90 -0
  37. data/spec/spec_helper.rb +6 -2
  38. data/spec/{config_builder → unit}/filter/boxes_spec.rb +0 -0
  39. data/spec/{config_builder → unit}/filter/roles_spec.rb +0 -0
  40. data/spec/{config_builder → unit}/loader/yaml_spec.rb +0 -0
  41. data/spec/unit/model/base_spec.rb +122 -0
  42. data/spec/{config_builder → unit}/model/provider/vmware_fusion_spec.rb +6 -5
  43. data/templates/locales/en.yml +4 -0
  44. metadata +33 -20
@@ -1,49 +1,59 @@
1
1
  # @see http://docs.vagrantup.com/v2/provisioning/puppet_apply.html
2
- class ConfigBuilder::Model::Provisioner::Puppet < ConfigBuilder::Model::Base
2
+ class ConfigBuilder::Model::Provisioner::Puppet < ConfigBuilder::Model::Provisioner::Base
3
+
4
+ # @!attribute [rw] binary_path
5
+ # @return [String] The path to Puppet's `bin` directory.
6
+ def_model_attribute :binary_path
3
7
 
4
8
  # @!attribute [rw] manifests_path
5
9
  # @return [String] The path to the puppet manifests.
6
- attr_accessor :manifests_path
10
+ def_model_attribute :manifests_path
7
11
 
8
12
  # @!attribute [rw] manifest_file
9
13
  # @return [String] The name of the manifest to apply
10
- attr_accessor :manifest_file
14
+ def_model_attribute :manifest_file
11
15
 
12
16
  # @!attribute [rw] module_path
13
17
  # @return [String] A colon separated set of filesystem paths for Puppet
14
- attr_accessor :module_path
18
+ def_model_attribute :module_path
15
19
 
16
20
  # @!attribute [rw] facter
17
21
  # @return [Hash] A hash of values to use as facts
18
- attr_accessor :facter
22
+ def_model_attribute :facter
19
23
 
20
24
  # @!attribute [rw] options
21
25
  # @return [String] An arbitrary set of arguments for the `puppet` command
22
- attr_accessor :options
26
+ def_model_attribute :options
23
27
 
24
28
  # @!attribute [rw] hiera_config_path
25
29
  # @return [String] Path to the Hiera configuration file stored on the host
26
30
  # @since 0.15.0
27
- attr_accessor :hiera_config_path
31
+ def_model_attribute :hiera_config_path
28
32
 
29
33
  # @!attribute [rw] working_directory
30
34
  # @return [String] Path in the guest that will be the working directory when Puppet is executed
31
35
  # @since 0.15.0
32
- attr_accessor :working_directory
33
-
34
- def to_proc
35
- Proc.new do |vm_config|
36
- vm_config.provision :puppet do |puppet_config|
37
- with_attr(:manifests_path) { |val| puppet_config.manifests_path = val }
38
- with_attr(:manifest_file) { |val| puppet_config.manifest_file = val }
39
- with_attr(:module_path) { |val| puppet_config.module_path = val }
40
- with_attr(:facter) { |val| puppet_config.facter = val }
41
- with_attr(:options) { |val| puppet_config.options = val }
42
- with_attr(:hiera_config_path) { |val| puppet_config.hiera_config_path = val }
43
- with_attr(:working_directory) { |val| puppet_config.working_directory = val }
44
- end
45
- end
46
- end
36
+ def_model_attribute :working_directory
37
+
38
+ # @!attribute [rw] environment
39
+ # @return [String] Name of the Puppet environment.
40
+ def_model_attribute :environment
41
+
42
+ # @!attribute [rw] environment_path
43
+ # @return [String] Path to the directory that contains environment files on the host disk.
44
+ def_model_attribute :environment_path
45
+
46
+ # @!attribute [rw] synced_folder_type
47
+ # @return [String] The type of synced folders to use when sharing the data required for the provisioner to work properly.
48
+ def_model_attribute :synced_folder_type
49
+
50
+ # @!attribute [rw] synced_folder_args
51
+ # @return [Array<String>] Arguments that are passed to the folder sync.
52
+ def_model_attribute :synced_folder_args
53
+
54
+ # @!attribute [rw] temp_dir
55
+ # @return [String] The directory where the data associated with the Puppet run will be stored on the guest machine.
56
+ def_model_attribute :temp_dir
47
57
 
48
58
  ConfigBuilder::Model::Provisioner.register('puppet', self)
49
59
  end
@@ -1,27 +1,33 @@
1
1
  # @see http://docs.vagrantup.com/v2/provisioning/puppet_agent.html
2
- class ConfigBuilder::Model::Provisioner::PuppetServer < ConfigBuilder::Model::Base
2
+ class ConfigBuilder::Model::Provisioner::PuppetServer < ConfigBuilder::Model::Provisioner::Base
3
+
4
+ # @!attribute [rw] binary_path
5
+ # @return [String]
6
+ def_model_attribute :binary_path
7
+
8
+ # @!attribute [rw] client_cert_path
9
+ # @return [String]
10
+ def_model_attribute :client_cert_path
11
+
12
+ # @!attribute [rw] client_private_key_path
13
+ # @return [String]
14
+ def_model_attribute :client_private_key_path
15
+
16
+ # @!attribute [rw] facter
17
+ # @return [Hash]
18
+ def_model_attribute :facter
3
19
 
4
20
  # @!attribute [rw] puppet_server
5
21
  # @return [String]
6
- attr_accessor :puppet_server
22
+ def_model_attribute :puppet_server
7
23
 
8
- # @!attribute [rw] node_name
24
+ # @!attribute [rw] puppet_node
9
25
  # @return [String]
10
- attr_accessor :node_name
26
+ def_model_attribute :puppet_node
11
27
 
12
28
  # @!attribute [rw] options
13
29
  # @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
30
+ def_model_attribute :options
25
31
 
26
32
  ConfigBuilder::Model::Provisioner.register('puppet_server', self)
27
33
  end
@@ -1,5 +1,5 @@
1
1
  # @see http://docs.vagrantup.com/v2/provisioning/shell.html
2
- class ConfigBuilder::Model::Provisioner::Shell < ConfigBuilder::Model::Base
2
+ class ConfigBuilder::Model::Provisioner::Shell < ConfigBuilder::Model::Provisioner::Base
3
3
 
4
4
  # @!attribute [rw] inline
5
5
  # @return [String] The inline shell command to run
@@ -13,15 +13,33 @@ class ConfigBuilder::Model::Provisioner::Shell < ConfigBuilder::Model::Base
13
13
  # @return [String] A string acting as an argument vector to the command.
14
14
  def_model_attribute :args
15
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
16
+ # @!attribute [rw] env
17
+ # @return [Hash] A hash of values passed in as environment variables to the script.
18
+ def_model_attribute :env
19
+
20
+ # @!attribute [rw] binary
21
+ # @return [Boolean] Whether Windows line endings are replaced with Unix line endings.
22
+ def_model_attribute :binary
23
+
24
+ # @!attribute [rw] privileged
25
+ # @return [Boolean] Specifies whether to execute the script as a privileged user or not.
26
+ def_model_attribute :privileged
27
+
28
+ # @!attribute [rw] upload_path
29
+ # @return [String] The remote path where the shell script will be uploaded to.
30
+ def_model_attribute :upload_path
31
+
32
+ # @!attribute [rw] keep_color
33
+ # @return [Boolean] Whether Vagrant should use coloring for the output.
34
+ def_model_attribute :keep_color
35
+
36
+ # @!attribute [rw] powershell_args
37
+ # @return [String] Extra arguments to pass to PowerShell if you are provisioning with PowerShell on Windows.
38
+ def_model_attribute :powershell_args
39
+
40
+ # @!attribute [rw] powershell_elevated_interactive
41
+ # @return [Boolean] Whether to run an elevated script in interactive mode on Windows.
42
+ def_model_attribute :powershell_elevated_interactive
25
43
 
26
44
  ConfigBuilder::Model::Provisioner.register('shell', self)
27
45
  end
@@ -2,11 +2,9 @@
2
2
  #
3
3
  # @see http://docs.vagrantup.com/v2/vagrantfile/index.html
4
4
  class ConfigBuilder::Model::Root < ConfigBuilder::Model::Base
5
-
6
- include ConfigBuilder::ModelDelegator
7
-
8
5
  def_model_delegator :vagrant
9
6
  def_model_delegator :vms
7
+ def_model_delegator :vm_defaults
10
8
 
11
9
  # @!attribute [rw] ssh
12
10
  # @return [Hash<Symbol, Object>] The ssh configuration for all VMs
@@ -18,6 +16,16 @@ class ConfigBuilder::Model::Root < ConfigBuilder::Model::Base
18
16
  # }
19
17
  def_model_delegator :ssh
20
18
 
19
+ # @!attribute [rw] nfs
20
+ # @return [Hash<Symbol, Object>] The nfs configuration for all VMs
21
+ # @example
22
+ # >> config.nfs
23
+ # => {
24
+ # :nfs_export => true,
25
+ # :nfs_version => 4
26
+ # }
27
+ def_model_delegator :nfs
28
+
21
29
  # @!attribute [rw] winrm
22
30
  # @return [Hash<Symbol, Object>] The winrm configuration for all VMs
23
31
  # @example
@@ -40,10 +48,19 @@ class ConfigBuilder::Model::Root < ConfigBuilder::Model::Base
40
48
 
41
49
  private
42
50
 
51
+ def eval_vm_defaults(root_config)
52
+ with_attr(:vm_defaults) do |hash|
53
+ v = ConfigBuilder::Model::VM.new_from_hash(hash)
54
+ v.call(root_config)
55
+ end
56
+ end
57
+
43
58
  def eval_vms(root_config)
44
59
  attr(:vms).each do |hash|
45
60
  v = ConfigBuilder::Model::VM.new_from_hash(hash)
46
- v.call(root_config)
61
+ root_config.vm.define(v.instance_id, v.instance_options) do |vm_config|
62
+ v.call(vm_config)
63
+ end
47
64
  end
48
65
  end
49
66
 
@@ -53,6 +70,13 @@ class ConfigBuilder::Model::Root < ConfigBuilder::Model::Base
53
70
  end
54
71
  end
55
72
 
73
+ def eval_nfs(root_config)
74
+ with_attr(:nfs) do |nfs_config|
75
+ f = ConfigBuilder::Model::NFS.new_from_hash(nfs_config)
76
+ f.call(root_config)
77
+ end
78
+ end
79
+
56
80
  def eval_ssh(root_config)
57
81
  with_attr(:ssh) do |ssh_config|
58
82
  f = ConfigBuilder::Model::SSH.new_from_hash(ssh_config)
@@ -35,6 +35,10 @@ class ConfigBuilder::Model::SSH < ConfigBuilder::Model::Base
35
35
  # option.
36
36
  def_model_attribute :guest_port
37
37
 
38
+ # @!attribute [rw] keep_alive
39
+ # @return [Boolean]
40
+ def_model_attribute :keep_alive
41
+
38
42
  # @!attribute [rw] private_key_path
39
43
  # @return [String] The path to the private key to use to SSH into the guest
40
44
  # machine. By default this is the insecure private key that ships with
@@ -58,6 +62,11 @@ class ConfigBuilder::Model::SSH < ConfigBuilder::Model::Base
58
62
  # enabled. Defaults to `false`.
59
63
  def_model_attribute :forward_x11
60
64
 
65
+ # @!attribute [rw] forward_env
66
+ # @return [Array<String>] An array of host environment variables to forward
67
+ # to the guest.
68
+ def_model_attribute :forward_env
69
+
61
70
  # @!attribute [rw] insert_key
62
71
  # @return [Boolean] If `true`, Vagrant will automatically insert an insecure
63
72
  # keypair to use for SSH. By default, this is `true`. This only has an
@@ -89,22 +98,31 @@ class ConfigBuilder::Model::SSH < ConfigBuilder::Model::Base
89
98
  # Vagrant.
90
99
  def_model_attribute :shell
91
100
 
101
+ # @!attribute [rw] sudo_command
102
+ # @return [String] The command to use when executing a command with sudo.
103
+ # This defaults to `sudo -E -H %c`. The `%c` will be replaced by the
104
+ # command that is being executed.
105
+ def_model_attribute :sudo_command
106
+
92
107
  def to_proc
93
108
  Proc.new do |global_config|
94
109
  ssh = global_config.ssh
95
110
 
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 }
111
+ with_attr(:username) { |val| ssh.username = val }
112
+ with_attr(:password) { |val| ssh.password = val }
113
+ with_attr(:host) { |val| ssh.host = val }
114
+ with_attr(:port) { |val| ssh.port = val }
115
+ with_attr(:guest_port) { |val| ssh.guest_port = val }
116
+ with_attr(:keep_alive) { |val| ssh.keep_alive = val }
101
117
  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 }
118
+ with_attr(:forward_agent) { |val| ssh.forward_agent = val }
119
+ with_attr(:forward_x11) { |val| ssh.forward_x11 = val }
120
+ with_attr(:forward_env) { |val| ssh.forward_env = val }
121
+ with_attr(:insert_key) { |val| ssh.insert_key = val }
122
+ with_attr(:proxy_command) { |val| ssh.proxy_command = val }
123
+ with_attr(:pty) { |val| ssh.pty = val }
124
+ with_attr(:shell) { |val| ssh.shell = val }
125
+ with_attr(:sudo_command) { |val| ssh.sudo_command = val }
108
126
  end
109
127
  end
110
128
  end
@@ -4,30 +4,82 @@
4
4
  class ConfigBuilder::Model::SyncedFolder < ConfigBuilder::Model::Base
5
5
 
6
6
  # @!attribute [rw] host_path
7
- # @return [String] The host file path to mount on the guest
7
+ # @return [String] The host file path to mount on the guest.
8
8
  def_model_attribute :host_path
9
9
 
10
10
  # @!attribute [rw] guest_path
11
- # @return [String] The guest file path to be used as the mount point
11
+ # @return [String] The guest file path to be used as the mount point.
12
12
  def_model_attribute :guest_path
13
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
14
+ # @!attribute [rw] create
15
+ # @return [Boolean] If true, the host path will be created if it does not
16
+ # exist.
17
+ def_model_attribute :create
18
+
19
+ # @!attribute [rw] mount_options
20
+ # @return [Array<String>] A list of additional options to pass to the mount.
21
+ # command.
22
+ def_model_attribute :mount_options
18
23
 
19
24
  # @!attribute [rw] disabled
20
25
  # @return [Boolean] If the mount point should be disabled.
21
26
  def_model_attribute :disabled
22
27
 
23
- # @!attribute [rw] nfs
24
- # @return [Boolean] If the mount point should use NFS
25
- def_model_attribute :nfs
28
+ # @!attribute [rw] group
29
+ # @return [String] The group that will own the synced folder. By default this
30
+ # will be the SSH user.
31
+ def_model_attribute :group
32
+
33
+ # @!attribute [rw] owner
34
+ # @return [String] The user who should be the owner of this synced folder. By
35
+ # default this will be the SSH user.
36
+ def_model_attribute :owner
26
37
 
27
38
  # @!attribute [rw] type
28
39
  # @return [String] The method for syncing folder to guest.
29
40
  def_model_attribute :type
30
41
 
42
+ # @!attribute [rw] nfs_export
43
+ # @return [Boolean] Whether Vagrant should manage entries in /etc/exports.
44
+ def_model_attribute :nfs_export
45
+
46
+ # @!attribute [rw] nfs_export
47
+ # @return [nfs_udp] Whether or not to use UDP as the transport.
48
+ def_model_attribute :nfs_udp
49
+
50
+ # @!attribute [rw] nfs_version
51
+ # @return [Fixnum, String] The NFS protocol version to use.
52
+ def_model_attribute :nfs_version
53
+
54
+ # @!attribute [rw] rsync__args
55
+ # @return [Array<String>] A list of arguments to supply to rsync.
56
+ def_model_attribute :rsync__args
57
+
58
+ # @!attribute [rw] rsync__auto
59
+ # @return [Boolean] If false, then rsync-auto will not watch and
60
+ # automatically sync this folder.
61
+ def_model_attribute :rsync__auto
62
+
63
+ # @!attribute [rw] rsync__chown
64
+ # @return [Boolean] If false, then the owner and group options for the synced
65
+ # folder are ignored and Vagrant will not execute a recursive chown.
66
+ def_model_attribute :rsync__chown
67
+
68
+ # @!attribute [rw] rsync__exclude
69
+ # @return [String, Array<String>] A list of files or directories to exclude
70
+ # from the sync.
71
+ def_model_attribute :rsync__exclude
72
+
73
+ # @!attribute [rw] rsync__rsync_path
74
+ # @return [String] The path on the remote host where rsync is and how it is
75
+ # executed.
76
+ def_model_attribute :rsync__rsync_path
77
+
78
+ # @!attribute [rw] rsync__verbose
79
+ # @return [Boolean] If true, then the output from the rsync process will be
80
+ # echoed to the console.
81
+ def_model_attribute :rsync__verbose
82
+
31
83
  def to_proc
32
84
  Proc.new do |vm_config|
33
85
  vm_config.synced_folder(attr(:host_path), attr(:guest_path), folder_opts)
@@ -38,11 +90,28 @@ class ConfigBuilder::Model::SyncedFolder < ConfigBuilder::Model::Base
38
90
 
39
91
  def folder_opts
40
92
  h = {}
41
- with_attr(:extra) { |val| h[:extra] = val }
42
- with_attr(:disabled) { |val| h[:disabled] = val }
43
- with_attr(:nfs) { |val| h[:nfs] = val }
44
- with_attr(:type) { |val| h[:type] = val }
45
-
93
+ with_attr(:create) { |val| h[:create] = val }
94
+ with_attr(:mount_options) { |val| h[:mount_options] = val }
95
+ with_attr(:disabled) { |val| h[:disabled] = val }
96
+ with_attr(:group) { |val| h[:group] = val }
97
+ with_attr(:create) { |val| h[:create] = val }
98
+ with_attr(:extra) { |val| h[:extra] = val }
99
+ with_attr(:disabled) { |val| h[:disabled] = val }
100
+ with_attr(:group) { |val| h[:group] = val }
101
+ with_attr(:nfs) { |val| h[:nfs] = val }
102
+ with_attr(:owner) { |val| h[:owner] = val }
103
+ with_attr(:type) { |val| h[:type] = val }
104
+ # NFS
105
+ with_attr(:nfs_export) { |val| h[:nfs_export] = val }
106
+ with_attr(:nfs_udp) { |val| h[:nfs_udp] = val }
107
+ with_attr(:nfs_version) { |val| h[:nfs_version] = val }
108
+ # RSync
109
+ with_attr(:rsync__args) { |val| h[:rsync__args] = val }
110
+ with_attr(:rsync__auto) { |val| h[:rsync__auto] = val }
111
+ with_attr(:rsync__chown) { |val| h[:rsync__chown] = val }
112
+ with_attr(:rsync__exclude) { |val| h[:rsync__exclude] = val }
113
+ with_attr(:rsync__rsync_path) { |val| h[:rsync__rsync_path] = val }
114
+ with_attr(:rsync__verbose) { |val| h[:rsync__verbose] = val }
46
115
  h
47
116
  end
48
117
  end
@@ -1,8 +1,5 @@
1
1
  # @see http://docs.vagrantup.com/v2/vagrantfile/machine_settings.html
2
2
  class ConfigBuilder::Model::VM < ConfigBuilder::Model::Base
3
-
4
- include ConfigBuilder::ModelDelegator
5
-
6
3
  # @!attribute [rw] provider
7
4
  # @return [Hash<Symbol, Object>] The provider configuration for
8
5
  # this VM
@@ -64,6 +61,17 @@ class ConfigBuilder::Model::VM < ConfigBuilder::Model::Base
64
61
  # ]
65
62
  def_model_delegator :private_networks
66
63
 
64
+ # @!attribute [rw] public_networks
65
+ # @return [Array<Hash<Symbol, Object>>] A collection of IP address network
66
+ # settings.
67
+ # @example
68
+ # >> vm.public_networks
69
+ # => [
70
+ # {:ip => '10.20.4.1'},
71
+ # {:bridge: "en1: Wi-Fi (AirPort)"},
72
+ # ]
73
+ def_model_delegator :public_networks
74
+
67
75
  # @!attribute [rw] synced_folders
68
76
  # @return [Array<Hash<Symbol, Object>>]
69
77
  # @example
@@ -75,9 +83,28 @@ class ConfigBuilder::Model::VM < ConfigBuilder::Model::Base
75
83
  #
76
84
  def_model_delegator :synced_folders
77
85
 
78
- # @!attribute [rw] guest
79
- # @return [String] The guest type to use for this VM
80
- def_model_attribute :guest
86
+ # @!attribute [rw] name
87
+ # @return [String] The name of the instantiated box in this environment.
88
+ def_model_id :name
89
+
90
+ # @!attribute [rw] autostart
91
+ # @return [Boolean] If true, vagrant will start the box on "vagrant up".
92
+ # If false, vagrant must be given the box name explicitly or it will not
93
+ # start.
94
+ def_model_option :autostart
95
+
96
+ # @!attribute [rw] allowed_synced_folder_types
97
+ # @return [Array<String>]
98
+ def_model_attribute :allowed_synced_folder_types
99
+
100
+ # @!attribute [rw] base_mac
101
+ # @return [String] MAC address of the NAT device.
102
+ def_model_attribute :base_mac
103
+
104
+ # @!attribute [rw] autostart
105
+ # @return [Fixnum] The time in seconds that Vagrant will wait for the machine
106
+ # to boot and be accessible. By default this is 300 seconds.
107
+ def_model_attribute :boot_timeout
81
108
 
82
109
  # @!attribute [rw] box
83
110
  # @return [String] This configures what box the machine will be brought up
@@ -85,6 +112,14 @@ class ConfigBuilder::Model::VM < ConfigBuilder::Model::Base
85
112
  # shorthand name of a box in Vagrant Cloud.
86
113
  def_model_attribute :box
87
114
 
115
+ # @!attribute [rw] box_check_update
116
+ # @return [Boolean] If true, Vagrant will check for updates to the
117
+ # configured box on every `vagrant up`. If an update is found, Vagrant
118
+ # will tell the user. By default this is `true`. Updates will only be
119
+ # checked for boxes that properly support updates (boxes from Vagrant
120
+ # Cloud or some other versioned box).
121
+ def_model_attribute :box_check_update
122
+
88
123
  # @!attribute [rw] box_url
89
124
  # @return [String, Array<String>] The URL that the configured box can be
90
125
  # found at. If `box` is a shorthand to a box in Vagrant Cloud then this
@@ -99,6 +134,29 @@ class ConfigBuilder::Model::VM < ConfigBuilder::Model::Base
99
134
  # example: "file:///tmp/test.box".
100
135
  def_model_attribute :box_url
101
136
 
137
+ # @!attribute [rw] box_server_url
138
+ # @return [String]
139
+ def_model_attribute :box_server_url
140
+
141
+ # @!attribute [rw] box_version
142
+ # @return [String] The version of the box to use. This defaults to ">= 0"
143
+ # (the latest version available). This can contain an arbitrary list of
144
+ # constraints, separated by commas, such as: >= 1.0, < 1.5. When
145
+ # constraints are given, Vagrant will use the latest available box
146
+ # satisfying these constraints.
147
+ def_model_attribute :box_version
148
+
149
+ # @!attribute [rw] box_download_ca_cert
150
+ # @return [String] Path to a CA cert bundle to use when downloading a box
151
+ # directly. By default, Vagrant will use the Mozilla CA cert bundle.
152
+ def_model_attribute :box_download_ca_cert
153
+
154
+ # @!attribute [rw] box_download_ca_path
155
+ # @return [String] Path to a directory containing CA certificates for
156
+ # downloading a box directly. By default, Vagrant will use the Mozilla CA
157
+ # cert bundle.
158
+ def_model_attribute :box_download_ca_path
159
+
102
160
  # @!attribute [rw] box_download_checksum
103
161
  # @return [String] The checksum of the box specified by `box_url`.
104
162
  # If not specified, no checksum comparison will be done. If specified,
@@ -128,40 +186,42 @@ class ConfigBuilder::Model::VM < ConfigBuilder::Model::Base
128
186
  # will be verified.
129
187
  def_model_attribute :box_download_insecure
130
188
 
131
- # @!attribute [rw] box_check_update
132
- # @return [Boolean] If true, Vagrant will check for updates to the
133
- # configured box on every `vagrant up`. If an update is found, Vagrant
134
- # will tell the user. By default this is `true`. Updates will only be
135
- # checked for boxes that properly support updates (boxes from Vagrant
136
- # Cloud or some other versioned box).
137
- def_model_attribute :box_check_update
189
+ # @!attribute [rw] box_download_location_trusted
190
+ # @return [Boolean] If ´true´, then all HTTP redirects will be treated as
191
+ # trusted. That means credentials used for initial URL will be used for all
192
+ # subsequent redirects. By default, redirect locations are untrusted so
193
+ # credentials (if specified) used only for initial HTTP request.
194
+ def_model_attribute :box_download_location_trusted
138
195
 
139
- # @!attribute [rw] box_version
140
- # @return [String] The version of the box to use. This defaults to ">= 0"
141
- # (the latest version available). This can contain an arbitrary list of
142
- # constraints, separated by commas, such as: >= 1.0, < 1.5. When
143
- # constraints are given, Vagrant will use the latest available box
144
- # satisfying these constraints.
145
- def_model_attribute :box_version
196
+ # @!attribute [rw] communicator
197
+ # @return [String] The name of the communicator to use when sending
198
+ # commands to this box. Set to 'winrm' for Windows VMs.
199
+ def_model_attribute :communicator
146
200
 
147
- # @!attribute [rw] name
148
- # @return [String] The name of the instantiated box in this environment
149
- def_model_attribute :name
201
+ # @!attribute [rw] graceful_halt_timeout
202
+ # @return [Fixnum] The time in seconds that Vagrant will wait for the machine
203
+ # to
204
+ # gracefully halt when vagrant halt is called. Defaults to 60 seconds.
205
+ def_model_attribute :graceful_halt_timeout
206
+
207
+ # @!attribute [rw] guest
208
+ # @return [String] The guest type to use for this VM.
209
+ def_model_attribute :guest
150
210
 
151
211
  # @!attribute [rw] hostname
152
212
  # @return [String] The hostname the machine should have.
153
213
  def_model_attribute :hostname
154
214
 
155
- # @!attribute [rw] communicator
156
- # @return [String] The name of the communicator to use when sending
157
- # commands to this box. Set to 'winrm' for Windows VMs.
158
- def_model_attribute :communicator
215
+ # @!attribute [rw] post_up_message
216
+ # @return [String] A message to show after vagrant up. This will be shown to
217
+ # the user and is useful for containing instructions such as how to access
218
+ # various components of the development environment.
219
+ def_model_attribute :post_up_message
159
220
 
160
- # @!attribute [rw] autostart
161
- # @return [Boolean] If true, vagrant will start the box on "vagrant up".
162
- # If false, vagrant must be given the box name explicitly or it will not
163
- # start.
164
- def_model_attribute :autostart
221
+ # @!attribute [rw] usable_port_range
222
+ # @return [String] A range of ports Vagrant can use for handling port
223
+ # collisions and such. Defaults to 2200..2250.
224
+ def_model_attribute :usable_port_range
165
225
 
166
226
  def initialize
167
227
  @defaults = {
@@ -169,35 +229,27 @@ class ConfigBuilder::Model::VM < ConfigBuilder::Model::Base
169
229
  :provisioners => [],
170
230
  :forwarded_ports => [],
171
231
  :private_networks => [],
232
+ :public_networks => [],
172
233
  :synced_folders => [],
173
234
  :autostart => true,
174
235
  }
175
236
  end
176
237
 
177
238
  def to_proc
178
- Proc.new do |global_config|
179
- global_config.vm.define(attr(:name), autostart: attr(:autostart)) do |config|
180
- vm_config = config.vm
181
-
182
- with_attr(:box) { |val| vm_config.box = val }
183
- with_attr(:box_url) { |val| vm_config.box_url = val }
184
- with_attr(:box_download_checksum) { |val| vm_config.box_download_checksum = val }
185
- with_attr(:box_download_checksum_type) { |val| vm_config.box_download_checksum_type = val }
186
- with_attr(:box_download_client_cert) { |val| vm_config.box_download_client_cert = val }
187
- with_attr(:box_download_insecure) { |val| vm_config.box_download_insecure = val }
188
- with_attr(:box_check_update) { |val| vm_config.box_check_update = val }
189
- with_attr(:box_version) { |val| vm_config.box_version = val }
190
-
191
- with_attr(:hostname) { |val| vm_config.hostname = attr(:hostname) }
192
- with_attr(:guest) { |val| vm_config.guest = attr(:guest) }
193
-
194
- with_attr(:communicator) { |val| vm_config.communicator = attr(:communicator) }
195
-
196
- eval_models(vm_config)
197
- end
239
+ Proc.new do |config|
240
+ vm_config = config.vm
241
+
242
+ configure!(vm_config)
243
+ eval_models(vm_config)
198
244
  end
199
245
  end
200
246
 
247
+
248
+ # @private
249
+ def configure_usable_port_range(config, val)
250
+ config.usable_port_range = Range.new(*val.split('..').map(&:to_i))
251
+ end
252
+
201
253
  private
202
254
 
203
255
  def eval_provisioners(vm_config)
@@ -232,6 +284,13 @@ class ConfigBuilder::Model::VM < ConfigBuilder::Model::Base
232
284
  end
233
285
  end
234
286
 
287
+ def eval_public_networks(vm_config)
288
+ attr(:public_networks).each do |hash|
289
+ n = ConfigBuilder::Model::Network::PublicNetwork.new_from_hash(hash)
290
+ n.call(vm_config)
291
+ end
292
+ end
293
+
235
294
  def eval_forwarded_ports(vm_config)
236
295
  attr(:forwarded_ports).each do |hash|
237
296
  f = ConfigBuilder::Model::Network::ForwardedPort.new_from_hash(hash)