vagrant-google icon indicating copy to clipboard operation
vagrant-google copied to clipboard

Automatic /etc/hosts entry for created machine

Open gdubicki opened this issue 3 years ago • 1 comments

I am testing some Ansible playbooks on the machine in GCP created with Vagrant and this plugin.

I am using static Ansible inventory, so after I create a new vm I have to add/update its external IP address in the inventory file. This is slightly annoying.

I could automate it by using the GCP dynamic inventory for Ansible but a) its configuration is an overkill for such a simple use case, b) it would add another extra step to regenerate the inventory after creating a new vm.

For my use case it would be cool if this plugin could create/update an /etc/hosts entry with the created vm external IP under some name, f.e. by default "vagrant".

Do you think this is a good idea? Would a PR with such an optional feature be accepted?

gdubicki avatar Mar 07 '22 09:03 gdubicki

I started with printing out the external IP with shell provisioner:

  config.vm.provision "shell",
    inline: "echo External IP: $(curl -s icanhazip.com)"

gdubicki avatar Mar 13 '22 09:03 gdubicki