From 46c85e75322c84aaff51b48f28c0558f05dea522 Mon Sep 17 00:00:00 2001 From: Thomas Deutsch Date: Tue, 17 Oct 2023 11:30:35 +0200 Subject: [PATCH] feat(homebrew): Add option to upgrade all casks --- roles/homebrew/README.md | 5 +++++ roles/homebrew/defaults/main.yml | 1 + roles/homebrew/tasks/main.yml | 12 ++++++++++++ 3 files changed, 18 insertions(+) diff --git a/roles/homebrew/README.md b/roles/homebrew/README.md index 1268acd..4cadc7c 100644 --- a/roles/homebrew/README.md +++ b/roles/homebrew/README.md @@ -38,6 +38,11 @@ Packages you would like to make sure are _uninstalled_. Whether to upgrade homebrew and all packages installed by homebrew. If you prefer to manually update packages via `brew` commands, leave this set to `false`. + + homebrew_cask_upgrade_all_packages: false + +Whether to upgrade homebrew and all cask applications installed by homebrew. If you prefer to manually update packages via `brew` commands, leave this set to `false`. + homebrew_taps: - homebrew/core - { name: my_company/internal_tap, url: 'https://example.com/path/to/tap.git' } diff --git a/roles/homebrew/defaults/main.yml b/roles/homebrew/defaults/main.yml index 02cd267..7abb44e 100644 --- a/roles/homebrew/defaults/main.yml +++ b/roles/homebrew/defaults/main.yml @@ -10,6 +10,7 @@ homebrew_installed_packages: [] homebrew_uninstalled_packages: [] homebrew_upgrade_all_packages: false +homebrew_cask_upgrade_all_packages: false homebrew_taps: - homebrew/core diff --git a/roles/homebrew/tasks/main.yml b/roles/homebrew/tasks/main.yml index ae8116c..d070236 100644 --- a/roles/homebrew/tasks/main.yml +++ b/roles/homebrew/tasks/main.yml @@ -136,6 +136,18 @@ notify: - Clear homebrew cache + - name: Upgrade all cask applications (if configured). + homebrew_cask: + install_options: "{{ item.install_options | default('appdir=' + homebrew_cask_appdir) }}" + accept_external_apps: "{{ homebrew_cask_accept_external_apps }}" + sudo_password: "{{ ansible_become_password | default(omit) }}" + update_homebrew: true + upgrade_all: true + greedy: true + when: homebrew_cask_upgrade_all_packages + notify: + - Clear homebrew cache + # Brew. - name: Ensure blacklisted homebrew packages are not installed. homebrew: "name={{ item }} state=absent"