diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode_offline/files/.place_holder b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode_offline/files/.place_holder new file mode 100644 index 0000000000..e7993a7319 --- /dev/null +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode_offline/files/.place_holder @@ -0,0 +1,4 @@ +download and copy (soft link) xcode offline files heare: +Xcode_12.4.xip +Xcode_13.1.xip +etc. diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode_offline/tasks/main.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode_offline/tasks/main.yml new file mode 100644 index 0000000000..043c6d8398 --- /dev/null +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode_offline/tasks/main.yml @@ -0,0 +1,13 @@ +--- +######################### +# Xcdde offline install # +######################### + +# Install Xcode withou need to login with appleID +# Path /Applications/Xcode.app/ +# Requires the following variable: +# xcode_version: 12.4 | 13.1 | 13.2.1 | 13.4 | 14.3.1 | 15.0.1 + +- name: Xcode offline + include_tasks: xcode_offline.yml + tags: xcode_offline diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode_offline/tasks/xcode_offline.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode_offline/tasks/xcode_offline.yml new file mode 100644 index 0000000000..57f1f7a205 --- /dev/null +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode_offline/tasks/xcode_offline.yml @@ -0,0 +1,48 @@ +--- +- name: Check xcode version + shell: xcodebuild -version + register: xcodebuild_version + failed_when: false + tags: xcode_offline + +- name: Install and configure xcode if not installed + when: "'Xcode ' + xcode_version not in xcodebuild_version.stdout" + tags: xcode_offline + block: + + - name: Display xcode version + debug: + var: xcodebuild_version + + - name: Copy xcode file to remote host + copy: + src: Xcode_{{ xcode_version }}.xip + dest: '~' + force: false + + - name: Install xcode {{ xcode_version }} + shell: | + xip -x ~/Xcode_{{ xcode_version }}.xip + args: + chdir: /Applications + become: true + become_user: "{{ ansible_user }}" + + - name: Configure xcode {{ xcode_version }} + become: true + shell: | + xcode-select -s /Applications/Xcode.app/Contents/Developer + xcodebuild -license accept + + - name: Clean up after install Xcode + shell: | + rm ~/Xcode_{{ xcode_version }}.xip + + - name: Check xcode version + shell: xcodebuild -version + register: output + ignore_errors: true + + - name: Check if xcode version is correct + debug: + var: output diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/brew/tasks/brew.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/brew/tasks/brew.yml new file mode 100644 index 0000000000..f2ecaaf3d0 --- /dev/null +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/brew/tasks/brew.yml @@ -0,0 +1,85 @@ +--- + +- name: Check if Homebrew is already installed + stat: + path: /usr/local/bin/brew + register: b + when: ansible_architecture == "x86_64" + tags: brew + +- name: Check if Homebrew is already installed + stat: + path: /opt/homebrew/bin/brew + register: b + when: ansible_architecture == "arm64" + tags: brew + +- name: Set brew_is_installed + set_fact: brew_is_installed="{{ b.stat.exists }}" + when: b.stat.exists is defined + tags: brew + +- name: Install home brew + when: not brew_is_installed + tags: brew + block: + - name: Add user j9admin to sudoers + template: + src: sudoers + dest: /etc/sudoers.d/{{ ansible_user }} + become: true + + - name: Install home brew + shell: | + NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" + + - name: Check brew installation + shell: /usr/local/bin/brew --version + register: check_brew + ignore_errors: true + when: ansible_architecture == "x86_64" + + - name: Set brew_is_installed x86_64 + set_fact: brew_is_installed="{{ check_brew.rc == 0 }}" + when: check_brew.rc is defined + + - name: Check brew installation + shell: /opt/homebrew/bin/brew --version + register: check_brew + ignore_errors: true + when: ansible_architecture == "arm64" + + - name: Set brew_is_installed arm64 + set_fact: brew_is_installed="{{ check_brew.rc == 0 }}" + when: check_brew.rc is defined + + - name: Fail brew installation + fail: + msg: 'brew is not installed! exiting...' + when: not brew_is_installed + + - name: Configure brew x86_64 + blockinfile: + state: present + insertafter: EOF + dest: ~/.zprofile + marker: "" + content: | + eval $(/usr/local/bin/brew shellenv) + when: ansible_architecture == "x86_64" + + - name: Configure brew arm64 + blockinfile: + state: present + insertafter: EOF + dest: ~/.zprofile + marker: "" + content: | + eval $(/opt/homebrew/bin/brew shellenv) + when: ansible_architecture == "arm64" + + - name: Remove user j9admin from sudoers + file: + path: /etc/sudoers.d/{{ ansible_user }} + state: absent + become: true diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/brew/tasks/main.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/brew/tasks/main.yml new file mode 100644 index 0000000000..3246bc8830 --- /dev/null +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/brew/tasks/main.yml @@ -0,0 +1,9 @@ +--- +######## +# brew # +######## + +- name: Install homebrew + include_tasks: brew.yml + when: ansible_distribution == "MacOSX" + tags: brew diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/brew/templates/sudoers b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/brew/templates/sudoers new file mode 100644 index 0000000000..08c1ede634 --- /dev/null +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/brew/templates/sudoers @@ -0,0 +1 @@ +{{ ansible_user }} ALL=(ALL) NOPASSWD: ALL