Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

homebrew: reports failure when installing "emacs" formula #8229

Closed
1 task done
markshep opened this issue Apr 17, 2024 · 6 comments · Fixed by #8406
Closed
1 task done

homebrew: reports failure when installing "emacs" formula #8229

markshep opened this issue Apr 17, 2024 · 6 comments · Fixed by #8406
Labels
bug This issue/PR relates to a bug callback callback plugin module module plugins plugin (any type)

Comments

@markshep
Copy link

markshep commented Apr 17, 2024

Summary

When I try to install the "emacs" formula I get this error:

Warning: Treating emacs as a formula. For the cask, use homebrew/cask/emacs or specify the `--cask` flag.

Issue Type

Bug Report

Component Name

homebrew

Ansible Version

$ ansible --version
ansible [core 2.16.5]
  config file = None
  configured module search path = ['/Users/mark/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/Cellar/ansible/9.4.0_1/libexec/lib/python3.12/site-packages/ansible
  ansible collection location = /Users/mark/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.12.3 (main, Apr  9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)] (/opt/homebrew/Cellar/ansible/9.4.0_1/libexec/bin/python)
  jinja version = 3.1.3
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
# /opt/homebrew/Cellar/ansible/9.4.0_1/libexec/lib/python3.12/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 8.5.0  

Configuration

$ ansible-config dump --only-changed
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /Users/mark/bin/scripts/emacs
PAGER(env: PAGER) = less

OS / Environment

macOS 14.4.1 (23E224) on Apple Silicon M1
Homebrew 4.2.18

Steps to Reproduce

- name: "homebrew : install emacs"
  homebrew:
    name:
      - emacs
  become: true
  become_user: mark

Expected Results

I expect to install the "emacs" formula without issuing an error.

Actual Results

$ ansible-playbook -i inventory/main.yml site.yml -t macos --limit macbook-2020-wireless.ddf.intranet -vvv
ansible-playbook [core 2.16.5]
  config file = None
  configured module search path = ['/Users/mark/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/Cellar/ansible/9.4.0_1/libexec/lib/python3.12/site-packages/ansible
  ansible collection location = /Users/mark/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible-playbook
  python version = 3.12.3 (main, Apr  9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)] (/opt/homebrew/Cellar/ansible/9.4.0_1/libexec/bin/python)
  jinja version = 3.1.3
  libyaml = True
No config file found; using defaults
host_list declined parsing /Users/mark/code/ddf-ansible/inventory/main.yml as it did not pass its verify_file() method
script declined parsing /Users/mark/code/ddf-ansible/inventory/main.yml as it did not pass its verify_file() method
Parsed /Users/mark/code/ddf-ansible/inventory/main.yml inventory source with yaml plugin
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: site.yml *************************************************************
10 plays in site.yml

PLAY [base Debian configuration] ***********************************************

PLAY [base macOS configuration] ************************************************

TASK [macos-base : include_tasks] **********************************************
task path: /Users/mark/code/ddf-ansible/roles/macos-base/tasks/main.yml:2
redirecting (type: modules) ansible.builtin.homebrew to community.general.homebrew
included: /Users/mark/code/ddf-ansible/roles/macos-base/tasks/homebrew.yml for macbook-2020-wireless.ddf.intranet

