puppetlabs/beaker — pull request #144 by kbarber (2014-02-05 19:31:26+00:00)
Title: Fix regexp for finding ip address for Fedora

The previous command for finding the IP address of a host:

ip a | awk '/g/{print$2}'

Picks up all kinds of stray entries, on Amazon Linux for example:

# ip a | awk '/g/{print$2}'
109.74.196.121/24
2a01:7e00::f03c:91ff:fe96:e1e4/64
gre0:
0.0.0.0
gretap0:
ip6gre0:

On a Fedora 20 box hosted in EC2:

# ip a|awk '/g/{print$2}'
lo:
eth0:
10.232.140.48/26

This is because its just looking for the letter 'g' which is not accurate
enough. Some interface lines have the word 'group' for example.

Changing this to the actual word 'global' seems to solve it:

# ip a | awk '/global/{print$2}'
109.74.196.121/24

This has been tested to work on:

* Debian 6/7
* Fedora 18, 20
* Amazon Linux
* Redhat 5/6

So I believe the behaviour should still be consistent after this change.

Signed-off-by: Ken Barber