Repository: ansible/ansible

Issue:
missing broadcast address in facts
I try to template the /etc/network/interfaces in debian, need broadcast address. Unfortunetly, there is no broadcast address in ansible facts, part of setup result:

```
     "ansible_default_ipv4": {
            "address": "144.76.19.151", 
            "alias": "eth0", 
            "gateway": "144.76.19.129", 
            "interface": "eth0", 
            "macaddress": "4c:72:b9:7c:c6:1d", 
            "mtu": 1500, 
            "netmask": "255.255.255.224", 
            "network": "144.76.19.128", 
            "type": "ether"
        }, 
       "ansible_eth0": {
            "active": true, 
            "device": "eth0", 
            "ipv4": {
                "address": "144.76.19.151", 
                "netmask": "255.255.255.224", 
                "network": "144.76.19.128"
            }, 
            "ipv6": [
                {
                    "address": "2a01:4f8:191:1196::2", 
                    "prefix": "64", 
                    "scope": "global"
                }, 
                {
                    "address": "fe80::4e72:b9ff:fe7c:c61d", 
                    "prefix": "64", 
                    "scope": "link"
                }
            ], 
            "macaddress": "4c:72:b9:7c:c6:1d", 
            "module": "e1000e", 
            "mtu": 1500, 
            "promisc": false, 
            "type": "ether"
        }, 
```

_ansible 1.9.1_, debian jessie. 

I see that previously this was working (https://github.com/ansible/ansible/issues/8519), can we have it back? I found even similar question (http://grokbase.com/t/gg/ansible-project/14c2jdv7qn/ipv4-broadcast-address) but without answers..



Discussion:

Resolving patch:
diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py
--- a/lib/ansible/module_utils/facts.py
+++ b/lib/ansible/module_utils/facts.py
@@ -1836,6 +1836,7 @@ def parse_ip_output(output, secondary=False):
                     if words[0] == 'inet':
                         if '/' in words[1]:
                             address, netmask_length = words[1].split('/')
+                            broadcast = words[3]
                         else:
                             # pointopoint interfaces do not have a prefix
                             address = words[1]
@@ -1849,6 +1850,7 @@ def parse_ip_output(output, secondary=False):
                             interfaces[iface] = {}
                         if not secondary and "ipv4" not in interfaces[iface]:
                             interfaces[iface]['ipv4'] = {'address': address,
+                                                         'broadcast': broadcast,
                                                          'netmask': netmask,
                                                          'network': network}
                         else:
@@ -1856,6 +1858,7 @@ def parse_ip_output(output, secondary=False):
                                 interfaces[iface]["ipv4_secondaries"] = []
                             interfaces[iface]["ipv4_secondaries"].append({
                                 'address': address,
+                                'broadcast': broadcast,
                                 'netmask': netmask,
                                 'network': network,
                             })
@@ -1866,12 +1869,14 @@ def parse_ip_output(output, secondary=False):
                                 interfaces[device]["ipv4_secondaries"] = []
                             interfaces[device]["ipv4_secondaries"].append({
                                 'address': address,
+                                'broadcast': broadcast,
                                 'netmask': netmask,
                                 'network': network,
                             })
 
                         # If this is the default address, update default_ipv4
                         if 'address' in default_ipv4 and default_ipv4['address'] == address:
+                            default_ipv4['broadcast'] = broadcast 
                             default_ipv4['netmask'] = netmask
                             default_ipv4['network'] = network
                             default_ipv4['macaddress'] = macaddress


Test patch: