ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
788 stars 1.45k forks source link

Wrong error message / failure on upgrading latest -> latest homebrew cask #1647

Open cdayjr opened 3 years ago

cdayjr commented 3 years ago
SUMMARY

I have a cask that does not have a checksum, so when you install or upgrade it, it emits the following message but continues successfully:

Warning: No checksum defined for cask 'firefox-developer-edition', skipping verification.

When running in ansible, the tasks gets marked as failed and only this is picked up for the error message. I believe the task failure is because of this https://github.com/ansible-collections/community.general/blob/3b9c6d496bbb5b24e1281c59025903fea7d4718e/plugins/modules/packaging/os/homebrew_cask.py#L697-L705 - the check if a cask has been upgraded will never return true for a greedy latest -> latest, but I'm not sure why the error message is that warning when it doesn't affect the command competing at all.

ISSUE TYPE
COMPONENT NAME

homebrew_cask

ANSIBLE VERSION
ansible 2.10.4
  config file = None
  configured module search path = ['/Users/cdayjr/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/2.10.5/libexec/lib/python3.9/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.9.1 (default, Jan  8 2021, 17:17:43) [Clang 12.0.0 (clang-1200.0.32.28)]
CONFIGURATION
OS / ENVIRONMENT

Just running this on localhost, here's my system info:

 cdayjr@Mac-mini
 OS: 64bit macOS 11.1 20C69
 Kernel: x86_64 Darwin 20.2.0
 Uptime: 1h 27m
 Packages: 231
 Shell: zsh 5.8
 Resolution: 2560x1440, 1920x1200 
 DE: Aqua
 WM: Quartz Compositor
 WM Theme: Blue (Dark)
 Disk: 122G / 400G (32%)
 CPU: Intel Core i7-8700B @ 3.20GHz
 GPU: Intel UHD Graphics 630 
 RAM: 4292MiB / 8192MiB
STEPS TO REPRODUCE

Here's the full manual update command + results:

$ brew upgrade --cask homebrew/cask-versions/firefox-developer-edition
==> Upgrading 1 outdated package:
firefox-developer-edition latest -> latest
==> Upgrading firefox-developer-edition
==> Downloading https://download.mozilla.org/?product=firefox-devedition-latest-ssl&os=osx&lang=en-US
Already downloaded: /Users/cdayjr/Library/Caches/Homebrew/downloads/382608000536d61f64e4a147e764c559ce144c3f04dd0f05209549d3bf118f1a--Firefox 85.0b9.dmg
Warning: No checksum defined for cask 'firefox-developer-edition', skipping verification.
==> Backing App 'Firefox Developer Edition.app' up to '/usr/local/Caskroom/firefox-developer-edition/latest/Firefox De
==> Removing App '/Applications/Firefox Developer Edition.app'.
==> Moving App 'Firefox Developer Edition.app' to '/Applications/Firefox Developer Edition.app'.
==> Purging files for version latest of Cask firefox-developer-edition
🍺  firefox-developer-edition was successfully upgraded!

However, when I run the following task in ansible (note the homebrew tap homebrew/cask-versions is already installed before we get to this point):

    - name: Install firefox-developer-edition from casks versions repo
      community.general.homebrew_cask:
        name:
          - homebrew/cask-versions/firefox-developer-edition
        state: latest
        greedy: true

Note, you can get the error without greedy: true if it's not already upgraded, but you can always reproduce it with the flag so I left it in there.

EXPECTED RESULTS

The task being marked as changed as an upgrade happened, even if it still shows that latest can be upgraded to latest. But if not, I just don't want that unrelated warning message sent back as the failure message.

ACTUAL RESULTS

without verbosity:

TASK [Install firefox-developer-edition from casks versions repo] ****************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Warning: No checksum defined for cask 'firefox-developer-edition', skipping verification."}

with verbosity -vvvv:

TASK [Install firefox-developer-edition from casks versions repo] ****************************************************
task path: /Users/cdayjr/test.yaml:7
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: cdayjr
<localhost> EXEC /bin/sh -c 'echo ~cdayjr && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/cdayjr/.ansible/tmp `"&& mkdir "` echo /Users/cdayjr/.ansible/tmp/ansible-tmp-1610943951.783828-2529-257457941825376 `" && echo ansible-tmp-1610943951.783828-2529-257457941825376="` echo /Users/cdayjr/.ansible/tmp/ansible-tmp-1610943951.783828-2529-257457941825376 `" ) && sleep 0'
Using module file /Users/cdayjr/.ansible/collections/ansible_collections/community/general/plugins/modules/homebrew_cask.py
<localhost> PUT /Users/cdayjr/.ansible/tmp/ansible-local-249407o50ha2/tmp615562yf TO /Users/cdayjr/.ansible/tmp/ansible-tmp-1610943951.783828-2529-257457941825376/AnsiballZ_homebrew_cask.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/cdayjr/.ansible/tmp/ansible-tmp-1610943951.783828-2529-257457941825376/ /Users/cdayjr/.ansible/tmp/ansible-tmp-1610943951.783828-2529-257457941825376/AnsiballZ_homebrew_cask.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/env python3 /Users/cdayjr/.ansible/tmp/ansible-tmp-1610943951.783828-2529-257457941825376/AnsiballZ_homebrew_cask.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/cdayjr/.ansible/tmp/ansible-tmp-1610943951.783828-2529-257457941825376/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "accept_external_apps": false,
            "greedy": true,
            "install_options": [],
            "name": [
                "homebrew/cask-versions/firefox-developer-edition"
            ],
            "path": "/usr/local/bin",
            "state": "latest",
            "sudo_password": null,
            "update_homebrew": false,
            "upgrade_all": false
        }
    },
    "msg": "Warning: No checksum defined for cask 'firefox-developer-edition', skipping verification."
}
ansibullbot commented 3 years ago

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 3 years ago

cc @Akasurde @danieljaouen @enriclluelles @indrajitr @kyleabenson @martinm82 click here for bot help

MichaelHeaton commented 1 year ago

I'm seeing the same error's with Google Chrome

google_chrome.yml

---
- name: Install Google Chrome Packages through Homebrew
  # https://formulae.brew.sh/cask/google-chrome
  when: ansible_distribution == 'MacOSX'
  homebrew:
    name: google-chrome
    state: present

Ansible output without chrome already installed

TASK [common : Install Google Chrome Packages through Homebrew] *******************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Warning: No checksum defined for cask 'google-chrome', skipping verification."}

PLAY RECAP ************************************************************************************
localhost                  : ok=6    changed=0    unreachable=0    failed=1    skipped=2    rescued=0    ignored=0

Ansible output with chrome already installed

TASK [common : Install Google Chrome Packages through Homebrew] *******************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Warning: Cask 'google-chrome' is already installed.\n\nTo re-install google-chrome, run:\n  brew reinstall --cask google-chrome"}

PLAY RECAP ************************************************************************************
localhost                  : ok=6    changed=0    unreachable=0    failed=1    skipped=2    rescued=0    ignored=0   
brew info google-chrome
==> google-chrome: 105.0.5195.125 (auto_updates)
https://www.google.com/chrome/
/opt/homebrew/Caskroom/google-chrome/105.0.5195.125 (61.7KB)
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/google-chrome.rb
==> Name
Google Chrome
==> Description
Web browser
==> Artifacts
Google Chrome.app (App)
==> Analytics
install: 18,368 (30 days), 55,474 (90 days), 288,587 (365 days)
ansibullbot commented 1 year ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help