TASK [macos-base : homebrew : install emacs] ***********************************
task path: /Users/mark/code/ddf-ansible/roles/macos-base/tasks/homebrew.yml:2
redirecting (type: modules) ansible.builtin.homebrew to community.general.homebrew
<macbook-2020-wireless.ddf.intranet> ESTABLISH SSH CONNECTION FOR USER: root
<macbook-2020-wireless.ddf.intranet> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/Users/mark/.ansible/cp/0622c77de3"' macbook-2020-wireless.ddf.intranet '/bin/sh -c '"'"'echo ~root && sleep 0'"'"''
<macbook-2020-wireless.ddf.intranet> (0, b'/var/root\n', b'')
<macbook-2020-wireless.ddf.intranet> ESTABLISH SSH CONNECTION FOR USER: root
<macbook-2020-wireless.ddf.intranet> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/Users/mark/.ansible/cp/0622c77de3"' macbook-2020-wireless.ddf.intranet '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /var/tmp `"&& mkdir "` echo /var/tmp/ansible-tmp-1713349079.605263-26016-197675568165086 `" && echo ansible-tmp-1713349079.605263-26016-197675568165086="` echo /var/tmp/ansible-tmp-1713349079.605263-26016-197675568165086 `" ) && sleep 0'"'"''
<macbook-2020-wireless.ddf.intranet> (0, b'ansible-tmp-1713349079.605263-26016-197675568165086=/var/tmp/ansible-tmp-1713349079.605263-26016-197675568165086\n', b'')
redirecting (type: modules) ansible.builtin.homebrew to community.general.homebrew
<macbook-2020-wireless.ddf.intranet> Attempting python interpreter discovery
<macbook-2020-wireless.ddf.intranet> ESTABLISH SSH CONNECTION FOR USER: root
<macbook-2020-wireless.ddf.intranet> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/Users/mark/.ansible/cp/0622c77de3"' macbook-2020-wireless.ddf.intranet '/bin/sh -c '"'"'echo PLATFORM; uname; echo FOUND; command -v '"'"'"'"'"'"'"'"'python3.12'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.11'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.10'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.9'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.8'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.7'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.6'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'/usr/bin/python3'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'/usr/libexec/platform-python'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python2.7'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'/usr/bin/python'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python'"'"'"'"'"'"'"'"'; echo ENDFOUND && sleep 0'"'"''
<macbook-2020-wireless.ddf.intranet> (0, b'PLATFORM\nDarwin\nFOUND\n/usr/bin/python3\nENDFOUND\n', b'')
<macbook-2020-wireless.ddf.intranet> Python interpreter discovery fallback (unsupported platform for extended discovery: darwin)
Using module file /opt/homebrew/Cellar/ansible/9.4.0_1/libexec/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/homebrew.py
<macbook-2020-wireless.ddf.intranet> PUT /Users/mark/.ansible/tmp/ansible-local-26012cb3gygb4/tmp8qfs6gfn TO /var/tmp/ansible-tmp-1713349079.605263-26016-197675568165086/AnsiballZ_homebrew.py
<macbook-2020-wireless.ddf.intranet> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/Users/mark/.ansible/cp/0622c77de3"' '[macbook-2020-wireless.ddf.intranet]'
<macbook-2020-wireless.ddf.intranet> (0, b'sftp> put /Users/mark/.ansible/tmp/ansible-local-26012cb3gygb4/tmp8qfs6gfn /var/tmp/ansible-tmp-1713349079.605263-26016-197675568165086/AnsiballZ_homebrew.py\n', b'')
<macbook-2020-wireless.ddf.intranet> ESTABLISH SSH CONNECTION FOR USER: root
<macbook-2020-wireless.ddf.intranet> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/Users/mark/.ansible/cp/0622c77de3"' macbook-2020-wireless.ddf.intranet '/bin/sh -c '"'"'setfacl -m u:mark:r-x /var/tmp/ansible-tmp-1713349079.605263-26016-197675568165086/ /var/tmp/ansible-tmp-1713349079.605263-26016-197675568165086/AnsiballZ_homebrew.py && sleep 0'"'"''
<macbook-2020-wireless.ddf.intranet> (127, b'', b'/bin/sh: setfacl: command not found\n')
<macbook-2020-wireless.ddf.intranet> Failed to connect to the host via ssh: /bin/sh: setfacl: command not found
<macbook-2020-wireless.ddf.intranet> ESTABLISH SSH CONNECTION FOR USER: root
<macbook-2020-wireless.ddf.intranet> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/Users/mark/.ansible/cp/0622c77de3"' macbook-2020-wireless.ddf.intranet '/bin/sh -c '"'"'chmod u+x /var/tmp/ansible-tmp-1713349079.605263-26016-197675568165086/ /var/tmp/ansible-tmp-1713349079.605263-26016-197675568165086/AnsiballZ_homebrew.py && sleep 0'"'"''
<macbook-2020-wireless.ddf.intranet> (0, b'', b'')
<macbook-2020-wireless.ddf.intranet> ESTABLISH SSH CONNECTION FOR USER: root
<macbook-2020-wireless.ddf.intranet> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/Users/mark/.ansible/cp/0622c77de3"' macbook-2020-wireless.ddf.intranet '/bin/sh -c '"'"'chown mark /var/tmp/ansible-tmp-1713349079.605263-26016-197675568165086/ /var/tmp/ansible-tmp-1713349079.605263-26016-197675568165086/AnsiballZ_homebrew.py && sleep 0'"'"''
<macbook-2020-wireless.ddf.intranet> (0, b'', b'')
<macbook-2020-wireless.ddf.intranet> ESTABLISH SSH CONNECTION FOR USER: root
<macbook-2020-wireless.ddf.intranet> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/Users/mark/.ansible/cp/0622c77de3"' -tt macbook-2020-wireless.ddf.intranet '/bin/sh -c '"'"'sudo -H -S -n  -u mark /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-jxffvulggznewlinyqnxidvwxiqiwxab ; /usr/bin/python3 /var/tmp/ansible-tmp-1713349079.605263-26016-197675568165086/AnsiballZ_homebrew.py'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
<macbook-2020-wireless.ddf.intranet> (1, b'shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied\r\njob-working-directory: error retrieving current directory: getcwd: cannot access parent directories: Permission denied\r\n\r\n{"failed": true, "msg": "Warning: Treating emacs as a formula. For the cask, use homebrew/cask/emacs or specify the `--cask` flag.", "invocation": {"module_args": {"name": ["emacs"], "path": "/usr/local/bin:/opt/homebrew/bin:/home/linuxbrew/.linuxbrew/bin", "state": "present", "update_homebrew": false, "upgrade_all": false, "install_options": [], "upgrade_options": []}}}\r\n', b'Shared connection to macbook-2020-wireless.ddf.intranet closed.\r\n')
<macbook-2020-wireless.ddf.intranet> Failed to connect to the host via ssh: Shared connection to macbook-2020-wireless.ddf.intranet closed.
<macbook-2020-wireless.ddf.intranet> ESTABLISH SSH CONNECTION FOR USER: root
<macbook-2020-wireless.ddf.intranet> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/Users/mark/.ansible/cp/0622c77de3"' macbook-2020-wireless.ddf.intranet '/bin/sh -c '"'"'rm -f -r /var/tmp/ansible-tmp-1713349079.605263-26016-197675568165086/ > /dev/null 2>&1 && sleep 0'"'"''
<macbook-2020-wireless.ddf.intranet> (0, b'', b'')
fatal: [macbook-2020-wireless.ddf.intranet]: FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "invocation": {
        "module_args": {
            "install_options": [],
            "name": [
                "emacs"
            ],
            "path": "/usr/local/bin:/opt/homebrew/bin:/home/linuxbrew/.linuxbrew/bin",
            "state": "present",
            "update_homebrew": false,
            "upgrade_all": false,
            "upgrade_options": []
        }
    },
    "msg": "Warning: Treating emacs as a formula. For the cask, use homebrew/cask/emacs or specify the `--cask` flag."
}

