vagrant-openstack-provider icon indicating copy to clipboard operation
vagrant-openstack-provider copied to clipboard

Use standard environments variables for credentials

Open julienvey opened this issue 11 years ago • 1 comments

Instead of adding username, password, tenant_name and auth url in vagrantfile, we could try to look up the standard environment variables used by openstack CLI, OS_USERNAME, OS_PASSWORD...

We would do this only when the params are not present in the Vagrantfile

julienvey avatar Aug 28 '14 08:08 julienvey

Agreed. Here are some candidates for defaults

    os.openstack_auth_url = "#{ENV['OS_AUTH_URL']}/tokens"
    os.username           = ENV['OS_USERNAME']
    os.password           = ENV['OS_PASSWORD']
    os.tenant_name        = ENV['OS_TENANT_NAME']

Digressing here but ... would it be bad practice to infer new ones. To work towards a situation where a standard virtualbox Vagrantfile could be launched without manipulation.

    os.floating_ip_pool   = ENV['OS_XFLOATING_IP_POOL']
    os.networks           = ENV['OS_XNETWORKS_JSON']

Perhaps the README could just encourage users to create a ~/.vagrant.d/Vagrantfile

# vi: set ft=ruby :

require 'vagrant-openstack-provider'
Vagrant.configure(2) do |config|

  config.ssh.username = 'root'
  config.ssh.private_key_path = "~/.ssh/id_rsa"

  config.vm.provider :openstack do |os|
    os.openstack_auth_url = "#{ENV['OS_AUTH_URL']}/tokens" #'http://keystone-server.net/v2.0/tokens'
    os.username           = ENV['OS_USERNAME']
    os.password           = ENV['OS_PASSWORD']
    os.tenant_name        = ENV['OS_TENANT_NAME']
    os.flavor             = 'm1.small'
    os.image              = 'CentOS-6.6'
    os.floating_ip_pool   = 'PUBLIC-NETWORK'
    os.networks = [{id: "c61bd39a-f1ec-4072-a227-4ed72cbda191"}]
    os.keypair_name           = 'username_key'
  end

end

Boom, no editing vagrant files. I am sure you already know that but it isn't so obvious to newbies

kcd83 avatar Jun 23 '15 23:06 kcd83