-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
145 additions
and
170 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Packer Configuration for Virtual Machine Images | ||
|
||
This repository contains two Packer configuration files used for building virtual machine images for MacStadium Orka environments. These configurations are specifically tailored to set up environments with necessary tools like Homebrew, Ansible, and Xcode. | ||
|
||
## Configuration Files | ||
|
||
1. Base Image Creation (`orka-base.pkr.hcl`): This file is used to create a base image for sonoma-arm64 VMs. It installs Homebrew, Ansible, and specific versions of Xcode. | ||
|
||
1. Adoptium Image Creation (`orka.pkr.hcl`): This configuration builds upon the base image to create an Adoptium Sonoma ARM64 and Intel image, with a full Ansible playbook run excluding certain tags. | ||
|
||
## Prerequisites | ||
|
||
- [Packer](https://www.packer.io/downloads) installed on your system. | ||
- Access to a MacStadium Orka environment (via VPN). | ||
- Required environment variables set (`ORKA_TOKEN`, `XCode11_7_SAS_TOKEN`, `XCode12_4_SAS_TOKEN`). | ||
|
||
## Setup and Usage | ||
|
||
### Setting Environment Variables | ||
|
||
Set the necessary environment variables: | ||
|
||
```bash | ||
export ORKA_TOKEN="your-orka-token" | ||
export XCode11_7_SAS_TOKEN="your-xcode11.7-token" | ||
export XCode12_4_SAS_TOKEN="your-xcode12.4-token" | ||
``` | ||
|
||
### Running the Packer Builds | ||
|
||
1. Building the Base image | ||
|
||
```bash | ||
packer init . | ||
packer build orka-base.pkr.hcl | ||
``` | ||
|
||
This will create the base image for sonoma-arm64 and somoma-intel VMs. | ||
|
||
1. Building the Adoptium image | ||
|
||
The Adoptium image depends on the base image. This generates the images that we use in Jenkins and contains the full set of dependencies. | ||
|
||
```bash | ||
packer init . | ||
packer build orka.pkr.hcl | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 0 additions & 115 deletions
115
ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode/tasks/main.yml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode12/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
# Xcode 12.4 is needed to build JDK 17+ | ||
# Xcode12.4 can be downloaded from https://developer.apple.com/download/all after authentication with apple ID and password | ||
# See https://github.com/adoptium/infrastructure/issues/2536#issuecomment-1708716478 | ||
|
||
- name: Check if Xcode12.4 is installed | ||
stat: | ||
path: /Applications/Xcode-12.4.app/ | ||
register: xcode12_installed | ||
|
||
- name: Check if SAS variable is defined | ||
set_fact: | ||
apple_variables: yes | ||
when: not xcode12_installed.stat.exists and XCode12_4_SAS_TOKEN is defined | ||
|
||
- name: Display Information when XCode12_4_SAS_TOKEN is not defined | ||
debug: | ||
msg: "XCode12_4_SAS_TOKEN is not defined. Xcode will need to be installed manually. | ||
Skipping Xcode installation" | ||
when: not xcode12_installed.stat.exists and apple_variables is not defined | ||
|
||
- name: Install Xcode12.4 | ||
when: not xcode12_installed.stat.exists and apple_variables is defined | ||
block: | ||
- name: Check for /tmp/Xcode_12.4.xip | ||
stat: | ||
path: /tmp/Xcode_12.4.xip | ||
register: xcode12_4_xip | ||
|
||
# Stored in Azure Blob Storage (SAS URL set to expire in 2033) | ||
- name: Download XCode 12.4 from Azure blob storage | ||
when: not xcode12_4_xip.stat.exists | ||
get_url: | ||
url: "https://ansiblestorageadopt.blob.core.windows.net/xcode-12-4/Xcode_12.4.xip?{{ XCode12_4_SAS_TOKEN }}" | ||
dest: /tmp/Xcode_12.4.xip | ||
mode: 0755 | ||
|
||
- name: Extract Xcode12.4 | ||
shell: xip -x /tmp/Xcode_12.4.xip | ||
args: | ||
chdir: /tmp | ||
creates: /tmp/Xcode.app | ||
|
||
- name: Move Xcode12.4 to /Applications directory | ||
copy: | ||
src: /tmp/Xcode.app | ||
dest: /Applications/Xcode.app/ | ||
remote_src: true | ||
|
||
- name: Select Xcode12.4 as the default Xcode | ||
shell: sudo xcode-select --switch /Applications/Xcode.app | ||
|
||
- name: Accept Xcode license | ||
shell: arch -x86_64 sudo xcodebuild -license accept | ||
|
||
- name: Clean up Xcode12.4.xip file | ||
file: | ||
path: /tmp/Xcode_12.4.xip | ||
state: absent |