Open robinbowes opened 8 years ago
@BaxterStockman I worked around this as follows:
Put your credentials in a file in the root of your home dir named .vcenter_login.yaml like this:
---
username: "your_username"
password: "your_password"
Add code to Vagrantfile, something like this:
provider = 'vcenter'
creds_file = YAML.load_file(File.expand_path("~/.#{provider}_login.yaml"))
username = creds_file['username']
password = creds_file['password']
Then you can use the username and password variables like this:
config.vm.provider :vcenter do |vcenter|
vcenter.username = username
vcenter.password = password
...
@robinbowes -- thanks for sharing your setup! I had hoped to do something similar, but I've gotten pushback from colleagues who aren't enthusiastic about storing their credentials in a file (even with restrictive permissions). I have a workaround, but it makes me feel bad about myself :cry::
# This is a simplified version of the logic that's followed in `bin/vagrant`;
# see https://github.com/mitchellh/vagrant/blob/master/bin/vagrant.
class UI
extend SingleForwardable
class << self
attr_accessor :ui
def init(argv = ARGV)
self.ui = ui_class(argv).new
end
def ui_class(argv)
if argv.include?("--machine-readable")
Vagrant::UI::MachineReadable
elsif argv.include?("--no-color") || ENV["VAGRANT_NO_COLOR"]
Vagrant::UI::Basic
elsif argv.include?("--color")
Vagrant::UI::Colored
elsif !Vagrant::Util::Platform.terminal_supports_colors?
Vagrant::UI::Basic
elsif !$stdout.tty? && !Vagrant::Util::Platform.cygwin?
Vagrant::UI::Basic
else
Vagrant::UI::Colored
end
end
private :ui_class
end
def_single_delegators :ui, :ask, :detail, :warn, :error, :info, :output,
:success
end
UI.init
Vagrant.configure('2') do |config|
config.vm.provider :vcenter do |vcenter|
vcenter.password = UI.ask('vSphere password (will be hidden): ', :echo => false)
end
end
Would really appreciate this feature! :+1: