Class: VagrantPlugins::WindowsDomain::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-windows-domain/config.rb

Overview

The “Configuration” represents a configuration of how the WindowsDomain provisioner should behave: authentication mechanism etc.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/vagrant-windows-domain/config.rb', line 61

def initialize
  super
  @domain            = UNSET_VALUE
  @computer_name     = UNSET_VALUE
  @username          = UNSET_VALUE
  @password          = UNSET_VALUE
  @join_options      = {}
  @ou_path           = UNSET_VALUE
  @primary_dns       = UNSET_VALUE
  @secondary_dns     = UNSET_VALUE
  @unsecure          = UNSET_VALUE
  @rename            = UNSET_VALUE
  @logger            = Log4r::Logger.new("vagrant::vagrant_windows_domain")
end

Instance Attribute Details

#computer_nameObject

The new Computer Name to use when joining the domain. Specifies a new name for the computer in the new domain. Uses the -NameName Option.



17
18
19
# File 'lib/vagrant-windows-domain/config.rb', line 17

def computer_name
  @computer_name
end

#domainObject

The Windows Domain to join.

Setting this will result in an additional restart.



13
14
15
# File 'lib/vagrant-windows-domain/config.rb', line 13

def domain
  @domain
end

#join_optionsObject

The set of Advanced options to pass when joining the Domain.

See (technet.microsoft.com/en-us/library/hh849798.aspx) for detail. NOTE: If we user :computer_name from above this needs to be merged!!



34
35
36
# File 'lib/vagrant-windows-domain/config.rb', line 34

def join_options
  @join_options
end

#ou_pathObject

Organisational Unit path in AD.

Specifies an organizational unit (OU) for the domain account. Enter the full distinguished name of the OU in quotation marks. The default value is the default OU for machine objects in the domain.



41
42
43
# File 'lib/vagrant-windows-domain/config.rb', line 41

def ou_path
  @ou_path
end

#passwordObject

The Password to use when authenticating against the Domain.

Specifies the password of a user account that has permission to join the computers to a new domain.



28
29
30
# File 'lib/vagrant-windows-domain/config.rb', line 28

def password
  @password
end

#primary_dnsObject

IP address of primary DNS server

Specifies the IP address you want assigned as the primary DNS server for the primary nic



46
47
48
# File 'lib/vagrant-windows-domain/config.rb', line 46

def primary_dns
  @primary_dns
end

#renameObject

The trigger whether plugin should rename the computer or omit the renaming



59
60
61
# File 'lib/vagrant-windows-domain/config.rb', line 59

def rename
  @rename
end

#secondary_dnsObject

IP address of the secondary DNS server

Specifies the IP address you want assigned as the secondary DNS server for the primary nic



51
52
53
# File 'lib/vagrant-windows-domain/config.rb', line 51

def secondary_dns
  @secondary_dns
end

#unsecureObject

Performs an unsecure join to the specified domain.

When this option is used username/password are not required



56
57
58
# File 'lib/vagrant-windows-domain/config.rb', line 56

def unsecure
  @unsecure
end

#usernameObject

The Username to use when authenticating against the Domain.

Specifies a user account that has permission to join the computers to a new domain.



22
23
24
# File 'lib/vagrant-windows-domain/config.rb', line 22

def username
  @username
end

Instance Method Details

#finalize!Object

Final step of the Configuration lifecyle prior to validation.

Ensures all attributes are set to defaults if not provided.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/vagrant-windows-domain/config.rb', line 80

def finalize!
  super

  # Null checks
  @domain            = nil if @domain == UNSET_VALUE || @domain == ""
  @computer_name     = nil if @computer_name == UNSET_VALUE || @computer_name == ""
  @username          = nil if @username == UNSET_VALUE || @username == ""
  @password          = nil if @password == UNSET_VALUE || @password == ""
  @join_options      = [] if @join_options == UNSET_VALUE
  @ou_path           = nil if @ou_path == UNSET_VALUE
  @primary_dns       = nil if @primary_dns == UNSET_VALUE
  @secondary_dns     = nil if @secondary_dns == UNSET_VALUE
  @unsecure          = false if @unsecure == UNSET_VALUE
  @rename            = true if @rename == UNSET_VALUE
end

#validate(machine) ⇒ Hash

Validate configuration and return a hash of errors.

Validation happens after finalize!.

Parameters:

  • The (Machine)

    current Machine

Returns:

  • (Hash)

    Any errors or {} if no errors found



102
103
104
105
106
107
108
109
110
111
# File 'lib/vagrant-windows-domain/config.rb', line 102

def validate(machine)        
  errors = _detected_errors

  # Need to supply one of them!
  if ( (@username != nil && @password != nil) && @unsecure == true)
    errors << I18n.t("vagrant_windows_domain.errors.both_credentials_provided")
  end
  
  { "windows domain provisioner" => errors }
end