From ef55e4b4ad759774b689d70450d896871cfa902a Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 23 Jan 2024 10:41:55 +0100 Subject: [PATCH 1/2] Stick to defaults - update homebrew_install_path As the README says - it is recommended to stick to the default. The default install path is /opt/homebrew on macs with Apple-chipsets [1]. 1: --- roles/homebrew/README.md | 6 +++--- roles/homebrew/defaults/main.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/roles/homebrew/README.md b/roles/homebrew/README.md index 64284d2..6c023ea 100644 --- a/roles/homebrew/README.md +++ b/roles/homebrew/README.md @@ -15,11 +15,11 @@ Available variables are listed below, along with default values (see [`defaults/ The GitHub repository for Homebrew core. homebrew_prefix: "{{ (ansible_machine == 'arm64') | ternary('/opt/homebrew', '/usr/local') }}" - homebrew_install_path: "{{ homebrew_prefix }}/Homebrew" + homebrew_install_path: "{{ homebrew_prefix }}{{ '/Homebrew' if ansible_machine != 'arm64' }}" -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. +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 `/opt/homebrew` (or `/usr/local` if you're on an Intel-mac) so things work as Homebrew expects. - homebrew_brew_bin_path: /usr/local/bin + homebrew_brew_bin_path: {{ homebrew_prefix }}/bin The path where `brew` will be installed. diff --git a/roles/homebrew/defaults/main.yml b/roles/homebrew/defaults/main.yml index 299c5e4..5b7d7cc 100644 --- a/roles/homebrew/defaults/main.yml +++ b/roles/homebrew/defaults/main.yml @@ -2,7 +2,7 @@ homebrew_repo: https://github.com/Homebrew/brew homebrew_prefix: "{{ (ansible_machine == 'arm64') | ternary('/opt/homebrew', '/usr/local') }}" -homebrew_install_path: "{{ homebrew_prefix }}/Homebrew" +homebrew_install_path: "{{ homebrew_prefix }}{{ '/Homebrew' if ansible_machine != 'arm64' }}" homebrew_brew_bin_path: "{{ homebrew_prefix }}/bin" homebrew_installed_packages: [] From daa998a0eeb67d9c06325a6e649cda810f08f4c4 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 23 Jan 2024 13:42:40 +0100 Subject: [PATCH 2/2] Homebrew-folder is not default on macs with arm64 No reason to create the folder when it isn't needed. Not sure if this is the best solution here, but it's simple. --- roles/homebrew/tasks/main.yml | 5 +++++ roles/homebrew/vars/main.yml | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/roles/homebrew/tasks/main.yml b/roles/homebrew/tasks/main.yml index 6b660b9..defe736 100644 --- a/roles/homebrew/tasks/main.yml +++ b/roles/homebrew/tasks/main.yml @@ -88,6 +88,11 @@ when: not homebrew_binary.stat.exists become: true +- name: Add missing folder if not on Apple-chipset + set_fact: + homebrew_folders_base: "{{ homebrew_folders_base + ['Homebrew'] }}" + when: ansible_machine != 'arm64' + - name: Ensure proper homebrew folders are in place. file: path: "{{ homebrew_prefix }}/{{ item }}" diff --git a/roles/homebrew/vars/main.yml b/roles/homebrew/vars/main.yml index 109fe6d..94ae40f 100644 --- a/roles/homebrew/vars/main.yml +++ b/roles/homebrew/vars/main.yml @@ -1,7 +1,6 @@ --- homebrew_folders_base: - Cellar - - Homebrew - Frameworks - Caskroom - bin