From bc2a40a1ffe585eeac19433df22028fdf010c356 Mon Sep 17 00:00:00 2001 From: Haroon Khel <34969545+Haroon-Khel@users.noreply.github.com> Date: Mon, 6 Nov 2023 23:54:50 +0800 Subject: [PATCH] unixPb: Add role to install intel homebrew for arm64 macs (#3185) * add intel homebrew install for m1 macs * remove spaces * add brew path to brew ansible modules * change formatting of module parameters * typo * remove debug tasks * add comment * specify homebrew path * correct conditions * remove intel homebrew, uninstall libpng * add adoptopenjdk tag to libpng uninstall --- .../roles/Common/tasks/MacOSX.yml | 45 +++++++++++++++---- .../Nagios_Plugins/tasks/nagios_MacOSX.yml | 16 ++++++- .../roles/Xcode/tasks/main.yml | 11 +++++ .../roles/curl/tasks/main.yml | 11 +++++ 4 files changed, 73 insertions(+), 10 deletions(-) diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/tasks/MacOSX.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/tasks/MacOSX.yml index 5ee080d541..033adc23a1 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/tasks/MacOSX.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/tasks/MacOSX.yml @@ -25,12 +25,12 @@ - name: Set homebrew path (x64) set_fact: - homebrew_path: /usr/local/bin/brew + homebrew_path: /usr/local/bin when: ansible_architecture == "x86_64" - name: Set homebrew path (Arm64) set_fact: - homebrew_path: /opt/homebrew/bin/brew + homebrew_path: /opt/homebrew/bin when: ansible_architecture == "arm64" - name: Configure system-wide Bash profile @@ -67,7 +67,7 @@ - name: Check if Homebrew is already installed stat: - path: "{{ homebrew_path }}" + path: "{{ homebrew_path }}/brew" register: brew - name: Install Homebrew @@ -81,6 +81,7 @@ become_user: "{{ ansible_user }}" homebrew: upgrade_all: yes + path: "{{ homebrew_path }}" when: "macos_version_number is version('10.15', '>')" tags: - brew_upgrade @@ -90,6 +91,7 @@ become_user: "{{ ansible_user }}" homebrew_tap: name: buo/cask-upgrade + path: "{{ homebrew_path }}" tags: - brew_cu @@ -98,12 +100,13 @@ become_user: "{{ ansible_user }}" homebrew_tap: name: AdoptOpenJDK/openjdk + path: "{{ homebrew_path }}" # Skipping linting as no situation where this can't run (lint error 301) - name: Update Casks become: yes become_user: "{{ ansible_user }}" - command: "{{ homebrew_path }} cu -y" + command: "{{ homebrew_path }}/brew cu -y" tags: - brew_cu - skip_ansible_lint @@ -111,14 +114,20 @@ - name: Install Build Tool Packages become: yes become_user: "{{ ansible_user }}" - homebrew: "name={{ item }} state=present" + homebrew: + name: "{{ item }}" + state: present + path: "{{ homebrew_path }}" with_items: "{{ Build_Tool_Packages }}" tags: build_tools - name: Install Build Tool Packages NOT macOS 10.12 become: yes become_user: "{{ ansible_user }}" - homebrew: "name={{ item }} state=present" + homebrew: + name: "{{ item }}" + state: present + path: "{{ homebrew_path }}" with_items: "{{ Build_Tool_Packages_NOT_10_12 }}" when: - not (macos_version_number | regex_search("10.12")) @@ -127,21 +136,30 @@ - name: Install Build Tool Casks become: yes become_user: "{{ ansible_user }}" - homebrew_cask: "name={{ item }} state=present" + homebrew_cask: + name: "{{ item }}" + state: present + path: "{{ homebrew_path }}" with_items: "{{ Build_Tool_Casks }}" tags: build_tools - name: Install Test Tool Packages become: yes become_user: "{{ ansible_user }}" - homebrew: "name={{ item }} state=present" + homebrew: + name: "{{ item }}" + state: present + path: "{{ homebrew_path }}" with_items: "{{ Test_Tool_Packages }}" tags: test_tools - name: Install JCK Tool Casks become: yes become_user: "{{ ansible_user }}" - homebrew_cask: "name={{ item }} state=present" + homebrew_cask: + name: "{{ item }}" + state: present + path: "{{ homebrew_path }}" with_items: "{{ JCK_Tool_Casks }}" tags: jck_tools @@ -162,6 +180,15 @@ when: not pdfwriter.stat.exists tags: jck_tools +- name: Uninstall libpng + become: yes + become_user: "{{ ansible_user }}" + homebrew: + name: libpng + state: absent + path: "{{ homebrew_path }}" + tags: adoptopenjdk + # As per https://github.com/eclipse/openj9/issues/3790 - name: Creating /etc/sysctl.conf for kernel tunings file: diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Nagios_Plugins/tasks/nagios_MacOSX.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Nagios_Plugins/tasks/nagios_MacOSX.yml index 18da3d34b1..b6553498be 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Nagios_Plugins/tasks/nagios_MacOSX.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Nagios_Plugins/tasks/nagios_MacOSX.yml @@ -6,8 +6,22 @@ ######################################## # Install Nagios dependencies packages # ######################################## + +- name: Set Mac homebrew path (x64) + set_fact: + homebrew_path: /usr/local/bin + when: ansible_architecture == "x86_64" + +- name: Set Mac homebrew path (Arm64) + set_fact: + homebrew_path: /opt/homebrew/bin + when: ansible_architecture == "arm64" + - name: Install additional packages used by Nagios - homebrew: "name={{ item }} state=present" + homebrew: + name: "{{ item }}" + state: present + path: "{{ homebrew_path }}" become: yes become_user: "{{ ansible_user }}" with_items: diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode/tasks/main.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode/tasks/main.yml index 6bae45d566..5f390c0983 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode/tasks/main.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode/tasks/main.yml @@ -20,6 +20,16 @@ Ensure that Apple_ID_User, Apple_ID_Password and FASTLANE_SESSION are defined. Skipping Xcode installation" when: apple_variables is not defined +- name: Set Mac homebrew path (x64) + set_fact: + homebrew_path: /usr/local/bin + when: ansible_architecture == "x86_64" + +- name: Set Mac homebrew path (Arm64) + set_fact: + homebrew_path: /opt/homebrew/bin + when: ansible_architecture == "arm64" + - name: Install Xcode when: apple_variables is defined block: @@ -29,6 +39,7 @@ homebrew: name: ruby@2.7 # no 3.0 yet for fastlane (https://github.com/fastlane/fastlane/issues/17931) state: present + path: "{{ homebrew_path }}" - name: Configure Bash profile extension for Ruby become: yes diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/curl/tasks/main.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/curl/tasks/main.yml index 5691b9450d..0f82f6e611 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/curl/tasks/main.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/curl/tasks/main.yml @@ -27,6 +27,16 @@ curl_latest: 7.79.1 tags: curl +- name: Set Mac homebrew path (x64) + set_fact: + homebrew_path: /usr/local/bin + when: ansible_distribution == "MacOSX" and ansible_architecture == "x86_64" + +- name: Set Mac homebrew path (Arm64) + set_fact: + homebrew_path: /opt/homebrew/bin + when: ansible_distribution == "MacOSX" and ansible_architecture == "arm64" + - name: Download curl {{ curl_latest }} get_url: url: https://github.com/curl/curl/releases/download/curl-7_79_1/curl-{{ curl_latest }}.tar.gz @@ -114,6 +124,7 @@ homebrew: name: curl state: latest + path: "{{ homebrew_path }}" when: - ansible_distribution == "MacOSX" - "macos_version_number is version('10.13', '>')"