Use mgmt.ipv4 as ansible_host for containers with SSH servers#2913
Merged
Use mgmt.ipv4 as ansible_host for containers with SSH servers#2913
Conversation
There was a problem hiding this comment.
Pull request overview
This PR modifies how Ansible inventory hosts are configured to ensure IPv4 addresses are used for SSH connections, particularly fixing issue #2911 related to ansible-pysshlib compatibility. The changes consolidate inventory host creation logic by making the Ansible output module use the common adjust_inventory_host function instead of its own ansible_inventory_host implementation.
Key changes:
- Refactored inventory host creation to use a shared function across different output modules
- Modified dictionary order in
topo_to_hostto ensuremgmt.ipv4overwriteshostnamefor non-Docker connections - Added Docker connection detection to prevent using management IP addresses for Docker containers
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| netsim/outputs/common.py | Moved topo_to_host dictionary definition, modified add_group_vars to return group_vars, enhanced adjust_inventory_host with Docker connection handling to skip mgmt.ipv4 for Docker nodes |
| netsim/outputs/ansible.py | Removed duplicate ansible_inventory_host function and local topo_to_host definition, replaced with call to shared adjust_inventory_host from common module |
This patch resolves #2911 because it ensures Ansible always gets an IPv4 address for SSH connections. Beneficial side effects: * Access to SSH containers and VMs is completely identical and is no longer dependent on /etc/hosts * Ansible output module uses the same 'adjust_inventory_host' function as all other code * All the duplicate code in the 'ansible' output module is gone
d2a44d3 to
d95bd6d
Compare
ipspace
added a commit
that referenced
this pull request
Dec 11, 2025
Owner
Author
|
@DanPartelly -- it looks like I finally nailed this one. Running integration tests now. The platform ones passed, the initial device configurations will take "forever" |
ipspace
added a commit
that referenced
this pull request
Dec 12, 2025
ipspace
added a commit
that referenced
this pull request
Dec 13, 2025
This patch resolves #2911 because it ensures Ansible always gets an IPv4 address for SSH connections. Beneficial side effects: * Access to SSH containers and VMs is completely identical and is no longer dependent on /etc/hosts * Ansible output module uses the same 'adjust_inventory_host' function as all other code * All the duplicate code in the 'ansible' output module is gone
ipspace
added a commit
that referenced
this pull request
Feb 3, 2026
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.
This patch resolves #2911 because it ensures Ansible always gets an IPv4 address for SSH connections.
Beneficial side effects: