Skip to content

Scope Ansible connection vars per host#23298

Draft
bingwang-ms wants to merge 3 commits intosonic-net:masterfrom
bingwang-ms:bwang/fix-ansible-connection-leakage
Draft

Scope Ansible connection vars per host#23298
bingwang-ms wants to merge 3 commits intosonic-net:masterfrom
bingwang-ms:bwang/fix-ansible-connection-leakage

Conversation

@bingwang-ms
Copy link
Collaborator

@bingwang-ms bingwang-ms commented Mar 25, 2026

Description of PR

Summary:
Prevent host-specific Ansible connection and credential overrides from leaking through shared variable-manager state and affecting later DUT operations in mixed topologies.

Fixes # N/A

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • New Test case
    • Skipped for non-supported platforms
  • Test case improvement

Back port request

  • 202205
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

Approach

What is the motivation for this PR?

Mixed fanout environments can exercise different device wrappers in the same run. Some wrappers were storing host-specific values such as ansible_connection, credentials, and become settings in shared variable_manager.extra_vars. That allowed one host's connection mode, for example network_cli, to leak into later DUT operations and caused commands such as duthost.command() and duthost.shell() to run with the wrong connection context.

How did you do it?

Added host-scoped variable helpers in AnsibleHostBase and updated the affected device wrappers to set connection and authentication overrides on the target inventory host instead of writing them into shared extra vars.

How did you verify/test it?

Ran:
python -m py_compile tests/common/devices/base.py tests/common/devices/sonic.py tests/common/devices/aos.py tests/common/devices/arista.py tests/common/devices/cisco.py tests/common/devices/eos.py tests/common/devices/juniper.py tests/common/devices/k8s.py tests/common/devices/onyx.py

Any platform specific information?

No platform-specific behavior is intended. The fix is framework-side and applies to mixed topologies where multiple host wrappers are used in the same run.

Supported testbed topology if it's a new test case?

N/A

Documentation

No documentation update is required for this framework fix.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Bing Wang (SONIC) <[email protected]>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bingwang-ms bingwang-ms added the Request for 202511 branch Request to backport a change to 202511 branch label Mar 25, 2026
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Bing Wang (SONIC) <[email protected]>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Bing Wang (SONIC) <[email protected]>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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

Labels

Request for 202511 branch Request to backport a change to 202511 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants