Commit f7e49be
committed
rabbitmq: keep dots in interface fact keys
get_rabbitmq_node_addresses() derived the ansible fact name for an
interface by replacing both "-" and "." with "_":
normalized_interface = internal_interface.replace(".", "_").replace("-", "_")
Ansible only replaces "-". PrefixFactNamespace._underscore() is
def _underscore(self, name):
return name.replace('-', '_')
and the setup module prefixes the result with "ansible_", so an interface
named br-ex is ansible_br_ex -- but one named bond0.100 is
ansible_bond0.100, with the dot intact.
Dotted names are the conventional way to name a VLAN interface, so for
any deployment using bond0.<vlan> the lookup asked for
ansible_bond0_100, found nothing, and reported
Interface bond0.100 (ansible_bond0_100) not found in ansible facts
This is independent of the Jinja2 handling further up the function: it
happens even when internal_interface is a plain literal with no template
in it at all.
Drop the dot substitution and keep the dash one. The unit test asserted
the old mapping ("eth0.100" -> "ansible_eth0_100"), so it pinned the bug
in place; it now asserts the mapping Ansible actually uses. Verified
against live fact gathering on ansible-core 2.18.9 and 2.19.11: a real
interface named br-e4aefb861457 is cached as ansible_br_e4aefb861457,
and PrefixFactNamespace leaves eth0.100 as ansible_eth0.100.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Roger Luethi <luethi@osism.tech>1 parent 0a164c5 commit f7e49be
2 files changed
Lines changed: 13 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
349 | | - | |
350 | | - | |
| 349 | + | |
| 350 | + | |
351 | 351 | | |
352 | | - | |
353 | | - | |
| 352 | + | |
| 353 | + | |
354 | 354 | | |
355 | | - | |
356 | | - | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
357 | 358 | | |
358 | 359 | | |
359 | | - | |
| 360 | + | |
360 | 361 | | |
361 | 362 | | |
362 | 363 | | |
| |||
0 commit comments