linux facts - return proper broadcast address (#64528)
* linux facts - return proper broadcast address Check that the value being returned is actually a broadcast address * Add tests * Cleanup tests
This commit is contained in:
parent
c4f442ed5a
commit
e6bf202738
5 changed files with 28 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- linux network facts - get the correct value for broadcast address (https://github.com/ansible/ansible/issues/64384)
|
|
@ -173,6 +173,7 @@ class LinuxNetwork(Network):
|
||||||
if '/' in words[1]:
|
if '/' in words[1]:
|
||||||
address, netmask_length = words[1].split('/')
|
address, netmask_length = words[1].split('/')
|
||||||
if len(words) > 3:
|
if len(words) > 3:
|
||||||
|
if words[2] == 'brd':
|
||||||
broadcast = words[3]
|
broadcast = words[3]
|
||||||
else:
|
else:
|
||||||
# pointopoint interfaces do not have a prefix
|
# pointopoint interfaces do not have a prefix
|
||||||
|
|
4
test/integration/targets/facts_linux_network/aliases
Normal file
4
test/integration/targets/facts_linux_network/aliases
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
needs/privileged
|
||||||
|
shippable/posix/group2
|
||||||
|
skip/freebsd
|
||||||
|
skip/osx
|
|
@ -0,0 +1,2 @@
|
||||||
|
dependencies:
|
||||||
|
- prepare_tests
|
18
test/integration/targets/facts_linux_network/tasks/main.yml
Normal file
18
test/integration/targets/facts_linux_network/tasks/main.yml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
- block:
|
||||||
|
- name: Add IP to interface
|
||||||
|
command: ip address add 100.42.42.1/32 dev {{ ansible_facts.default_ipv4.interface }}
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Gather network facts
|
||||||
|
setup:
|
||||||
|
gather_subset: network
|
||||||
|
|
||||||
|
- name: Ensure broadcast is reported as empty
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- ansible_facts[ansible_facts['default_ipv4']['interface']]['ipv4_secondaries'][0]['broadcast'] == ''
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Remove IP from interface
|
||||||
|
command: ip address delete 100.42.42.1/32 dev {{ ansible_facts.default_ipv4.interface }}
|
||||||
|
ignore_errors: yes
|
Loading…
Reference in a new issue