homebrew_cask: reinstall when force is install option (#4090)

* homebrew_cask: reinstall when force is install option

* add changelog entry

* Fix OSX CI runs - run as non-root

* test with cask that has no macos dependencies

* use `brooklyn` cask to test
This commit is contained in:
Joseph Torcasso 2022-02-02 15:31:05 -05:00 committed by GitHub
commit 8b95c56030
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 87 additions and 1 deletions

View file

@ -102,6 +102,12 @@ EXAMPLES = '''
state: present
install_options: 'debug,appdir=/Applications'
- name: Install cask with force option
community.general.homebrew_cask:
name: alfred
state: present
install_options: force
- name: Allow external app
community.general.homebrew_cask:
name: alfred
@ -600,7 +606,7 @@ class HomebrewCask(object):
self.message = 'Invalid cask: {0}.'.format(self.current_cask)
raise HomebrewCaskException(self.message)
if self._current_cask_is_installed():
if '--force' not in self.install_options and self._current_cask_is_installed():
self.unchanged_count += 1
self.message = 'Cask already installed: {0}'.format(
self.current_cask,