Skip to content

Commit 5c48c7e

Browse files
jovialpriteau
authored andcommitted
Fix networking connectivity check with no_ip
When no_ip is applied to only a subset of the hosts for a particular network, network connectivity check could fail since we only checked the source IP was properly defined and not the destination IP. This adds a check for the destination IP. Also improves the loop label for ease of debugging. Closes-Bug: #2120918 Change-Id: I107f1b2687852a04eb4a6eb7cc82f4d6690bc177 Signed-off-by: Will Szumski <[email protected]> (cherry picked from commit 7c6f81b)
1 parent 7ff2db4 commit 5c48c7e

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

ansible/network-connectivity.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,12 @@
6868
command: >
6969
ping {{ remote_ip }} -c1 -M do {% if mtu %} -s {{ mtu | int - icmp_overhead_bytes }}{% endif %}
7070
with_items: "{{ network_interfaces }}"
71+
loop_control:
72+
label: "{{ remote_host }} on {{ item }}"
7173
when:
72-
- item | net_ip
7374
- remote_hosts | length > 0
75+
- remote_ip | length > 0
76+
- item | net_ip
7477
changed_when: False
7578
vars:
7679
# Select other hosts targeted by this play which have this network
@@ -83,6 +86,10 @@
8386
rejectattr('inventory_hostname', 'equalto', inventory_hostname) |
8487
map(attribute='inventory_hostname') |
8588
list }}
86-
remote_host: "{{ remote_hosts | random }}"
87-
remote_ip: "{{ item | net_ip(remote_host) }}"
89+
# NOTE(wszumski): Needed to fix random choice for the run otherwise the
90+
# when check: remote_ip | length > 0, would pass, but remote_ip was ''
91+
# in the command. Assumption was that this was being evaluated once
92+
# for the when clause and then again for the command. Bug?
93+
remote_host: "{{ remote_hosts | random(seed=ansible_facts.date_time.iso8601) }}"
94+
remote_ip: "{{ lookup('cached', 'vars', item ~ '_ips')[remote_host] | default('', true) }}"
8895
mtu: "{{ item | net_mtu }}"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
fixes:
3+
- |
4+
Fixes network connectivity check when a subset of hosts have the ``no_ip``
5+
property set via group or host variables.
6+
`LP#2120918 <https://bugs.launchpad.net/kayobe/+bug/2120918>`__

0 commit comments

Comments
 (0)