Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packer-rocm: test linting action(s) #55

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/packer-rocm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
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/[email protected]
with:
submodules: true

- uses: actions/[email protected]
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 and Collections
run: |
pip install ansible-core ansible-lint
ansible-galaxy collection install -r packer-rocm/requirements.yml

- name: ansible-lint
run: |
ansible-lint --profile production --parseable --nocolor packer-rocm/

# 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/[email protected]
# id: setup
# with:
# version: "latest"
11 changes: 6 additions & 5 deletions packer-rocm/README.md
Original file line number Diff line number Diff line change
@@ -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.


Expand Down Expand Up @@ -35,16 +35,18 @@ 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

| 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.<br/>Adjustment brings _display_ requirements. | `True` |
| `packer_binary` | The name _or_ path for the _Packer_ binary.<br/>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]_.<br/>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_.<br/>Comma-separated. May include releases with `=x.y.z` or globbing. | `linux-headers-generic-hwe-22.04`<br/>`mesa-amdgpu-va-drivers` |
Expand All @@ -57,7 +59,6 @@ Remove `-K` if your account does _not_ require a passphrase for `sudo`. This is
| `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.<br/>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

Expand Down
2 changes: 1 addition & 1 deletion packer-rocm/playbooks/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
7 changes: 3 additions & 4 deletions packer-rocm/ubuntu/ubuntu-rocm.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions packer-rocm/ubuntu/ubuntu-rocm.variables.pkr.hcl
Original file line number Diff line number Diff line change
@@ -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"
Expand Down