Skip to content

Conversation

@maylikenoother
Copy link

Summary

Fixes #86298.

Since 2.19, ssh connection has_tty uses _is_tty_requested() which only inspects ssh args and ignores the use_tty option. This causes become plugins that require a TTY (e.g. community.general.machinectl) to fail even when ansible_ssh_use_tty/use_tty is enabled.

Changes

  • Make _is_tty_requested() return True when use_tty is enabled, so has_tty matches exec_command() behavior.
  • Add a unit test to ensure has_tty respects use_tty.
  • Add changelog fragment.

Testing

Unit test added; CI will validate.

@ansibot ansibot added needs_triage Needs a first human triage before being processed. has_issue labels Dec 24, 2025
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Jan 2, 2026
@ansibot ansibot added the stale_review Updates were made after the last review and the last review is more than 7 days old. label Jan 3, 2026
@maylikenoother
Copy link
Author

Thanks for the review!

I updated the ssh connection logic to avoid disabling pipelining when use_tty is true (default). _is_tty_requested() now returns True only when the active become plugin requires a TTY (become.require_tty) or when explicit SSH args request a TTY (-t / RequestTTY=yes|force).

I also updated/added unit tests:

  • has_tty respects become.require_tty
  • regression: pipelining is not disabled solely due to default use_tty

@ansibot ansibot removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Jan 3, 2026
@s-hertel s-hertel dismissed their stale review January 5, 2026 14:53

pipelining no longer broken

@s-hertel s-hertel requested a review from bcoca January 5, 2026 14:53
@ansibot ansibot removed the stale_review Updates were made after the last review and the last review is more than 7 days old. label Jan 5, 2026
@bcoca
Copy link
Member

bcoca commented Jan 5, 2026

So the reason use_tty was not inspected was due to the assumption that it would already be factored in the resulting arguments. If that assumption is incorrect and the arguments are not properly constructed, the whole check is problematic, it should only occur on finalized arguments.

So I don't think this fix goes in the right direction, as it will hide the real underlying problem.

Copy link
Member

@bcoca bcoca left a comment

Choose a reason for hiding this comment

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

I would stress integration tests over unit tests in this case.

@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Jan 5, 2026
@s-hertel s-hertel changed the title ssh connection: has_tty respects use_tty option ssh connection: has_tty respects become plugin requires_tty Jan 5, 2026
@s-hertel
Copy link
Contributor

s-hertel commented Jan 5, 2026

@bcoca The PR is unrelated to use_tty now, I updated the title to reflect the current branch.

The underlying issue is specific to the ssh connection, and occurs here: https://github.com/ansible/ansible/blob/devel/lib/ansible/executor/task_executor.py#L1035-L1039. The ssh connection overrides has_tty and does not check whether the become plugin requires a tty.

@s-hertel s-hertel changed the title ssh connection: has_tty respects become plugin requires_tty ssh connection: has_tty respects become plugin require_tty Jan 5, 2026
@bcoca
Copy link
Member

bcoca commented Jan 5, 2026

I'm not sure what the issue is then, that code in TE just makes sure the configurations are in agreement.

If I'm reading the change correctly this basically overrides the user's conflicting configuration and gives priority to the become plugin?

@s-hertel
Copy link
Contributor

s-hertel commented Jan 5, 2026

Prior to 7290959, has_tty was true for the ssh connection. The changelog suggests the only reason this was done, was to disable pipelining by default:

  • ssh connection plugin now overrides pipelining when a tty is requested.

If the become plugin requires a TTY, it should do the same thing imo. An alternative fix would be to remove the has_tty property (so it's always True again), so _is_tty_requested only used for automatically disabling pipelining. I think this might be slightly better, since become plugins can configure pipelining separately.

@bcoca
Copy link
Member

bcoca commented Jan 5, 2026

talked with @s-hertel and realized that we have several issues:

  • ssh defaults to using tty (use_tty defaults to true), even though it should only do so if explicitly set on ssh connection or required by become plugin
  • _is_tty_requesxted does not match the actual command build for it's detection, why adding check on use_tty 'worked'TM, but was still incorrect.
  • missing integration tests for these paths

use_tty should be factored in _build_command and then switch _is_tty_requested to use _build_command, so both paths match. Also make the default for has_tty 'smart' and depend on pipelining and become plugin settings

@ansibot ansibot added the stale_review Updates were made after the last review and the last review is more than 7 days old. label Jan 8, 2026
@ansibot ansibot removed the stale_review Updates were made after the last review and the last review is more than 7 days old. label Jan 8, 2026
@mattclay mattclay removed their request for review January 8, 2026 19:57
@mattclay mattclay dismissed their stale review January 8, 2026 20:00

Ignore my request, I had overlooked an earlier comment from bcoca.

@webknjaz webknjaz added the ci_verified Changes made in this PR are causing tests to fail. label Jan 8, 2026
@ansibot ansibot added the stale_review Updates were made after the last review and the last review is more than 7 days old. label Jan 8, 2026
@maylikenoother maylikenoother requested a review from bcoca January 8, 2026 20:39
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Jan 8, 2026
@maylikenoother
Copy link
Author

maylikenoother commented Jan 9, 2026

@bcoca

I’ve dropped the become.require_tty check from _is_tty_requested() and instead aligned tty detection with the actual ssh command generation.

@webknjaz webknjaz added the ci_verified Changes made in this PR are causing tests to fail. label Jan 9, 2026
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Jan 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

has_issue needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. needs_triage Needs a first human triage before being processed. stale_review Updates were made after the last review and the last review is more than 7 days old.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSH connection has_tty does not check use_tty option, breaks machinectl

6 participants