From 5e48391b05ce3ff864547497502bcff73e1227af Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 9 Jun 2013 13:27:08 -0700 Subject: [PATCH] read_ip_address linux cap only reads ip of first device [GH-1799] --- CHANGELOG.md | 2 ++ plugins/guests/linux/cap/read_ip_address.rb | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5951b55e2..7836e74a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,8 @@ BUG FIXES: errors. [GH-1691] - Setting hostname on SLES 11 works again. [GH-1781] - `config.vm.guest` properly forces guests again. [GH-1800] + - The `read_ip_address` capability for linux properly reads the IP + of only the first network interface. [GH-1799] ## 1.2.2 (April 23, 2013) diff --git a/plugins/guests/linux/cap/read_ip_address.rb b/plugins/guests/linux/cap/read_ip_address.rb index 0eaffccbf..c6adc9e16 100644 --- a/plugins/guests/linux/cap/read_ip_address.rb +++ b/plugins/guests/linux/cap/read_ip_address.rb @@ -3,13 +3,13 @@ module VagrantPlugins module Cap class ReadIPAddress def self.read_ip_address(machine) - command = "ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'" + command = "ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1 }'" result = "" machine.communicate.execute(command) do |type, data| result << data if type == :stdout end - result.chomp + result.chomp.split("\n").first end end end