Skip to content

Use mgmt.ipv4 as ansible_host for containers with SSH servers#2913

Merged
ipspace merged 1 commit intodevfrom
ansible-host-ipv4
Dec 13, 2025
Merged

Use mgmt.ipv4 as ansible_host for containers with SSH servers#2913
ipspace merged 1 commit intodevfrom
ansible-host-ipv4

Conversation

@ipspace
Copy link
Owner

@ipspace ipspace commented Dec 11, 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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_host to ensure mgmt.ipv4 overwrites hostname for 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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

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
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

ipspace added a commit that referenced this pull request Dec 11, 2025
@ipspace
Copy link
Owner Author

ipspace commented Dec 11, 2025

@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 ipspace merged commit 6b5171e into dev Dec 13, 2025
17 checks passed
@ipspace ipspace deleted the ansible-host-ipv4 branch December 13, 2025 07:24
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
The SR Linux 'reload config' used 'docker cp' which broke after #2913.
Using 'scp' instead of that seems to work like a charm.

Closes #3067
ipspace added a commit that referenced this pull request Feb 3, 2026
The SR Linux 'reload config' used 'docker cp' which broke after #2913.
Using 'scp' instead of that seems to work like a charm.

Closes #3067
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] ansible-pysshlib breaks netlab initial configuration when hostnames contain underscores

1 participant