community.general.homebrew – Package manager for Homebrew

Note

This plugin is part of the community.general collection (version 3.8.1).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.homebrew.

Synopsis

  • Manages Homebrew packages

Requirements

The below requirements are needed on the host that executes this module.

  • python >= 2.6
  • homebrew must already be installed on the target system

Parameters

Parameter Choices/Defaults Comments
install_options
list / elements=string
options flags to install a package.

aliases: options
name
list / elements=string
A list of names of packages to install/remove.

aliases: formula, package, pkg
path
path
Default:
"/usr/local/bin:/opt/homebrew/bin"
A ':' separated list of paths to search for 'brew' executable. Since a package (formula in homebrew parlance) location is prefixed relative to the actual path of brew command, providing an alternative brew path enables managing different set of packages in an alternative location in the system.
state
string
    Choices:
  • absent
  • head
  • installed
  • latest
  • linked
  • present
  • removed
  • uninstalled
  • unlinked
  • upgraded
state of the package.
update_homebrew
boolean
    Choices:
  • no
  • yes
update homebrew itself first.
Alias update-brew has been deprecated and will be removed in community.general 5.0.0.

aliases: update-brew
upgrade_all
boolean
    Choices:
  • no
  • yes
upgrade all homebrew packages.

aliases: upgrade
upgrade_options
list / elements=string
added in 0.2.0 of community.general
Option flags to upgrade.

Notes

Note

  • When used with a loop: each package will be processed individually, it is much more efficient to pass the list directly to the name option.

Examples

# Install formula foo with 'brew' in default path
- community.general.homebrew:
    name: foo
    state: present

# Install formula foo with 'brew' in alternate path C(/my/other/location/bin)
- community.general.homebrew:
    name: foo
    path: /my/other/location/bin
    state: present

# Update homebrew first and install formula foo with 'brew' in default path
- community.general.homebrew:
    name: foo
    state: present
    update_homebrew: yes

# Update homebrew first and upgrade formula foo to latest available with 'brew' in default path
- community.general.homebrew:
    name: foo
    state: latest
    update_homebrew: yes

# Update homebrew and upgrade all packages
- community.general.homebrew:
    update_homebrew: yes
    upgrade_all: yes

# Miscellaneous other examples
- community.general.homebrew:
    name: foo
    state: head

- community.general.homebrew:
    name: foo
    state: linked

- community.general.homebrew:
    name: foo
    state: absent

- community.general.homebrew:
    name: foo,bar
    state: absent

- community.general.homebrew:
    name: foo
    state: present
    install_options: with-baz,enable-debug

- name: Install formula foo with 'brew' from cask
  community.general.homebrew:
    name: homebrew/cask/foo
    state: present

- name: Use ignore-pinned option while upgrading all
  community.general.homebrew:
    upgrade_all: yes
    upgrade_options: ignore-pinned

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
changed_pkgs
list / elements=string
added in 0.2.0 of community.general
success
List of package names which are changed after module run

Sample:
['git', 'git-cola']
msg
string
always
if the cache was updated or not

Sample:
Changed: 0, Unchanged: 2
unchanged_pkgs
list / elements=string
added in 0.2.0 of community.general
success
List of package names which are unchanged after module run

Sample:
['awscli', 'ag']


Authors

  • Indrajit Raychaudhuri (@indrajitr)
  • Daniel Jaouen (@danieljaouen)
  • Andrew Dunham (@andrew-d)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/homebrew_module.html