{"id":15715994,"url":"https://github.com/wayofdev/ansible-role-homebrew","last_synced_at":"2025-05-13T00:05:27.803Z","repository":{"id":37032590,"uuid":"494308321","full_name":"wayofdev/ansible-role-homebrew","owner":"wayofdev","description":"Ansible role installs Homebrew on Linux and macOS. Uses loops and retries to install Homebrew apps and casks.","archived":false,"fork":false,"pushed_at":"2023-09-05T02:05:31.000Z","size":280,"stargazers_count":13,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-13T00:05:17.174Z","etag":null,"topics":["ansible","ansible-role","automation","brew","homebrew","linux","linuxbrew","macos","mdm","provisioning"],"latest_commit_sha":null,"homepage":"https://wayof.dev","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wayofdev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"wayofdev"}},"created_at":"2022-05-20T03:32:39.000Z","updated_at":"2025-01-15T20:30:39.000Z","dependencies_parsed_at":"2024-10-24T13:08:54.341Z","dependency_job_id":"f72cd6ed-5545-469f-bab5-2792c8cb511f","html_url":"https://github.com/wayofdev/ansible-role-homebrew","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayofdev%2Fansible-role-homebrew","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayofdev%2Fansible-role-homebrew/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayofdev%2Fansible-role-homebrew/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayofdev%2Fansible-role-homebrew/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wayofdev","download_url":"https://codeload.github.com/wayofdev/ansible-role-homebrew/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253843213,"owners_count":21972873,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-role","automation","brew","homebrew","linux","linuxbrew","macos","mdm","provisioning"],"created_at":"2024-10-03T21:43:46.973Z","updated_at":"2025-05-13T00:05:27.777Z","avatar_url":"https://github.com/wayofdev.png","language":"Makefile","funding_links":["https://github.com/sponsors/wayofdev"],"categories":[],"sub_categories":[],"readme":"\u003cbr\u003e\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg width=\"456\" src=\"https://raw.githubusercontent.com/wayofdev/ansible-role-homebrew/master/assets/logo.gh-light-mode-only.png#gh-light-mode-only\"\u003e\n\u003cimg width=\"456\" src=\"https://raw.githubusercontent.com/wayofdev/ansible-role-homebrew/master/assets/logo.gh-dark-mode-only.png#gh-dark-mode-only\"\u003e\n\u003c/div\u003e\n\n\n\u003cbr\u003e\n\n\u003cbr\u003e\n\n\u003cdiv align=\"center\"\u003e\n\u003ca href=\"https://actions-badge.atrox.dev/wayofdev/ansible-role-homebrew/goto\"\u003e\u003cimg alt=\"Build Status\" src=\"https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fwayofdev%2Fansible-role-homebrew%2Fbadge\u0026style=flat-square\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://galaxy.ansible.com/wayofdev/homebrew\"\u003e\u003cimg alt=\"Ansible Role\" src=\"https://img.shields.io/ansible/role/59331?style=flat-square\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/wayofdev/ansible-role-homebrew/tags\"\u003e\u003cimg src=\"https://img.shields.io/github/v/tag/wayofdev/ansible-role-homebrew?sort=semver\u0026style=flat-square\" alt=\"Latest Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://galaxy.ansible.com/wayofdev/homebrew\"\u003e\u003cimg alt=\"Ansible Quality Score\" src=\"https://img.shields.io/ansible/quality/59331?style=flat-square\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://galaxy.ansible.com/wayofdev/homebrew\"\u003e\u003cimg alt=\"Ansible Role\" src=\"https://img.shields.io/ansible/role/d/59331?style=flat-square\"/\u003e\u003c/a\u003e\n\u003ca href=\"LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/wayofdev/ansible-role-homebrew.svg?style=flat-square\u0026color=blue\" alt=\"Software License\"/\u003e\u003c/a\u003e\n\u003ca href=\"#\"\u003e\u003cimg alt=\"Commits since latest release\" src=\"https://img.shields.io/github/commits-since/wayofdev/ansible-role-homebrew/latest?style=flat-square\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\n# Ansible Role: Homebrew\n\nInstalls [Homebrew](https://brew.sh/) on macOS or Linux, and configures taps, packages and casks. Package uses retry loops to deal with connectivity issues.\n\nIf you **like/use** this role, please consider **starring** it. Thanks!\n\n\u003cbr\u003e\n\n## 🗂 Table of Contents\n\n* [Requirements](#-requirements)\n* [Role Variables](#-role-variables)\n   * [Structure](#-structure)\n   * [Tapping repositories](#-tapping-repositories)\n   * [Packages: Installing, updating and removing](#-packages-installing-updating-and-removing)\n   * [Casks: installing, updating and removing](#-casks-installing-updating-and-removing)\n* [Example Playbook](#-example-playbook)\n   * [for macOS machines](#-for-macos-machines)\n   * [for Linux machines](#-for-linux-machines)\n* [Development](#-development)\n* [Testing](#-testing)\n* [Dependencies](#-dependencies)\n   * [for all](#-for-all)\n   * [only macOS](#-only-macos)\n   * [only Linux](#-only-linux)\n* [Compatibility](#-compatibility)\n* [License](#-license)\n* [Author Information](#-author-information)\n* [Credits and Resources](#-credits-and-resources)\n* [Sponsors](#-sponsors)\n\n\u003cbr\u003e\n\n## 📑 Requirements\n\n* Up-to-date version of ansible. During maintenance/development, we stick to ansible versions and will use new features if they are available (and update `meta/main.yml` for the minimum version).\n* Compatible OS. See [compatibility](#-compatibility) table.\n* `jmespath` library needs to be installed on the host running the playbook (needed for the `json_query` filter).\n* Role has dependencies on third-party roles on different operating systems. See `requirements.yml` and [dependencies](#-dependencies) section.\n\n\u003cbr\u003e\n\n## 🔧 Role Variables\n\nAvailable variables are listed below, along with example values (see `defaults/main.yml`). Additional variables are stored in `vars/main.yml`.\n\n\u003cbr\u003e\n\n### → Structure\n\nGitHub repository variable for Homebrew core. By default, role checks for latest release from official Homebrew repository, if you are changing `homebrew_repository` to your  fork and want to use `master` branch and turn off latest release autodetect, then set `homebrew_repository_use_master` variable to `true`\n\n```yaml\n# From which repository should we install homebrew?\nhomebrew_repository: https://github.com/Homebrew/brew\n\n# Set to true if you want to use master branch instead of release auto-detect,\n# or you use custom fork specified in homebrew_repository\nhomebrew_repository_use_master: false\n```\n\nWhen set to true, will update Homebrew itself and upgrade all homebrew packages:\n\n```yaml\n# Run task to upgrade all packages\nhomebrew_upgrade_all: true\n```\n\nVariable controls retry times and delay to wait between retries, if `homebrew install` task failed:\n\n```yaml\n# How much times to retry, if installation of package / tap / cask fails ?\n# This can happen during network problems.\nhomebrew_retries: 32\n\n# Delay between each retry attempt.\nhomebrew_delay: 3\n```\n\nSet to `true` to remove the Homebrew cache after any new software is installed or updated.\n\n```yaml\nhomebrew_clear_cache: false\n```\n\nDirectory where applications installed via `cask` should be installed.\n\n```yaml\nhomebrew_cask_appdir: /Applications\n```\n\nIf set to `true`, passes `--greedy` to brew cask outdated when checking if an installed cask has a newer version available.\n\n```yaml\nhomebrew_cask_greedy_mode: false\n```\n\nTurn off homebrew analytics, which are collected by default.\n\n```yaml\nhomebrew_collect_analytics: false\n```\n\n\u003cbr\u003e\n\n### → Tapping repositories\n\n**Adding** (tapping) repositories\n\n```yaml\nhomebrew_taps:\n  - homebrew/core\n  - homebrew/cask-versions\n  - homebrew/cask-fonts\n```\n\n**Adding** (tapping) repositories, in more verbose way, defining urls and states:\n\n```yaml\nhomebrew_taps:\n  # just tap\n  - name: homebrew/core\n\n  # tap from custom repository\n  - name: denji/nginx\n    url: https://github.com/denji/homebrew-nginx\n\n  # tap with defined custom state\n  - name: homebrew/cask-fonts\n    state: present\n```\n\n**Removing** taps:\n\n```yaml\nhomebrew_taps:\n  # define state: absent to delete taps\n  - name: homebrew/cask-fonts\n    state: absent\n\n  - name: denji/nginx\n    state: absent\n```\n\n\u003cbr\u003e\n\n### → Packages: Installing, updating and removing\n\n**Adding** packages in simple way:\n\n```yaml\nhomebrew_packages:\n  - wget\n  - curl\n  - nano\n```\n\n**Adding** packages in advanced way, defining state, path, and other options:\n\n```yaml\nhomebrew_packages:\n  # install to custom path\n  - name: wget\n    state: present\n    path: /opt/custom/path/bin\n```\n\n**Updating** packages:\n\n```yaml\nhomebrew_packages:\n  # update homebrew first and install formula wget with 'brew' in default path\n  - name: wget\n    state: present\n    update_homebrew: true\n\n  # update homebrew first and upgrade formula curl to the latest available with 'brew' in default path\n  - name: curl\n    state: latest\n    update_homebrew: true\n```\n\n**Removing** packages:\n\n```yaml\nhomebrew_packages:\n  - name: wget\n    state: absent\n  - name: curl\n    state: absent\n```\n\n\u003cbr\u003e\n\n### → Casks: installing, updating and removing\n\n\u003e :warning: **Notice**: Casks are supported only on macOS. See [this post](https://github.com/Linuxbrew/brew/issues/742).\n\n**Adding** casks in simple way:\n\n```yaml\nhomebrew_casks:\n  # Installing list of casks\n  - firefox\n  - google-chrome\n  - alfred\n  - 1password\n```\n\n**Adding** casks with advanced options:\n\n```yaml\nhomebrew_casks:\n  # Installing firefox cask\n  - name: firefox\n    state: present\n```\n\n**Removing** casks:\n\n```yaml\nhomebrew_casks:\n  # define state: absent to delete\n  - name: firefox\n    state: absent\n  - name: google-chrome\n    state: absent\n```\n\n\u003cbr\u003e\n\n## 📗 Example Playbook\n\n### → for macOS machines\n\n```yaml\n---\n- hosts: all\n  connection: local\n\n  # is needed when running over SSH\n  environment:\n    - PATH: \"{{ homebrew_search_paths | join(':') }}:{{ ansible_env.PATH }}\"\n\n  vars:\n    homebrew_taps:\n      - homebrew/core\n      - homebrew/cask\n      - homebrew/cask-fonts\n      - yt-dlp/taps\n    homebrew_packages:\n      - ssh-copy-id  # from homebrew/core\n      - yt-dlp  # from yt-dlp/taps\n    homebrew_casks:\n      - firefox\n      - google-chrome\n      - font-fira-code-nerd-font  # from homebrew/cask-fonts\n    homebrew_retries: 12\n    homebrew_delay: 3\n    homebrew_clear_cache: false\n    homebrew_collect_analytics: false\n\n  roles:\n    - elliotweiser.osx-command-line-tools  # only on macOS machines\n    - wayofdev.homebrew\n```\n\n### → for Linux machines\n\n```yaml\n---\n- hosts: all\n  connection: local\n\n  # is needed when running over SSH\n  environment:\n    - PATH: \"{{ homebrew_search_paths | join(':') }}:{{ ansible_env.PATH }}\"\n\n  vars:\n    homebrew_user: linuxbrew  # FYI: can be skipped, as automatically detected, but linuxbrew user is recommended way for installing Homebrew with Linux\n    homebrew_group: linuxbrew  # same as homebrew_user\n\n    homebrew_taps:\n      - homebrew/core\n      - yt-dlp/taps\n    homebrew_packages:\n      - ssh-copy-id  # from homebrew/core\n      - yt-dlp  # from yt-dlp/taps\n    homebrew_retries: 12\n    homebrew_delay: 3\n    homebrew_clear_cache: false\n    homebrew_collect_analytics: false\n\n  roles:\n    - geerlingguy.git  # only on linux machines, and can be skipped if machine has git\n    - wayofdev.homebrew\n```\n\n\u003cbr\u003e\n\n## ⚙️ Development\n\nTo install dependencies and start development you can check contents of our `Makefile`\n\n**Install** [poetry](https://github.com/python-poetry/poetry) using [poetry-bin](https://github.com/gi0baro/poetry-bin) and all dev python dependencies:\n\n```bash\n$ make install\n```\n\n**Install** only python dependencies, assuming that you already have poetry:\n\n```bash\n$ make install-deps\n```\n\n**Install** all git hooks:\n\n```bash\n$ make hooks\n```\n\n**Lint** all role files:\n\n```bash\n$ make lint\n```\n\n\u003cbr\u003e\n\n## 🧪 Testing\n\nYou can check `Makefile` to get full list of commands for remote and local testing. For local testing you can use these comands to test whole role or separate tasks:\n\n### → on localhost\n\n\u003e :warning: **Notice**: By defaut all tests are running against your local machine!\n\n```bash\n# run all tags with scenario from ./tests/test.yml\n$ make test\n\n# or test-tag without any parameters\n$ make test-tag\n\n# run idempotency check\n$ make test-idempotent\n\n# run tasks that validate config file and does installation\n$ export TASK_TAGS=\"brew-install,brew-update\"\n$ make test-tag\n\n# run by predefined command that executes only one tag\n$ make test-install\n$ make test-analytics\n$ make test-update\n$ make test-taps\n$ make test-packages\n$ make test-casks\n\n# run molecule tests on localhost\n$ poetry run molecule test --scenario-name default-macos-on-localhost -- -vvv\n\n# or with make command\n$ make m-local\n\n# runs molecule with docker driver\n$ poetry run molecule test --scenario-name default -- -vvv\n\n# or with make file\n$ make m-linux\n```\n\n\u003cbr\u003e\n\n### → over SSH\n\n```bash\n# run molecule scenarios against remote machines over SSH\n# this will need VM setup and configuration\n$ poetry run molecule test --scenario-name default-macos-over-ssh -- -vvv\n\n$ make m-remote\n\n# tags also can be passed\n$ export TASK_TAGS=\"brew-install,brew-update\"\n$ make m-remote\n```\n\n\u003cbr\u003e\n\n## 📦 Dependencies\n\nInstallation handled by `Makefile` and requirements are defined in `requirements.yml`\n\n### → for all\n\n  - [ansible.community.general](https://docs.ansible.com/ansible/latest/collections/community/general/index.html)\n\n### → only macOS\n\n  - [elliotweiser.osx-command-line-tools](https://galaxy.ansible.com/elliotweiser/osx-command-line-tools/)\n\n### → only Linux\n\n  - [geerlingguy.git](https://galaxy.ansible.com/geerlingguy/git)\n\n\u003cbr\u003e\n\n## 🧩 Compatibility\n\nThis role has been tested on these systems:\n\n| system / container | tag      |\n| :----------------- | -------- |\n| macos              | monterey |\n| macos              | big-sur  |\n| ubuntu             | jammy    |\n| ubuntu             | focal    |\n| debian             | bullseye |\n| debian             | buster   |\n| fedora             | 36       |\n| fedora             | 35       |\n| centos             | 8        |\n| centos             | 7        |\n\n\u003cbr\u003e\n\n## 🤝 License\n\n[![Licence](https://img.shields.io/github/license/wayofdev/ansible-role-homebrew?style=for-the-badge\u0026color=blue)](./LICENSE)\n\n\u003cbr\u003e\n\n## 🙆🏼‍♂️ Author Information\n\nThis role was created in **2022** by [lotyp / wayofdev](https://github.com/wayofdev).\n\n\u003cbr\u003e\n\n## 🧱 Credits and Resources\n\n**Inspired by:**\n\n* [role-homebrew-retry](https://github.com/osx-provisioner/role-homebrew-retry) by [@niall-byrne](https://github.com/niall-byrne)\n* homebrew role created by [@geerlingguy](https://github.com/geerlingguy) as a part of [ansible-collection-mac](https://github.com/geerlingguy/ansible-collection-mac)\n* official Homebrew [installer script](https://github.com/Homebrew/install/blob/master/install.sh)\n\n\u003cbr\u003e\n\n## 🫡 Contributors\n\n\u003cimg align=\"left\" src=\"https://img.shields.io/github/contributors-anon/wayofdev/ansible-role-homebrew?style=for-the-badge\"/\u003e\n\n\u003ca href=\"https://github.com/wayofdev/ansible-role-homebrew/graphs/contributors\"\u003e\n  \u003cimg src=\"https://opencollective.com/wod/contributors.svg?width=890\u0026button=false\"\u003e\n\u003c/a\u003e\n\n\u003cbr\u003e\n\n## 🤑 Sponsors\n\nRole development and testing was done on [Parallels Desktop Pro Edition](https://www.parallels.com/products/desktop/pro/) and License was provided by [Parallels](https://www.parallels.com/eu/)\n\n\u003cdiv\u003e\n\u003ca href=\"https://www.parallels.com/products/desktop/pro/\"\u003e\n\u003cimg width=\"180\" src=\"assets/pr-full-color-on-white.jpeg#gh-light-mode-only\"\u003e\n\u003c/a\u003e\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwayofdev%2Fansible-role-homebrew","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwayofdev%2Fansible-role-homebrew","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwayofdev%2Fansible-role-homebrew/lists"}