rabbitmq: keep dots in interface fact keys - #2575
Open
ideaship wants to merge 1 commit into
Open
Conversation
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>
This was referenced Aug 6, 2026
ideaship
marked this pull request as ready for review
August 6, 2026 09:47
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider renaming
normalized_interfaceto something likeansible_fact_interface(or similar) now that it’s specifically aligned to Ansible’s fact naming, which will make the intent clearer than a generic “normalized” name. - Since the dash-to-underscore mapping logic is now tightly coupled to Ansible’s behavior, it might be worth extracting it into a small helper (e.g.,
to_ansible_interface_fact_key) so that any future changes to Ansible’s normalization rules need only be updated in one place.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider renaming `normalized_interface` to something like `ansible_fact_interface` (or similar) now that it’s specifically aligned to Ansible’s fact naming, which will make the intent clearer than a generic “normalized” name.
- Since the dash-to-underscore mapping logic is now tightly coupled to Ansible’s behavior, it might be worth extracting it into a small helper (e.g., `to_ansible_interface_fact_key`) so that any future changes to Ansible’s normalization rules need only be updated in one place.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
get_rabbitmq_node_addresses()derived the Ansible fact name for an interface by replacing both-and.with_:Ansible only replaces
-.PrefixFactNamespace._underscore()isname.replace('-', '_'), and the setup module prefixes the result withansible_, so an interface namedbr-exisansible_br_ex— but one namedbond0.100isansible_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 foransible_bond0_100, found nothing, and reported:This is independent of the Jinja2 handling further up the function: it happens even when
internal_interfaceis a plain literal with no template in it.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.Verification. Against live fact gathering on ansible-core 2.18.9 and 2.19.11: a real interface named
br-e4aefb861457is cached asansible_br_e4aefb861457, andPrefixFactNamespaceleaveseth0.100asansible_eth0.100. Reverting the code change makes the updated test fail with the message above.Found while investigating:
🤖 Generated with Claude Code