Class: VagrantBolt::Config::Global

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-bolt/config/global.rb

Direct Known Subclasses

Bolt

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGlobal

Returns a new instance of Global.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/vagrant-bolt/config/global.rb', line 92

def initialize
  @bolt_exe        = UNSET_VALUE
  @boltdir         = UNSET_VALUE
  @connect_timeout = UNSET_VALUE
  @host_key_check  = UNSET_VALUE
  @machine_alias   = UNSET_VALUE
  @machine_name    = UNSET_VALUE
  @modulepath      = UNSET_VALUE
  @password        = UNSET_VALUE
  @port            = UNSET_VALUE
  @private_key     = UNSET_VALUE
  @project         = UNSET_VALUE
  @run_as          = UNSET_VALUE
  @ssl             = UNSET_VALUE
  @ssl_verify      = UNSET_VALUE
  @sudo_password   = UNSET_VALUE
  @tmpdir          = UNSET_VALUE
  @user            = UNSET_VALUE
  @verbose         = UNSET_VALUE
  @debug           = UNSET_VALUE
  @facts           = UNSET_VALUE
  @vars            = UNSET_VALUE
  @features        = UNSET_VALUE
end

Instance Attribute Details

#bolt_exeString

Returns The full path to the bolt command. If not passed in, the default from PATH will be used.

Returns:

  • (String)

    The full path to the bolt command. If not passed in, the default from PATH will be used.



6
7
8
# File 'lib/vagrant-bolt/config/global.rb', line 6

def bolt_exe
  @bolt_exe
end

#boltdirString

Returns DEPRECATED use project. The bolt working directory. Defaults to ..

Returns:

  • (String)

    DEPRECATED use project. The bolt working directory. Defaults to .



10
11
12
# File 'lib/vagrant-bolt/config/global.rb', line 10

def boltdir
  @boltdir
end

#connect_timeoutString

Returns If the connection should check the host key on the remote host (linux).

Returns:

  • (String)

    If the connection should check the host key on the remote host (linux)



14
15
16
# File 'lib/vagrant-bolt/config/global.rb', line 14

def connect_timeout
  @connect_timeout
end

#debugBoolean

Returns Shows debug logging.

Returns:

  • (Boolean)

    Shows debug logging



78
79
80
# File 'lib/vagrant-bolt/config/global.rb', line 78

def debug
  @debug
end

#factsHash

Returns A hash of facts for the machine.

Returns:

  • (Hash)

    A hash of facts for the machine



82
83
84
# File 'lib/vagrant-bolt/config/global.rb', line 82

def facts
  @facts
end

#featuresArray<String>

Returns An array containing the features for this machine.

Returns:

  • (Array<String>)

    An array containing the features for this machine



90
91
92
# File 'lib/vagrant-bolt/config/global.rb', line 90

def features
  @features
end

#host_key_checkBoolean

Returns If the connection should check the host key on the remote host (linux).

Returns:

  • (Boolean)

    If the connection should check the host key on the remote host (linux)



14
# File 'lib/vagrant-bolt/config/global.rb', line 14

attr_accessor :connect_timeout

#machine_aliasString

Returns The alias of the machine to set in the bolt inventory.

Returns:

  • (String)

    The alias of the machine to set in the bolt inventory



22
23
24
# File 'lib/vagrant-bolt/config/global.rb', line 22

def machine_alias
  @machine_alias
end

#machine_nameString

Returns The name of the machine to set in the bolt inventory.

Returns:

  • (String)

    The name of the machine to set in the bolt inventory



26
27
28
# File 'lib/vagrant-bolt/config/global.rb', line 26

def machine_name
  @machine_name
end

#modulepathString

Returns The path to the modules.

Returns:

  • (String)

    The path to the modules.



30
31
32
# File 'lib/vagrant-bolt/config/global.rb', line 30

def modulepath
  @modulepath
end

#passwordString

Returns The password to authenticate on the machine.

Returns:

  • (String)

    The password to authenticate on the machine.



38
39
40
# File 'lib/vagrant-bolt/config/global.rb', line 38

def password
  @password
end

#portString

Returns The port to connect to the machine.

Returns:

  • (String)

    The port to connect to the machine.



42
43
44
# File 'lib/vagrant-bolt/config/global.rb', line 42

def port
  @port
end

#private_keyString

Returns The path of the private_key to authenticate on the machine.

Returns:

  • (String)

    The path of the private_key to authenticate on the machine.



46
47
48
# File 'lib/vagrant-bolt/config/global.rb', line 46

def private_key
  @private_key
end

#projectString

Returns The bolt project. Defaults to ..

Returns:

  • (String)

    The bolt project. Defaults to .



50
51
52
# File 'lib/vagrant-bolt/config/global.rb', line 50

def project
  @project
end

#run_asString

Returns User to run as using privilege escalation.

Returns:

  • (String)

    User to run as using privilege escalation.



54
55
56
# File 'lib/vagrant-bolt/config/global.rb', line 54

def run_as
  @run_as
end

#sslBoolean

Returns If the connection should use SSL on with WinRM (Windows).

Returns:

  • (Boolean)

    If the connection should use SSL on with WinRM (Windows)



