Skip to content

community.general.homebrew_cask doesn't prompting for password if required Ansible core 2.19.2 #10866

@stevo-knievo

Description

@stevo-knievo

Summary

My bootstrap.sh script ensures that:

  • sudo permissions are available
  • brew is installed
  • ansible is installed (brew install ansible)

Expected Behavior (Previously)

With older versions of Ansible, when the playbook hit a brew task that required sudo, the terminal prompted for a password, like so:

TASK [windows-app : Installing Windows App] ****************************************************************************************************************
Monday 29 September 2025  10:55:02 -0700 (0:00:01.926)       0:04:48.942 ******
Password:

Current Behavior (Ansible 2.19.2)

[ERROR]: Task failed: Module failed: sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required
Error: Failure while executing; `/usr/bin/sudo -u root -E LOGNAME=stefankoch USER=stefankoch USERNAME=stefankoch -- /usr/sbin/installer -pkg /opt/homebrew/Caskroom/windows-app/11.2.3/Windows_App_11.2.3_installer.pkg -target /` exited with 1. Here's the output:
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required
Origin: /Users/stefankoch/Code/install/macos/dotnet-dev.yml:5:7

3   hosts: localhost
4   tasks:
5     - name: "Installing Windows App"
        ^ column 7

fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper\nsudo: a password is required\nError: Failure while executing; `/usr/bin/sudo -u root -E LOGNAME=stefankoch USER=stefankoch USERNAME=stefankoch -- /usr/sbin/installer -pkg /opt/homebrew/Caskroom/windows-app/11.2.3/Windows_App_11.2.3_installer.pkg -target /` exited with 1. Here's the output:\nsudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper\nsudo: a password is required"}

Issue Type

Bug Report

Component Name

community.general.homebrew_cask

Ansible Version

$ ansible --version
ansible [core 2.19.2]
  config file = /Users/stefankoch/Code/install/macos/ansible.cfg
  configured module search path = ['/Users/stefankoch/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/Cellar/ansible/12.0.0/libexec/lib/python3.13/site-packages/ansible
  ansible collection location = /Users/stefankoch/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.13.7 (main, Aug 14 2025, 11:12:11) [Clang 17.0.0 (clang-1700.0.13.3)] (/opt/homebrew/Cellar/ansible/12.0.0/libexec/bin/python)
  jinja version = 3.1.6
  pyyaml version = 6.0.2 (with libyaml v0.2.5)

Community.general Version

$ ansible-galaxy collection list community.general

# /opt/homebrew/Cellar/ansible/12.0.0/libexec/lib/python3.13/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 11.2.1

Configuration

$ ansible-config dump --only-changed
CALLBACKS_ENABLED(/Users/stefankoch/Code/install/macos/ansible.cfg) = ['profile_tasks']
CONFIG_FILE() = /Users/stefankoch/Code/install/macos/ansible.cfg
DEFAULT_HOST_LIST(/Users/stefankoch/Code/install/macos/ansible.cfg) = ['/Users/stefankoch/Code/install>
DEFAULT_STDOUT_CALLBACK(/Users/stefankoch/Code/install/macos/ansible.cfg) = ansible.builtin.default
INTERPRETER_PYTHON(/Users/stefankoch/Code/install/macos/ansible.cfg) = auto_silent
RETRY_FILES_ENABLED(/Users/stefankoch/Code/install/macos/ansible.cfg) = False

OS / Environment

sw_vers
ProductName:                macOS
ProductVersion:         26.0
BuildVersion:           25A354

Steps to Reproduce

My bootstrap.sh

# --- Start install process ---------------------
# Temporarily elevates privileges allowing the current users to complete sensitive tasks without logging in as the root user.
echo "Checking for sudo access (which may request your password)..."
sudo ls >/dev/null 2>&1

echo "* Homebrew Installation"
echo "*********************************************************************"

# install Homebrew in NONINTERACTIVE mode
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# This updates your current Terminal shell session with the new environment variables.
eval "$(/opt/homebrew/bin/brew shellenv)";

echo "* Ansible Installation"
echo "*********************************************************************"
brew install -q ansible

echo "* Run Ansible"
echo "*********************************************************************"
ansible-playbook demo.yml

demo.yml

---
- name: Demo
  hosts: localhost
  tasks:
    - name: "Installing Windows App"
      community.general.homebrew_cask:
        state: latest
        name: "windows-app"

Expected Results

I would expect a password prompt

TASK [windows-app : Installing Windows App] ****************************************************************************************************************
Monday 29 September 2025  10:55:02 -0700 (0:00:01.926)       0:04:48.942 ******
Password:

Actual Results

[ERROR]: Task failed: Module failed: sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required
Error: Failure while executing; `/usr/bin/sudo -u root -E LOGNAME=stefankoch USER=stefankoch USERNAME=stefankoch -- /usr/sbin/installer -pkg /opt/homebrew/Caskroom/windows-app/11.2.3/Windows_App_11.2.3_installer.pkg -target /` exited with 1. Here's the output:
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required
Origin: /Users/stefankoch/Code/install/macos/dotnet-dev.yml:5:7

3   hosts: localhost
4   tasks:
5     - name: "Installing Windows App"
        ^ column 7

fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper\nsudo: a password is required\nError: Failure while executing; `/usr/bin/sudo -u root -E LOGNAME=stefankoch USER=stefankoch USERNAME=stefankoch -- /usr/sbin/installer -pkg /opt/homebrew/Caskroom/windows-app/11.2.3/Windows_App_11.2.3_installer.pkg -target /` exited with 1. Here's the output:\nsudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper\nsudo: a password is required"}

Code of Conduct

  • I agree to follow the Ansible Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue/PR relates to a bugmodulemodulepluginsplugin (any type)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions