forked from adoptium/infrastructure
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add packer files for building Orka images (adoptium#3253)
* add packer files for building Orka images * add intel * further tweaks * switch to xcode 15 * Update README.md * always update ansible
- Loading branch information
Showing
11 changed files
with
308 additions
and
123 deletions.
There are no files selected for viewing
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`, `XCode15_0_1_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 XCode15_0_1_SAS_TOKEN="your-xcode15.0.1-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. The base step has a pause which allows users to manually make any required changes and then resume the build. | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
packer { | ||
required_plugins { | ||
macstadium-orka = { | ||
source = "github.com/macstadium/macstadium-orka" | ||
version = "~>3" | ||
} | ||
ansible = { | ||
source = "github.com/hashicorp/ansible" | ||
version = "~> 1" | ||
} | ||
} | ||
} | ||
|
||
variable "ORKA_TOKEN" { | ||
default = env("ORKA_TOKEN") | ||
} | ||
|
||
variable "ORKA_ENDPOINT" { | ||
default = "http://10.221.188.20" | ||
} | ||
|
||
variable "XCode11_7_SAS_TOKEN" { | ||
default = env("XCode11_7_SAS_TOKEN") | ||
} | ||
|
||
variable "XCode15_0_1_SAS_TOKEN" { | ||
default = env("XCode15_0_1_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 xcode/brew/ansible installed" | ||
image_force_overwrite = true | ||
orka_endpoint = var.ORKA_ENDPOINT | ||
orka_auth_token = var.ORKA_TOKEN | ||
orka_vm_builder_name = "sonoma-arm64-builder" | ||
} | ||
|
||
source "macstadium-orka" "sonoma-intel" { | ||
source_image = "90gbsonomassh.img" | ||
image_name = "sonoma-intel-base" | ||
image_description = "Base image with sudoers setup and brew/ansible installed" | ||
image_force_overwrite = true | ||
orka_endpoint = var.ORKA_ENDPOINT | ||
orka_auth_token = var.ORKA_TOKEN | ||
orka_vm_builder_name = "sonoma-intel-builder" | ||
} | ||
|
||
# Generate the base image for the sonoma-arm64 VMs which we will use to run the ansible playbook | ||
build { | ||
sources = [ | ||
"macstadium-orka.sonoma-arm64", | ||
"macstadium-orka.sonoma-intel" | ||
] | ||
|
||
# set sudoers to allow passwordless sudo | ||
provisioner "shell" { | ||
inline = [ | ||
"echo admin | sudo -S sh -c 'echo \"%admin ALL=(ALL) NOPASSWD:ALL\" >> /etc/sudoers'", | ||
] | ||
} | ||
|
||
# Pause the provisioner until user interacts (for install Xcode etc) | ||
provisioner "breakpoint" {} | ||
|
||
# Install homebrew and ansible | ||
provisioner "shell" { | ||
inline = [<<EOF | ||
/bin/bash -c '\ | ||
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh | bash; \ | ||
ARCH=$(uname -m); \ | ||
if [ "$ARCH" = "x86_64" ]; then \ | ||
BREW_PATH=/usr/local/bin; \ | ||
else \ | ||
BREW_PATH=/opt/homebrew/bin; \ | ||
fi; \ | ||
echo eval "$($BREW_PATH/brew shellenv)" >> /Users/admin/.zprofile; \ | ||
eval "$($BREW_PATH/brew shellenv)"; \ | ||
echo export PATH="$BREW_PATH:$PATH" >> /Users/admin/.zprofile; \ | ||
brew install ansible;' | ||
EOF | ||
] | ||
} | ||
|
||
# Install Xcode | ||
provisioner "ansible-local" { | ||
playbook_file = "../playbooks/AdoptOpenJDK_Unix_Playbook/main.yml" | ||
playbook_dir = "../playbooks/AdoptOpenJDK_Unix_Playbook" | ||
extra_arguments = [ | ||
"--extra-vars", "ansible_user=admin", | ||
"--extra-vars", "XCode11_7_SAS_TOKEN=\"${var.XCode11_7_SAS_TOKEN}\"", | ||
"--extra-vars", "XCode15_0_1_SAS_TOKEN=\"${var.XCode15_0_1_SAS_TOKEN}\"", | ||
"--tags", "xcode11,xcode15" | ||
] | ||
command = "source /Users/admin/.zprofile; ansible-playbook" | ||
} | ||
} |
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,78 @@ | ||
packer { | ||
required_plugins { | ||
macstadium-orka = { | ||
source = "github.com/macstadium/macstadium-orka" | ||
version = "~>3" | ||
} | ||
ansible = { | ||
source = "github.com/hashicorp/ansible" | ||
version = "~> 1" | ||
} | ||
} | ||
} | ||
|
||
variable "ORKA_TOKEN" { | ||
default = env("ORKA_TOKEN") | ||
} | ||
|
||
variable "ORKA_ENDPOINT" { | ||
default = "http://10.221.188.20" | ||
} | ||
|
||
source "macstadium-orka" "sonoma-arm64" { | ||
source_image = "sonoma-arm64-base" | ||
image_name = "adoptium-sonoma-arm64" | ||
image_description = "Adoptium Sonoma ARM64 image with full ansible playbook run" | ||
image_force_overwrite = true | ||
orka_endpoint = var.ORKA_ENDPOINT | ||
orka_auth_token = var.ORKA_TOKEN | ||
orka_vm_builder_name = "sonoma-arm64-builder" | ||
} | ||
|
||
source "macstadium-orka" "sonoma-intel" { | ||
source_image = "sonoma-intel-base" | ||
image_name = "adoptium-sonoma-intel" | ||
image_description = "Base image with sudoers setup and brew/ansible installed" | ||
image_force_overwrite = true | ||
orka_endpoint = var.ORKA_ENDPOINT | ||
orka_auth_token = var.ORKA_TOKEN | ||
orka_vm_builder_name = "sonoma-intel-builder" | ||
} | ||
|
||
build { | ||
sources = [ | ||
"macstadium-orka.sonoma-arm64", | ||
"macstadium-orka.sonoma-intel" | ||
] | ||
|
||
# Ensure ansible package is up to date | ||
provisioner "shell" { | ||
inline = [ | ||
"source /Users/admin/.zprofile; brew upgrade ansible", | ||
] | ||
} | ||
|
||
# Create /tmp/packer-provisioner-ansible-local | ||
provisioner "shell" { | ||
inline = [ | ||
"mkdir -p /tmp/packer-provisioner-ansible-local", | ||
] | ||
} | ||
|
||
# Copy playbooks/Supporting_Scripts to /tmp/packer-provisioner-ansible-local | ||
provisioner "file" { | ||
source = "../playbooks/Supporting_Scripts" | ||
destination = "/tmp/packer-provisioner-ansible-local" | ||
} | ||
|
||
# Run ansible playbook | ||
provisioner "ansible-local" { | ||
playbook_file = "../playbooks/AdoptOpenJDK_Unix_Playbook/main.yml" | ||
playbook_dir = "../playbooks/AdoptOpenJDK_Unix_Playbook" | ||
extra_arguments = [ | ||
"--extra-vars", "ansible_user=admin", | ||
"--skip-tags=hostname,brew_upgrade,brew_cu,core_dumps,crontab,kernel_tuning,adoptopenjdk,jenkins,nagios,superuser,swap_file,jck_tools" | ||
] | ||
command = "source /Users/admin/.zprofile; ansible-playbook" | ||
} | ||
} |
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.
Oops, something went wrong.