I needed to know this to tell a user what to add to their host machine's host file. This works for me inside vagrant using just bash:
external_ip=$(cat /vagrant/config.yml | grep vagrant_ip | cut -d' ' -f2 | xargs)
echo -e "# Add this line to your host file:\n${external_ip} host.vagrant.vm"