Skip to content

Commit

Permalink
further tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
gdams committed Nov 17, 2023
1 parent fefb710 commit 593f7a5
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 170 deletions.
46 changes: 0 additions & 46 deletions .github/workflows/build_packer.yml

This file was deleted.

47 changes: 47 additions & 0 deletions ansible/packer/README.md
@@ -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
```
14 changes: 12 additions & 2 deletions ansible/packer/orka-base.pkr.hcl
Expand Up @@ -19,10 +19,18 @@ variable "ORKA_ENDPOINT" {
default = "http://10.221.188.20"
}

variable "XCode11_7_SAS_TOKEN" {
default = env("XCode11_7_SAS_TOKEN")
}

variable "XCode12_4_SAS_TOKEN" {
default = env("XCode12_4_SAS_TOKEN")
}

source "macstadium-orka" "sonoma-arm64" {
source_image = "sonoma-90gb-orka3-arm"
image_name = "sonoma-arm64-base"
image_description = "Base image with sudoers setup and brew/ansible installed"
image_description = "Base image with sudoers setup and xcode/brew/ansible installed"
image_force_overwrite = true
orka_endpoint = var.ORKA_ENDPOINT
orka_auth_token = var.ORKA_TOKEN
Expand Down Expand Up @@ -78,7 +86,9 @@ EOF
playbook_dir = "../playbooks/AdoptOpenJDK_Unix_Playbook"
extra_arguments = [
"--extra-vars", "ansible_user=admin",
"--tags", "xcode11"
"--extra-vars", "XCode11_7_SAS_TOKEN=\"${var.XCode11_7_SAS_TOKEN}\"",
"--extra-vars", "XCode12_4_SAS_TOKEN=\"${var.XCode12_4_SAS_TOKEN}\"",
"--tags", "xcode11,xcode12"
]
command = "source /Users/admin/.zprofile; ansible-playbook"
}
Expand Down
7 changes: 4 additions & 3 deletions ansible/playbooks/AdoptOpenJDK_Unix_Playbook/main.yml
Expand Up @@ -72,11 +72,12 @@
tags: [build_tools]
- role: gcc_11 # JDK19+
tags: [build_tools]
- role: Xcode
when: ansible_distribution == "MacOSX"
- role: Xcode11
when: ansible_distribution == "MacOSX" and ansible_architecture == "arm64"
tags: [xcode11]
tags: [xcode11] # JDK 8

Check failure on line 77 in ansible/playbooks/AdoptOpenJDK_Unix_Playbook/main.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

yaml[trailing-spaces]

Trailing spaces

Check failure on line 77 in ansible/playbooks/AdoptOpenJDK_Unix_Playbook/main.yml

View workflow job for this annotation

GitHub Actions / Yamllint

77:30 [trailing-spaces] trailing spaces
- role: Xcode12
when: ansible_distribution == "MacOSX" and ansible_architecture == "arm64"
tags: [xcode12] # JDK 17+
- role: cmake # OpenJ9 / OpenJFX
when: ansible_distribution != "Solaris" # Compile fails on Solaris
tags: [build_tools, build_tools_openj9, build_tools_openjfx]
Expand Down
Expand Up @@ -10,6 +10,7 @@ Build_Tool_Packages:
- automake # for compiling freetype on JDK8u
- cmake # OpenJ9
- coreutils
- git
- gnupg
- gnu-sed
- gnu-tar
Expand Down

This file was deleted.

Expand Up @@ -11,20 +11,21 @@
- name: Check if SAS variable is defined
set_fact:
apple_variables: yes
when: not xcode11_installed.stat.exists and XCode11.7_SAS_TOKEN is defined
when: not xcode11_installed.stat.exists and XCode11_7_SAS_TOKEN is defined

- name: Display Information when XCode11.7_SAS_TOKEN is not defined
- name: Display Information when XCode11_7_SAS_TOKEN is not defined
debug:
msg: "XCode11.7_SAS_TOKEN is not defined. Xcode will need to be installed manually.
msg: "XCode11_7_SAS_TOKEN is not defined. Xcode will need to be installed manually.
Skipping Xcode installation"
when: not xcode11_installed.stat.exists and apple_variables is not defined

- name: Install Xcode11.7
when: not xcode11_installed.stat.exists and apple_variables is defined
block:
# Stored in Azure Blob Storage (SAS URL set to expire in 2033)
- name: Download XCode 11.7 from Azure blob storage
get_url:
url: "https://ansiblestorageadopt.blob.core.windows.net/xcode11-7/Xcode_11.7.xip?{{ XCode11.7_SAS_TOKEN }}"
url: "https://ansiblestorageadopt.blob.core.windows.net/xcode11-7/Xcode_11.7.xip?{{ XCode11_7_SAS_TOKEN }}"
dest: /tmp/Xcode_11.7.xip
mode: 0755

Expand All @@ -40,6 +41,17 @@
dest: /Applications/Xcode-11.7.app/
remote_src: true

- name: Install Rosetta 2
command: /usr/sbin/softwareupdate --install-rosetta --agree-to-license
tags:
- rosetta

Check failure on line 48 in ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode11/tasks/main.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

yaml[trailing-spaces]

Trailing spaces

Check failure on line 48 in ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode11/tasks/main.yml

View workflow job for this annotation

GitHub Actions / Yamllint

48:1 [trailing-spaces] trailing spaces
- name: Select Xcode11.7 as the default Xcode
shell: sudo xcode-select --switch /Applications/Xcode-11.7.app

- name: Accept Xcode license
shell: arch -x86_64 sudo xcodebuild -license accept

- name: Clean up Xcode11.7.xip file
file:
path: /tmp/Xcode_11.7.xip
Expand Down
@@ -0,0 +1,53 @@
---
# 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:
# Stored in Azure Blob Storage (SAS URL set to expire in 2033)
- name: Download XCode 12.4 from Azure blob storage
get_url:
url: "https://ansiblestorageadopt.blob.core.windows.net/xcode12-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

Check failure on line 43 in ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode12/tasks/main.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

yaml[trailing-spaces]

Trailing spaces

Check failure on line 43 in ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Xcode12/tasks/main.yml

View workflow job for this annotation

GitHub Actions / Yamllint

43:1 [trailing-spaces] trailing spaces
- name: Select Xcode12.4 as the default Xcode
shell: sudo xcode-select --switch /Applications/Xcode.app

- name: Accept Xcode license
shell: sudo xcodebuild -license accept

- name: Clean up Xcode12.4.xip file
file:
path: /tmp/Xcode_12.4.xip
state: absent

0 comments on commit 593f7a5

Please sign in to comment.