62
63
64
# File 'lib/vagrant-bolt/config/global.rb', line 62

def ssl
  @ssl
end

#ssl_verifyBoolean

Returns If the connection should verify SSL on with WinRM (Windows).

Returns:

  • (Boolean)

    If the connection should verify SSL on with WinRM (Windows)



66
67
68
# File 'lib/vagrant-bolt/config/global.rb', line 66

def ssl_verify
  @ssl_verify
end

#sudo_passwordString

Returns The password to authenticate sudo on the machine.

Returns:

  • (String)

    The password to authenticate sudo on the machine.



58
59
60
# File 'lib/vagrant-bolt/config/global.rb', line 58

def sudo_password
  @sudo_password
end

#tmpdirString

Returns The directory to upload and execute temporary files on the target.

Returns:

  • (String)

    The directory to upload and execute temporary files on the target



70
71
72
# File 'lib/vagrant-bolt/config/global.rb', line 70

def tmpdir
  @tmpdir
end

#userString

Returns The user to authenticate on the machine.

Returns:

  • (String)

    The user to authenticate on the machine.



34
35
36
# File 'lib/vagrant-bolt/config/global.rb', line 34

def user
  @user
end

#varsHash

Returns A hash of vars for the machine.

Returns:

  • (Hash)

    A hash of vars for the machine



86
87
88
# File 'lib/vagrant-bolt/config/global.rb', line 86

def vars
  @vars
end

#verboseBoolean

Returns Shows verbose logging.

Returns:

  • (Boolean)

    Shows verbose logging



74
75
76
# File 'lib/vagrant-bolt/config/global.rb', line 74

def verbose
  @verbose
end

Instance Method Details

#bolt_exe_pathString

Get the full path to the bolt executable

Returns:

  • (String)

    The path to the bolt exe



144
145
146
147
148
# File 'lib/vagrant-bolt/config/global.rb', line 144

def bolt_exe_path
  return '/opt/puppetlabs/bin/bolt' if !Vagrant::Util::Platform.windows? && File.file?('/opt/puppetlabs/bin/bolt')

  Vagrant::Util::Which.which('bolt') || 'bolt'
end

#finalize!Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/vagrant-bolt/config/global.rb', line 117

def finalize!
  @bolt_exe        = bolt_exe_path if @bolt_exe == UNSET_VALUE
  @boltdir         = '.' if @boltdir == UNSET_VALUE
  @connect_timeout = nil if @connect_timeout == UNSET_VALUE
  @host_key_check  = nil if @host_key_check == UNSET_VALUE
  @machine_alias   = nil if @machine_alias == UNSET_VALUE
  @machine_name    = nil if @machine_name == UNSET_VALUE
  @modulepath      = nil if @modulepath == UNSET_VALUE
  @port            = nil if @port == UNSET_VALUE
  @password        = nil if @password == UNSET_VALUE
  @private_key     = nil if @private_key == UNSET_VALUE
  @project         = @boltdir if @project == UNSET_VALUE || @project.nil?
  @run_as          = nil if @run_as == UNSET_VALUE
  @ssl             = nil if @ssl == UNSET_VALUE
  @ssl_verify      = nil if @ssl_verify == UNSET_VALUE
  @sudo_password   = nil if @sudo_password == UNSET_VALUE
  @tmpdir          = nil if @tmpdir == UNSET_VALUE
  @user            = nil if @user == UNSET_VALUE
  @verbose         = nil if @verbose == UNSET_VALUE
  @debug           = nil if @debug == UNSET_VALUE
  @facts           = nil if @facts == UNSET_VALUE
  @features        = nil if @features == UNSET_VALUE
  @vars            = nil if @vars == UNSET_VALUE
end

#inventory_configHash

Generate a bolt inventory config hash for this config

Returns:

  • (Hash)

    A bolt inventory config hash containing the configured params



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/vagrant-bolt/config/global.rb', line 158

def inventory_config
  group_objects = ['facts', 'features', 'vars']
  config = {}
  instance_variables_hash.each do |key, value|
    next if value.nil? || (value == UNSET_VALUE)

    if group_objects.include?(key)
      config[key] = value
    elsif %r{machine_\w+}.match?(key)
      config[key.sub('machine_', '')] = value
    else
      setting_map.each do |transport, settings|
        next unless settings.include?(key)

        config['config'] ||= {}
        config['config'][transport.to_s] ||= {}
        config['config'][transport.to_s][key.tr('_', '-')] = value
      end
    end
  end
  config
end

#setting_mapHash

Return the setting map for the config hash

Returns:

  • (Hash)

    A map of the settings to the transport



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/vagrant-bolt/config/global.rb', line 183

def setting_map
  {
    'ssh': [
      'user',
      'password',
      'run_as',
      'port',
      'private_key',
      'connect_timeout',
      'host_key_check',
      'sudo_password',
      'tmpdir',
    ],
    'winrm': [
      'user',
      'password',
      'ssl',
      'ssl_verify',
      'port',
      'tmpdir',
    ],
  }
end

#validate(_machine) ⇒ Object



150
151
152
153
154
# File 'lib/vagrant-bolt/config/global.rb', line 150

def validate(_machine)
  errors = _detected_errors

  { "GlobalBolt" => errors }
end