Class: VagrantBolt::Config::Global
- Inherits:
-
Object
- Object
- VagrantBolt::Config::Global
- Defined in:
- lib/vagrant-bolt/config/global.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#bolt_exe ⇒ String
The full path to the bolt command.
-
#boltdir ⇒ String
DEPRECATED use
project
. -
#connect_timeout ⇒ String
If the connection should check the host key on the remote host (linux).
-
#debug ⇒ Boolean
Shows debug logging.
-
#facts ⇒ Hash
A hash of facts for the machine.
-
#features ⇒ Array<String>
An array containing the features for this machine.
-
#host_key_check ⇒ Boolean
If the connection should check the host key on the remote host (linux).
-
#machine_alias ⇒ String
The alias of the machine to set in the bolt inventory.
-
#machine_name ⇒ String
The name of the machine to set in the bolt inventory.
-
#modulepath ⇒ String
The path to the modules.
-
#password ⇒ String
The password to authenticate on the machine.
-
#port ⇒ String
The port to connect to the machine.
-
#private_key ⇒ String
The path of the private_key to authenticate on the machine.
-
#project ⇒ String
The bolt project.
-
#run_as ⇒ String
User to run as using privilege escalation.
-
#ssl ⇒ Boolean
If the connection should use SSL on with WinRM (Windows).
-
#ssl_verify ⇒ Boolean
If the connection should verify SSL on with WinRM (Windows).
-
#sudo_password ⇒ String
The password to authenticate sudo on the machine.
-
#tmpdir ⇒ String
The directory to upload and execute temporary files on the target.
-
#user ⇒ String
The user to authenticate on the machine.
-
#vars ⇒ Hash
A hash of vars for the machine.
-
#verbose ⇒ Boolean
Shows verbose logging.
Instance Method Summary collapse
-
#bolt_exe_path ⇒ String
Get the full path to the bolt executable.
- #finalize! ⇒ Object
-
#initialize ⇒ Global
constructor
A new instance of Global.
-
#inventory_config ⇒ Hash
Generate a bolt inventory config hash for this config.
-
#setting_map ⇒ Hash
Return the setting map for the config hash.
- #validate(_machine) ⇒ Object
Constructor Details
#initialize ⇒ Global
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_exe ⇒ String
Returns 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 |
#boltdir ⇒ String
Returns 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_timeout ⇒ String
Returns 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 |
#debug ⇒ Boolean
Returns Shows debug logging.
78 79 80 |
# File 'lib/vagrant-bolt/config/global.rb', line 78 def debug @debug end |
#facts ⇒ Hash
Returns A hash of facts for the machine.
82 83 84 |
# File 'lib/vagrant-bolt/config/global.rb', line 82 def facts @facts end |
#features ⇒ Array<String>
Returns 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_check ⇒ Boolean
Returns 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_alias ⇒ String
Returns 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_name ⇒ String
Returns 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 |
#modulepath ⇒ String
Returns The path to the modules.
30 31 32 |
# File 'lib/vagrant-bolt/config/global.rb', line 30 def modulepath @modulepath end |
#password ⇒ String
Returns The password to authenticate on the machine.
38 39 40 |
# File 'lib/vagrant-bolt/config/global.rb', line 38 def password @password end |
#port ⇒ String
Returns The port to connect to the machine.
42 43 44 |
# File 'lib/vagrant-bolt/config/global.rb', line 42 def port @port end |
#private_key ⇒ String
Returns 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 |
#project ⇒ String
Returns The bolt project. Defaults to .
.
50 51 52 |
# File 'lib/vagrant-bolt/config/global.rb', line 50 def project @project end |
#run_as ⇒ String
Returns 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 |
#ssl ⇒ Boolean
Returns 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_verify ⇒ Boolean
Returns 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_password ⇒ String
Returns 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 |
#tmpdir ⇒ String
Returns 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 |
#user ⇒ String
Returns The user to authenticate on the machine.
34 35 36 |
# File 'lib/vagrant-bolt/config/global.rb', line 34 def user @user end |
#vars ⇒ Hash
Returns A hash of vars for the machine.
86 87 88 |
# File 'lib/vagrant-bolt/config/global.rb', line 86 def vars @vars end |
#verbose ⇒ Boolean
Returns Shows verbose logging.
74 75 76 |
# File 'lib/vagrant-bolt/config/global.rb', line 74 def verbose @verbose end |
Instance Method Details
#bolt_exe_path ⇒ String
Get the full path to the bolt executable
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_config ⇒ Hash
Generate a bolt inventory config hash for this config
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_map ⇒ Hash
Return the setting map for the config hash
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 |