From 06295afa7f0a81e535ea5ebe119e09587e948e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulises=20Gasc=C3=B3n?= Date: Sun, 25 Aug 2024 15:49:41 +0200 Subject: [PATCH 1/6] chore: ignore .env orka files in git --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index c6fd7d207..5aec6349e 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,6 @@ ansible/host_vars/* !ansible/host_vars/*-template .venv Pipfile.lock + +# Orka secrets files including naming mutations +orka/*/.env* \ No newline at end of file From 5dc30048d3197ece43bc8fdc077908f352ba69fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulises=20Gasc=C3=B3n?= Date: Sun, 25 Aug 2024 15:50:37 +0200 Subject: [PATCH 2/6] feat: add packer template for macos-11-arm-test --- orka/templates/macos-11-arm-test.pkr.hcl | 51 ++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 orka/templates/macos-11-arm-test.pkr.hcl diff --git a/orka/templates/macos-11-arm-test.pkr.hcl b/orka/templates/macos-11-arm-test.pkr.hcl new file mode 100644 index 000000000..a305ed342 --- /dev/null +++ b/orka/templates/macos-11-arm-test.pkr.hcl @@ -0,0 +1,51 @@ +variable "orka_endpoint" { + type = string + default = "" +} + +variable "orka_auth_token" { + type = string + default = "" +} + +variable "ssh_username" { + type = string + default = "" +} + +variable "ssh_password" { + type = string + default = "" +} + +packer { + required_plugins { + macstadium-orka = { + version = "~> 3.0" + source = "github.com/macstadium/macstadium-orka" + } + } +} + +source "macstadium-orka" "macos11-arm-test-image" { + source_image = "90gbigsurssh.img" + image_name = "macos11-arm-test-latest.img" + image_description = "The MacOS 11 ARM test image" + orka_endpoint = var.orka_endpoint + orka_auth_token = var.orka_auth_token + ssh_username = var.ssh_username + ssh_password = var.ssh_password +} + +build { + sources = [ + "macstadium-orka.macos11-arm-test-image" + ] + provisioner "shell" { + inline = [ + "echo we are running on the remote host", + "hostname", + "touch .we-ran-packer-successfully" + ] + } +} \ No newline at end of file From ab68ac25598c6bc376efc0d6af1c23f8254dfc74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulises=20Gasc=C3=B3n?= Date: Sun, 25 Aug 2024 15:53:52 +0200 Subject: [PATCH 3/6] ci: add pipeline for Orka packer templates --- .github/workflows/orka-templates.yml | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/orka-templates.yml diff --git a/.github/workflows/orka-templates.yml b/.github/workflows/orka-templates.yml new file mode 100644 index 000000000..54eaa2793 --- /dev/null +++ b/.github/workflows/orka-templates.yml @@ -0,0 +1,38 @@ +name: Check ORKA Packer Templates + +on: + push: + paths: + - 'orka/**/*.pkr.hcl' + pull_request: + paths: + - 'orka/**/*.pkr.hcl' + +permissions: + contents: read + +jobs: + validate: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7 + + - name: Set up Packer + uses: hashicorp/setup-packer@1aa358be5cf73883762b302a3a03abd66e75b232 #v3.1.0 + + - name: Initialize Packer + run: packer init . + + - name: Validate Packer templates + env: + ORKA_ENDPOINT: 'https://mock-orka-endpoint' + ORKA_AUTH_TOKEN: 'mock-orka-auth-token' + SSH_USERNAME: 'mock-ssh-username' + SSH_PASSWORD: 'mock-ssh-password' + run: | + packer validate -var "orka_endpoint=$ORKA_ENDPOINT" \ + -var "orka_auth_token=$ORKA_AUTH_TOKEN" \ + -var "ssh_username=$SSH_USERNAME" \ + -var "ssh_password=$SSH_PASSWORD" . \ No newline at end of file From 2a97f6a46472d7ceaac54fe67565873423599aaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulises=20Gasc=C3=B3n?= Date: Sun, 25 Aug 2024 15:54:10 +0200 Subject: [PATCH 4/6] docs: add documentation for Orka Packer --- orka/templates/README.md | 77 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 orka/templates/README.md diff --git a/orka/templates/README.md b/orka/templates/README.md new file mode 100644 index 000000000..91c204313 --- /dev/null +++ b/orka/templates/README.md @@ -0,0 +1,77 @@ +# Using Packer with Orka + +## Pre-requisites + +You need to install Packer in your local machine. You can find the installation instructions [here](https://learn.hashicorp.com/tutorials/packer/get-started-install-cli). + +Once installed, you can verify the installation by running the following command: + +```shell +packer --version +``` + +While writing this document, the latest version of Packer is `1.11.2`. + +## Install dependencies + +You need to run the following command to install the dependencies: + +```shell +packer init . +``` + +## Access the Orka environment + +You need to connect to the Orka VPN. You can find the instructions in the secrets repository. + +## Load the environment variables + +You need to load the environment variables: + +1. Get the `.env` file from the secrets repository. You will find the instructions in the repository. +2. Copy the `.env` file to this directory. +3. Run the following command: + ```shell + source .env + ``` +4. Verify that the environment variables are loaded by running the following command: + ```shell + echo $ORKA_ENDPOINT + echo $ORKA_AUTH_TOKEN + echo $SSH_USERNAME + echo $SSH_PASSWORD + ``` + +## Validate the template + +You can validate all the templates by running the following command: + +```shell +packer validate -var "orka_endpoint=$ORKA_ENDPOINT" -var "orka_auth_token=$ORKA_AUTH_TOKEN" -var "ssh_username=$SSH_USERNAME" -var "ssh_password=$SSH_PASSWORD" . +``` + +You can validate a specific template by running the following command: + +```shell +packer validate -var "orka_endpoint=$ORKA_ENDPOINT" -var "orka_auth_token=$ORKA_AUTH_TOKEN" -var "ssh_username=$SSH_USERNAME" -var "ssh_password=$SSH_PASSWORD" +``` + +## Build the image + +You can build all the templates by running the following command: + +```shell +packer build -var "orka_endpoint=$ORKA_ENDPOINT" -var "orka_auth_token=$ORKA_AUTH_TOKEN" -var "ssh_username=$SSH_USERNAME" -var "ssh_password=$SSH_PASSWORD" . +``` + +You can build a specific template by running the following command: + +```shell +packer build -var "orka_endpoint=$ORKA_ENDPOINT" -var "orka_auth_token=$ORKA_AUTH_TOKEN" -var "ssh_username=$SSH_USERNAME" -var "ssh_password=$SSH_PASSWORD" +``` + +## Continuous Integration + +The templates are initialized and validated in the CI pipeline using GitHub Actions. The pipeline runs on every push to the repository that modifies the templates. You can find the pipeline in the `.github/workflows/orka-templates.yml` directory. + +We don't plan to build the images in the CI pipeline. The images are built manually by the team once the PRs are merged or just before merged. \ No newline at end of file From cfaa2b961e0949c9207ef1d86c659bf9bc58436e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulises=20Gasc=C3=B3n?= Date: Sun, 25 Aug 2024 15:57:44 +0200 Subject: [PATCH 5/6] fix: add references to directories --- .github/workflows/orka-templates.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/orka-templates.yml b/.github/workflows/orka-templates.yml index 54eaa2793..cdfe7a38b 100644 --- a/.github/workflows/orka-templates.yml +++ b/.github/workflows/orka-templates.yml @@ -24,6 +24,7 @@ jobs: - name: Initialize Packer run: packer init . + working-directory: orka/templates - name: Validate Packer templates env: @@ -35,4 +36,5 @@ jobs: packer validate -var "orka_endpoint=$ORKA_ENDPOINT" \ -var "orka_auth_token=$ORKA_AUTH_TOKEN" \ -var "ssh_username=$SSH_USERNAME" \ - -var "ssh_password=$SSH_PASSWORD" . \ No newline at end of file + -var "ssh_password=$SSH_PASSWORD" . + working-directory: orka/templates \ No newline at end of file From 320a29674ebef1c6153614bf43ef858a776d8d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulises=20Gasc=C3=B3n?= Date: Sun, 25 Aug 2024 18:35:04 +0200 Subject: [PATCH 6/6] fix: remove manual ssh reference and change arch --- ...11-arm-test.pkr.hcl => macos-11-intel-test.pkr.hcl} | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) rename orka/templates/{macos-11-arm-test.pkr.hcl => macos-11-intel-test.pkr.hcl} (71%) diff --git a/orka/templates/macos-11-arm-test.pkr.hcl b/orka/templates/macos-11-intel-test.pkr.hcl similarity index 71% rename from orka/templates/macos-11-arm-test.pkr.hcl rename to orka/templates/macos-11-intel-test.pkr.hcl index a305ed342..cf815f1d0 100644 --- a/orka/templates/macos-11-arm-test.pkr.hcl +++ b/orka/templates/macos-11-intel-test.pkr.hcl @@ -27,19 +27,17 @@ packer { } } -source "macstadium-orka" "macos11-arm-test-image" { +source "macstadium-orka" "macos11-intel-test-image" { source_image = "90gbigsurssh.img" - image_name = "macos11-arm-test-latest.img" - image_description = "The MacOS 11 ARM test image" + image_name = "macos11-intel-test-latest.img" + image_description = "The MacOS 11 Intel test image" orka_endpoint = var.orka_endpoint orka_auth_token = var.orka_auth_token - ssh_username = var.ssh_username - ssh_password = var.ssh_password } build { sources = [ - "macstadium-orka.macos11-arm-test-image" + "macstadium-orka.macos11-intel-test-image" ] provisioner "shell" { inline = [