PLAY RECAP *********************************************************************
macbook-2020-wireless.ddf.intranet : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@markshep
Copy link
Author

markshep commented Apr 17, 2024

When I run brew directly I get this:

$ brew install emacs
Warning: Treating emacs as a formula. For the cask, use homebrew/cask/emacs or specify the `--cask` flag.
Warning: emacs 29.3 is already installed and up-to-date.
To reinstall 29.3, run:
  brew reinstall emacs

Adding the --formulae option suppresses the warning message that's triggering the error in Ansible:

$ brew install --formulae emacs
==> Downloading https://formulae.brew.sh/api/formula.jws.json

Warning: emacs 29.3 is already installed and up-to-date.
To reinstall 29.3, run:
  brew reinstall emacs

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug callback callback plugin plugins plugin (any type) labels Apr 17, 2024
@felixfontein
Copy link
Collaborator

See also #7044.

@felixfontein
Copy link
Collaborator

!component =plugins/modules/homebrew.py

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added the module module label Apr 17, 2024
@ggustafsson
Copy link

Same issue discussed here as well:
#8274

kustodian pushed a commit to kustodian/community.general that referenced this issue May 22, 2024
Instead of checking if there is an error message, which can also be a
warning, we now check the return code.

This commint fixes ansible-collections#8229 ansible-collections#7044
kustodian pushed a commit to kustodian/community.general that referenced this issue May 22, 2024
Instead of checking if there is an error message, which can also be a
warning, we now check the return code.

