ggiamarchi / vagrant-openstack-provider

Use Vagrant to manage OpenStack Cloud instances.
MIT License
247 stars 101 forks source link

floating_ip is not giving me the ip of the remote server server #338

Open josrom opened 7 years ago

josrom commented 7 years ago

Hej, Im trying to retrieve the floating_ip on the vagrant file code to do some things with it but unfortunately seems to be behaving a little bit weird.... i get an object not an string.

g.vm.provision "ansible" do |ansible|
  #ansible.verbose = "vvvv"
  ansible.limit="all"
  ansible.playbook = "grafana.yml"
  config.vm.provider "openstack" do |cc|
    ansible.groups = {
        "grafana" => ["grafana"],
        "grafana:vars" => {"variable1" => "#{cc.floating_ip}"}
    }
  end

end

https://github.com/ggiamarchi/vagrant-openstack-provider/blob/b424746268e8b239befe473c85e7ae0a364f9760/source/lib/vagrant-openstack-provider/config.rb#L103 . The floating IP address from the IP pool which will be assigned to the instance..

@return [String] attr_accessor :floating_ip

And I get this: .vagrant/provisioners/ansible/inventory$ cat vagrant_ansible_inventory Generated by Vagrant

grafana ansible_ssh_host=185.62.207.59 ansible_ssh_port=22 ansible_ssh_user='ubuntu' ansible_ssh_private_key_file='.vagrant/machines/grafana/openstack/vagrant-generated-clxh3ah7'

[grafana] grafana

[grafana:vars] variable1=#

NOTE: variable1=# as result for "grafana:vars" => {"variable1" => "#{cc.floating_ip}"}

matttrach commented 6 years ago

This would be a really great variable to pass to provisioning, when using floating IP addresses the server tends not to know it's own IP address. If we could pass this along in an environment variable that would be cool too.

ghost commented 5 years ago

vagrant-openstack-provider is unusable with multiple vms: