[Ansible Galaxy] Use Ansible geerlingguy.homebrew to install packages with the Homebrew package manager
Ansible Role: Homebrew
Installs Homebrew on MacOS, and configures packages, taps, and cask apps according to supplied variables.
Installation
First, Install Ansible.
1 | Mac OS X |
Then, install it use:
1 | ansible-galaxy install geerlingguy.homebrew |
Role Variables
Available variables are listed below, along with default values (see defaults/main.yml
):
1 | homebrew_repo: https://github.com/Homebrew/brew |
The path where Homebrew will be installed (homebrew_prefix
is the parent directory). It is recommended you stick to the default, otherwise Homebrew might have some weird issues. If you change this variable, you should also manually create a symlink back to /usr/local
so things work as Homebrew expects.
1 | homebrew_brew_bin_path: /usr/local/bin |
The path where brew will be installed.
1 | homebrew_installed_packages: |
Packages you would like to make sure are installed via brew install. You can optionally add flags to the install by setting an install_options property, and if used, you need to explicitly set the name for the package as well. By default, no packages are installed (homebrew_installed_packages: []
).
1 | homebrew_uninstalled_packages: [] |
Packages you would like to make sure are uninstalled.
1 | homebrew_upgrade_all_packages: false |
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
.
1 | homebrew_taps: |
Taps you would like to make sure Homebrew has tapped.
1 | homebrew_cask_apps: |
Apps you would like to have installed via cask. Search for popular apps to see if they’re available for install via Cask. Cask will not be used if it is not included in the list of taps in the homebrew_taps variable. You can optionally add flags to the install by setting an install_options property, and if used, you need to explicitly set the name for the package as well. By default, no Cask apps will be installed (homebrew_cask_apps: []
).
1 | homebrew_cask_accept_external_apps: true |
Default value is false and would result in interruption of further processing of the whole role (and ansible play) in case any app given in homebrew_cask_apps
is already installed without cask. Good for a tightly managed system.
Specify as true
instead if you prefer to silently continue if any App is already installed without cask. Generally good for a system that is managed with cask / Ansible as well as other install methods (like manually) at the same time.
1 | homebrew_cask_uninstalled_apps: |
Apps you would like to make sure are uninstalled.
1 | homebrew_cask_appdir: /Applications |
Directory where applications installed via cask should be installed.
1 | homebrew_use_brewfile: true |
Whether to install via a Brewfile
. If so, you will need to install the homebrew/bundle
tap, which could be done within homebrew_taps
.
1 | homebrew_brewfile_dir: '~' |
The directory where your Brewfile is located.
1 | homebrew_clear_cache: false |
Set to true to remove the Hombrew cache after any new software is installed.
1 | homebrew_user: "{{ ansible_user_id }}" |
The user that you would like to install Homebrew as.
1 | homebrew_group: "{{ ansible_user_gid }}" |
The group that you would like to use while installing Homebrew.
1 | homebrew_folders_additional: [] |
Any additional folders inside homebrew_prefix
for which to ensure homebrew user/group ownership.
Dependencies
Example Playbook
1 | - hosts: localhost |
See the tests/local-testing directory for an example of running this role over Ansible’s local connection. See also: Mac Development Ansible Playbook - https://github.com/geerlingguy/mac-dev-playbook.
References
[2] geerlingguy/homebrew | Ansible Galaxy - https://galaxy.ansible.com/geerlingguy/homebrew
[3] Mac Development Ansible Playbook - https://github.com/geerlingguy/mac-dev-playbook
[4] The Missing Package Manager for macOS (or Linux) — Homebrew - https://brew.sh/
[5] Ansible is Simple IT Automation - https://www.ansible.com/