This commit fixes ansible-collections#8229 ansible-collections#7044
kustodian pushed a commit to kustodian/community.general that referenced this issue May 22, 2024
Instead of checking if there is an error message, which can also be a
warning, we now check the return code.

This commit fixes ansible-collections#8229 ansible-collections#7044
kustodian pushed a commit to kustodian/community.general that referenced this issue May 22, 2024
Instead of checking if there is an error message, which can also be a
warning, we now check the return code.

This commit fixes ansible-collections#8229 ansible-collections#7044
kustodian pushed a commit to kustodian/community.general that referenced this issue May 22, 2024
Instead of checking if there is an error message, which can also be a
warning, we now check the return code.

This commit fixes ansible-collections#8229 ansible-collections#7044
kustodian pushed a commit to kustodian/community.general that referenced this issue May 22, 2024
Instead of checking if there is an error message, which can also be a
warning, we now check the return code.

This commit fixes ansible-collections#8229 ansible-collections#7044
kustodian pushed a commit to kustodian/community.general that referenced this issue May 22, 2024
Instead of checking if there is an error message, which can also be a
warning, we now check the return code.

This commit fixes ansible-collections#8229 ansible-collections#7044
kustodian pushed a commit to kustodian/community.general that referenced this issue May 22, 2024
Instead of checking if there is an error message, which can also be a
warning, we now check the return code.

This commit fixes ansible-collections#8229 ansible-collections#7044
felixfontein pushed a commit that referenced this issue May 26, 2024
Instead of checking if there is an error message, which can also be a
warning, we now check the return code.

This commit fixes #8229 #7044

Co-authored-by: Strahinja Kustudic <strahinjak@nordeus.com>
patchback bot pushed a commit that referenced this issue May 26, 2024
Instead of checking if there is an error message, which can also be a
warning, we now check the return code.

This commit fixes #8229 #7044

Co-authored-by: Strahinja Kustudic <strahinjak@nordeus.com>
(cherry picked from commit 43cb5a0)
felixfontein pushed a commit that referenced this issue May 26, 2024
…g because of warnings (#8425)

Fix the homebrew module failing because of warnings (#8406)

Instead of checking if there is an error message, which can also be a
warning, we now check the return code.

This commit fixes #8229 #7044

Co-authored-by: Strahinja Kustudic <strahinjak@nordeus.com>
(cherry picked from commit 43cb5a0)

Co-authored-by: Strahinja Kustudic <kustodian@gmail.com>
felixfontein pushed a commit to felixfontein/community.general that referenced this issue May 27, 2024
…ons#8406)

Instead of checking if there is an error message, which can also be a
warning, we now check the return code.

This commit fixes ansible-collections#8229 ansible-collections#7044

Co-authored-by: Strahinja Kustudic <strahinjak@nordeus.com>
(cherry picked from commit 43cb5a0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug callback callback plugin module module plugins plugin (any type)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants