From a8975883c0a27a94f94b53fcc1dbe049be172306 Mon Sep 17 00:00:00 2001 From: Josh Lay Date: Sun, 20 Oct 2024 11:03:23 -0500 Subject: [PATCH 1/7] packer-rocm/actions: init (lint) --- .github/workflows/packer-rocm.yaml | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/packer-rocm.yaml diff --git a/.github/workflows/packer-rocm.yaml b/.github/workflows/packer-rocm.yaml new file mode 100644 index 0000000..d33c46f --- /dev/null +++ b/.github/workflows/packer-rocm.yaml @@ -0,0 +1,46 @@ +--- +name: Lint 'packer-rocm' + +on: + push: + paths: + - 'packer-rocm/**' + pull_request: + paths: + - 'packer-rocm/**' + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4.2.1 + with: + submodules: true + + - uses: actions/setup-python@v5.2.0 + with: + python-version: "3.x" + cache: 'pip' + + - name: Cache Ansible Collections + uses: actions/cache@v4 + with: + path: ~/.ansible/collections + key: ansible-collections-${{ hashFiles('packer-rocm/requirements.yml') }} + + - name: Install Ansible/Collections + run: | + pip install ansible-core ansible-lint + ansible-galaxy collection install -r packer-rocm/requirements.yml + + - name: Run 'ansible-lint' + run: | + ansible-lint --profile production --parseable --nocolor + + # if Ansible is good, set up Packer/test HCL + - name: Setup `packer` + uses: https://github.com/hashicorp/setup-packer@main + id: setup + with: + version: "latest" From b678dca83273287fce1a40d00a25d53204cf8dbe Mon Sep 17 00:00:00 2001 From: Josh Lay Date: Sun, 20 Oct 2024 11:10:57 -0500 Subject: [PATCH 2/7] packer-rocm: update README, note tag to skip host prep --- packer-rocm/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packer-rocm/README.md b/packer-rocm/README.md index df7d45b..2086d53 100644 --- a/packer-rocm/README.md +++ b/packer-rocm/README.md @@ -35,9 +35,10 @@ ansible-playbook ADA/packer-rocm/playbooks/build.yml \ -K ``` -Remove `-K` if your account does _not_ require a passphrase for `sudo`. This is used to prepare the host _(repositories and packages)_. +Remove `-K` if your account does _not_ require a passphrase for `sudo`. This is used to prepare the host. -**All** of these variables are _optional_. Please see [I/O](#io) for more. +Skip host preparation with `-t build`. **All** of these variables are _optional_. +Please see [I/O](#io) for more. ### I/O From 29dbb6ebc4c1e74c51200ff9ce130a778f94f622 Mon Sep 17 00:00:00 2001 From: Josh Lay Date: Sun, 20 Oct 2024 11:16:02 -0500 Subject: [PATCH 3/7] packer-rocm/workflow: use implicit ref for Packer, version --- .github/workflows/packer-rocm.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/packer-rocm.yaml b/.github/workflows/packer-rocm.yaml index d33c46f..5dac107 100644 --- a/.github/workflows/packer-rocm.yaml +++ b/.github/workflows/packer-rocm.yaml @@ -40,7 +40,7 @@ jobs: # if Ansible is good, set up Packer/test HCL - name: Setup `packer` - uses: https://github.com/hashicorp/setup-packer@main + uses: setup-packer@v3.1.0 id: setup with: version: "latest" From dc2ec1b63fb70dc38f42646d4faf51b365a017b8 Mon Sep 17 00:00:00 2001 From: Josh Lay Date: Sun, 20 Oct 2024 11:18:17 -0500 Subject: [PATCH 4/7] packer-rocm/README: minor brevity --- packer-rocm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packer-rocm/README.md b/packer-rocm/README.md index 2086d53..7c25ce6 100644 --- a/packer-rocm/README.md +++ b/packer-rocm/README.md @@ -1,7 +1,7 @@ # packer-rocm [MaaS](https://maas.io/)-enabled [Packer](https://www.packer.io/) images -with `amdgpu-dkms` and _(optional)_ [ROCm](https://www.amd.com/en/products/software/rocm.html). Builds on the [canonical/packer-maas](https://github.com/canonical/packer-maas/) +with `amdgpu-dkms` and [ROCm](https://www.amd.com/en/products/software/rocm.html). Builds on the [canonical/packer-maas](https://github.com/canonical/packer-maas/) project. From 53cd5ab546e6703919e67167dce54f1e410534c2 Mon Sep 17 00:00:00 2001 From: Josh Lay Date: Sun, 20 Oct 2024 11:20:40 -0500 Subject: [PATCH 5/7] packer-rocm/workflow: fix Packer ref, add org --- .github/workflows/packer-rocm.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/packer-rocm.yaml b/.github/workflows/packer-rocm.yaml index 5dac107..fdd7cf1 100644 --- a/.github/workflows/packer-rocm.yaml +++ b/.github/workflows/packer-rocm.yaml @@ -40,7 +40,7 @@ jobs: # if Ansible is good, set up Packer/test HCL - name: Setup `packer` - uses: setup-packer@v3.1.0 + uses: hashicorp/setup-packer@v3.1.0 id: setup with: version: "latest" From 9ee1ff2f1baada55c0d078a85c2cbcc5987ff793 Mon Sep 17 00:00:00 2001 From: Josh Lay Date: Sun, 20 Oct 2024 11:58:55 -0500 Subject: [PATCH 6/7] packer-rocm/workflow: only ansible-lint this directory --- .github/workflows/packer-rocm.yaml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/packer-rocm.yaml b/.github/workflows/packer-rocm.yaml index fdd7cf1..8dc5313 100644 --- a/.github/workflows/packer-rocm.yaml +++ b/.github/workflows/packer-rocm.yaml @@ -29,18 +29,20 @@ jobs: path: ~/.ansible/collections key: ansible-collections-${{ hashFiles('packer-rocm/requirements.yml') }} - - name: Install Ansible/Collections + - name: Install Ansible and Collections run: | pip install ansible-core ansible-lint ansible-galaxy collection install -r packer-rocm/requirements.yml - - name: Run 'ansible-lint' + - name: ansible-lint run: | - ansible-lint --profile production --parseable --nocolor + ansible-lint --profile production --parseable --nocolor packer-rocm/ - # if Ansible is good, set up Packer/test HCL - - name: Setup `packer` - uses: hashicorp/setup-packer@v3.1.0 - id: setup - with: - version: "latest" + # if Ansible passes, set up Packer/test HCL. + # challenge: many strict references to 'packer-maas' that are out-of-place until playbook-run. + +# - name: Setup `packer` +# uses: hashicorp/setup-packer@v3.1.0 +# id: setup +# with: +# version: "latest" From 237c37773ff1805d118783c5a035b1475490a4ff Mon Sep 17 00:00:00 2001 From: Josh Lay Date: Sun, 20 Oct 2024 12:00:20 -0500 Subject: [PATCH 7/7] packer-rocm/lint: (minor) improve Packer validation, consolidate deps --- packer-rocm/README.md | 4 ++-- packer-rocm/playbooks/build.yml | 2 +- packer-rocm/ubuntu/ubuntu-rocm.pkr.hcl | 7 +++---- packer-rocm/ubuntu/ubuntu-rocm.variables.pkr.hcl | 6 ++++++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packer-rocm/README.md b/packer-rocm/README.md index 7c25ce6..def4836 100644 --- a/packer-rocm/README.md +++ b/packer-rocm/README.md @@ -44,8 +44,9 @@ Please see [I/O](#io) for more. | Variable | Description | Default | |:----------:|-------------|:---------:| -| `qemu_binary` | The name _or_ path for the _QEMU_ binary. | `qemu-system-x86_64` | +| `hidden` | If the VNC window for the VM is _hidden_ during build.
Adjustment brings _display_ requirements. | `True` | | `packer_binary` | The name _or_ path for the _Packer_ binary.
Installation skipped if overridden. | `/usr/bin/packer` | +| `qemu_binary` | The name _or_ path for the _QEMU_ binary. | `qemu-system-x86_64` | | `rocm_releases` | One or more versions to include _[comma-separated]_.
Newest selects the `amdgpu` driver. | `6.2.2` | | `rocm_kernel` | The kernel package with an optional release specifier. | `linux-image-generic-hwe-22.04` | | `rocm_extras` | Packages to install _before_ `amdgpu-dkms` and _ROCm_.
Comma-separated. May include releases with `=x.y.z` or globbing. | `linux-headers-generic-hwe-22.04`
`mesa-amdgpu-va-drivers` | @@ -58,7 +59,6 @@ Please see [I/O](#io) for more. | `niccli_url` | The URL for the _Broadcom_ `niccli` installation archive. | [Link](https://docs.broadcom.com/docs-and-downloads/ethernet-network-adapters/NXE/Thor2/GCA1/bcm5760x_230.2.52.0a.zip) | | `niccli_sum` | _Optional_. Checksum to validate `niccli_url` downloads.
Example: `sha256:abcd1234` | _Undefined_ | | `niccli_driver` | If the `bnxt_{en,re}` NIC drivers are included. | `True` | -| `headless` | If the VNC window for the VM is _hidden_ during build. | `True` | #### MaaS diff --git a/packer-rocm/playbooks/build.yml b/packer-rocm/playbooks/build.yml index b4cc83f..5de4e38 100644 --- a/packer-rocm/playbooks/build.yml +++ b/packer-rocm/playbooks/build.yml @@ -123,7 +123,7 @@ ansible.builtin.command: cmd: > {{ packer_binary }} build - {% for _var in (packer_vars + ['headless', 'http_directory', 'http_proxy', 'https_proxy', 'no_proxy', 'ssh_ubuntu_password', 'ubuntu_release']) if vars[_var] is defined %} + {% for _var in (packer_vars + ['hidden', 'http_directory', 'http_proxy', 'https_proxy', 'no_proxy', 'ssh_ubuntu_password', 'ubuntu_release']) if vars[_var] is defined %} {{ '-var ' + _var + '=' + vars[_var] }} {% endfor %} -only=qemu.rocm . diff --git a/packer-rocm/ubuntu/ubuntu-rocm.pkr.hcl b/packer-rocm/ubuntu/ubuntu-rocm.pkr.hcl index 7167198..9cc3138 100644 --- a/packer-rocm/ubuntu/ubuntu-rocm.pkr.hcl +++ b/packer-rocm/ubuntu/ubuntu-rocm.pkr.hcl @@ -4,8 +4,8 @@ source "qemu" "rocm" { iso_target_path = "packer_cache/ubuntu-${var.ubuntu_release}.iso" iso_url = "https://releases.ubuntu.com/${var.ubuntu_release}/ubuntu-${var.ubuntu_release}-live-server-amd64.iso" # cloud-init, note 'cd_files' preserves original names - cd_files = ["meta-data"] cd_content = { + "meta-data" = "instance-id: iid-local01\nlocal-hostname: packer-rocm" "user-data" = file("${path.root}/user-data-rocm") # workaround for '-rocm' suffix; cloud-init expects 'user-data' } cd_label = "cidata" @@ -21,12 +21,11 @@ source "qemu" "rocm" { efi_boot = true efi_drop_efivars = true # don't place efivars.fd in output artifact format = "raw" # qcow2 may not be converted. if written to drives, can't be read back/won't find 'curtin' - headless = var.headless - http_directory = var.http_directory + headless = var.hidden shutdown_command = "sudo -S shutdown -P now" ssh_handshake_attempts = 500 ssh_username = "ubuntu" - ssh_password = var.ssh_ubuntu_password + ssh_password = "ubuntu" ssh_wait_timeout = "1h" ssh_timeout = "1h" # debug/discard diff --git a/packer-rocm/ubuntu/ubuntu-rocm.variables.pkr.hcl b/packer-rocm/ubuntu/ubuntu-rocm.variables.pkr.hcl index dfb1af1..72445f8 100644 --- a/packer-rocm/ubuntu/ubuntu-rocm.variables.pkr.hcl +++ b/packer-rocm/ubuntu/ubuntu-rocm.variables.pkr.hcl @@ -1,3 +1,9 @@ +variable "hidden" { + type = bool + default = true + description = "If the VNC display for the Virtual Machine is hidden while building the image. Adds display requirements" +} + variable "qemu_binary" { type = string default = "qemu-system-x86_64"