ctorgalson.linuxbrew
Linuxbrew (ctorgalson.linuxbrew
)
This guide explains how to manually install Linuxbrew, brew packages, and taps on Ubuntu/Debian and Fedora, ensuring no scripts are piped directly to sh
.
The role can be used in a playbook that runs with become: true
, so it needs the name of a non-root user to run brew
commands safely. For installing dependencies with apt
, it uses become
to gain higher privileges. It should work regardless of the ansible_user
, as long as the {{ lb__owner }}
user exists.
Thanks to markosamuli for their excellent Linuxbrew role, which inspired this one (although I may have made some mistakes).
Tasks
The role has three task files:
main.yml
This file:
- Checks if
brew
is already installed. - Includes
install.yml
ifbrew
is not installed. - Includes
packages.yml
if thelb__packages
variable isn't empty, or if eitherlb__update_homebrew_when_installing_packages
orlb__upgrade_all_when_installing_packages
istrue
. - Includes additional shell configuration tasks from
lb__shell_configuration_tasks
.
install.yml
This file:
- Installs dependencies with
apt
. - Creates necessary Linuxbrew directories.
- Clones the main and core Homebrew repositories.
- Links the
brew
binary. - Installs the
portable-ruby
package.
packages.yml
This file:
- Updates
brew
iflb__update_homebrew_when_installing_packages
istrue
. - Updates all
brew
packages iflb__upgrade_all_when_installing_packages
istrue
. - Installs any packages listed in
lb__packages
. - Installs any taps listed in
lb__taps
.
Requirements
No special requirements needed.
Role Variables
Vars
Name | Type | Default | Description |
---|---|---|---|
lb__prefix |
string | /home/linuxbrew/.linuxbrew |
Location for all brew files. |
lb__brew |
string | {{ lb__prefix }}/bin/brew |
Path to the brew binary. |
lb__homebrew_dir |
string | {{ lb__prefix }}/Homebrew |
Path to the Homebrew repository. |
lb__homebrew_core_dir |
string | {{ lb__prefix }}/Homebrew/Library/Taps/homebrew-core |
Path to the Homebrew core repository. |
lb__directories |
list | See vars/main.yml |
Directories to create in lb__prefix . |
lb__repos |
list | See vars/main.yml |
Repositories to clone during installation. Must include repo , dest , and version . |
lb__dependencies |
list | See vars/main.yml |
apt packages needed for brew . |
Defaults
Name | Type | Default | Description |
---|---|---|---|
lb__owner |
string | {{ ansible_user }} |
Owner of the {{ lb__prefix }} directory and files. |
lb__group |
string | {{ ansible_user }} |
Group for the {{ lb__prefix }} directory and files. |
lb__shell_configuration_tasks |
list | [] |
Paths to tasks to run after installation. |
lb__update_homebrew_when_installing_packages |
boolean | true |
Whether to update brew when adding new packages. |
lb__upgrade_all_when_installing_packages |
boolean | true |
Whether to upgrade all packages when adding new ones. |
lb__packages |
list | [] |
Linuxbrew packages to install. Must include a name , and may include optional properties. |
lb__taps |
list | [] |
Linuxbrew taps to install. Must include a name , and may have other optional properties. |
Dependencies
This role uses the ansible.community
collection for the homebrew
and homebrew_tap
modules.
Example Playbook
- hosts: servers
become: true
vars:
lb__owner: "ctorgalson"
lb__group: "{{ lb__owner }}"
lb__packages:
- name: "bottom"
state: "present"
- name: "starship"
state: "present"
tasks:
- name: "Install and configure Linuxbrew, packages, and taps."
ansible.builtin.import_role:
name: "ctorgalson.linuxbrew"
License
GPL-3.0-only
Installs linuxbrew, brew packages, and taps on Ubuntu/Debian.
ansible-galaxy install ctorgalson.linuxbrew