ctorgalson.linuxbrew
Linuxbrew (ctorgalson.linuxbrew)
Manually installs linuxbrew, brew packages, and taps on Ubuntu/Debian and Fedora
to avoid piping a shell script to sh :)
The role assumes that it could be run in a playbook that uses become: true,
so it requires the name of a non-root user to run brew commands safely. For
other tasks--such as installing dependencies using apt--it uses become to
escalate privileges. The result is, it should work regardless of the value of
ansible_user, as long as the {{ lb__owner }} user exists.
Credit to markosamuli for a good Linuxbrew role that didn't quite match up with my needs. I've used that role as the basis for this one (and probably introduced my own mistakes).
Tasks
The role is broken down into three tasks files:
main.yml
This file:
- checks if
brewalready exists, - includes
install.ymlwhenbrewdoes not yet exist, - includes
packages.ymlwhen thelb__packagesvariable is not empty, or either of the two variableslb__update_homebrew_when_installing_packages, orlb__upgrade_all_when_installing_packagesistrue. - includes any number of shell-configuration (or other) task files provided
in
lb__shell_configuration_tasks.
install.yml
This file:
- installs dependencies using
apt, - creates required Linuxbrew directories,
- clones the main and core Homebrew repos,
- symlinks the
brewbinary, - installs the
portable-rubypackage.
packages.yml
This file:
- updates
brewitself whenlb__update_homebrew_when_installing_packagesistrue, - updates all
brewpackages whenlb__upgrade_all_when_installing_packagesistrue, - installs any
brewpackages defined inlb__packages, - installs any
brewtaps defined inlb__taps.
Requirements
No special requirements.
Role Variables
Vars
| Name | Type | Default | Description |
|---|---|---|---|
lb__prefix |
string | /home/linuxbrew/.linuxbrew |
Location for all brew related files. |
lb__brew |
string | {{ lb__prefix }}/bin/brew |
Path to the brew binary. |
lb__homebrew_dir |
string | {{ lb__prefix }}/Homebrew |
Path to the Homebrew repo directory. |
lb__homebrew_core_dir |
string | {{ lb__prefix }}/Homebrew/Library/Taps/homebrew-core |
Path to the Homebrew core repo directory. |
lb__directories |
list | See vars/main.yml |
List of directories to be created in lb__prefix dir. |
lb__repos |
list | See vars/main.yml |
List of repos to be cloned during install. Each item must have repo, dest, and version properties suitable for ansible.builtin.git. |
lb__dependencies |
list | See vars/main.yml |
List of apt packages required for brew install and use. |
Defaults
| Name | Type | Default | Description |
|---|---|---|---|
lb__owner |
string | {{ ansible_user }} |
The name of the owner for the {{ lb__prefix }} directory and contents. |
lb__group |
string | {{ ansible_user }} |
The name of the group for the {{ lb__prefix }} directory and contents. |
lb__shell_configuration_tasks |
list | [] |
A list of paths to Ansible task include files to be run after the basic installation. |
lb__update_homebrew_when_installing_packages |
boolean | true |
Whether or not to update brew when installing new pacakges. |
lb__upgrade_all_when_installing_packages |
boolean | true |
Whether or not to upgrade Linuxbrew package when installing new pacakges. |
lb__packages |
list | [] |
A list of Linuxbrew packages to install. Each item must specify a name property, and can have optional state, path, and install_options properties suitable for ansible.community.homebrew. |
lb__taps |
list | [] |
A list of Linuxbrew taps to install. Each item must specify a name property, and can have state, path, and url properties suitable for ansible.community.homebrew_tap. |
Dependencies
This role relies on 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