-
-
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.
Merge branch 'master' into Common-tags
- Loading branch information
Showing
32 changed files
with
527 additions
and
168 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
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 |
---|---|---|
|
@@ -22,9 +22,12 @@ jobs: | |
- os: [macos-14] | ||
steps: | ||
|
||
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
|
||
- name: Install dependencies | ||
- name: Install Python | ||
run: brew install [email protected] --overwrite | ||
|
||
- name: Install Ansible | ||
run: brew install ansible | ||
|
||
# This is to fix an issue with the github macos14 runner, that cant resolve keyserver.ubuntu.com | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Packer | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- .github/workflows/packer.yml | ||
- ansible/playbooks/AdoptOpenJDK_Unix_Playbook/** | ||
- ansible/packer/** | ||
branches: | ||
- master | ||
|
||
jobs: | ||
packer: | ||
name: Update macOS Orka Image | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
os: [sonoma-arm64, sonoma-intel] | ||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
|
||
# This is to fix an issue with the github macos14 runner, that cant resolve keyserver.ubuntu.com | ||
# but this does work when replaced with the IP address. Spotted during the GPG verification of ANT step | ||
# Upstream Bug : https://github.com/actions/runner-images/issues/9777 | ||
- name: Replace keyserver address with IP address | ||
run: | | ||
sed -i 's/keyserver\.ubuntu\.com/185.125.188.27/g' ansible/playbooks/Supporting_Scripts/package_signature_verification.sh | ||
- name: Install openconnect | ||
run: sudo apt-get install -y openconnect | ||
|
||
- name: Connect to Orka VPN | ||
run: | | ||
echo ${{ secrets.ORKA_VPN_PASSWORD }} | sudo openconnect 207.254.69.34 \ | ||
--protocol=anyconnect --user=${{ secrets.ORKA_VPN_USERNAME }} \ | ||
--passwd-on-stdin --background \ | ||
--servercert ${{ secrets.ORKA_VPN_SERVER_CERT }} | ||
- name: Init Packer | ||
run: packer init orka.pkr.hcl | ||
working-directory: ansible/packer | ||
|
||
- name: Run Packer | ||
run: packer build --only=macstadium-orka.${{ matrix.os }} orka.pkr.hcl | ||
working-directory: ansible/packer | ||
env: | ||
ORKA_TOKEN: ${{ secrets.ORKA_TOKEN }} |
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
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" | ||
} | ||
} |
Oops, something went wrong.