Created
November 18, 2013 16:52
-
-
Save fifteen3/7531194 to your computer and use it in GitHub Desktop.
Vagrant Shell provisioner for returning the ip address of your vm.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#typically you need this for a dhcp public network setup | |
#with private networks you set the ip address but it is still useful | |
#to have this provisioner if you reload the vagrant file as it will remind | |
#you what the ip address is, so you can set it in your host file. | |
#use eth0 if the network is public, eth1 if the network is private | |
$network_interface = "eth0" | |
$display_ip_address = <<IP_ADDRESS | |
ipaddress=`/sbin/ifconfig #{$network_interface} | grep 'inet addr' | awk -F' ' '{print $2}' | awk -F':' '{print $2}'` | |
echo "ip address: $ipaddress" | |
IP_ADDRESS | |
config.vm.provision "shell", inline: $display_ip_address | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to execute this script while the vm is running I can always run:
vagrant provvision --provision-with shell