Different URL for different architectures

How can we have a single distrobuilder yaml for different architectures where the URL path differs between them.

Currently in the amazonlinux.yaml image file this is the URL line:
https://cdn.amazonlinux.com/os-images/{{ image.release }}/container/amzn2-container-raw-{{ image.release }}-x86_64.tar.xz

The URL for the arm image is slightly different path-wise:
https://cdn.amazonlinux.com/os-images/{{ image.release }}/container-arm64/amzn2-container-raw-{{ image.release }}-arm64.tar.xz

The architecture in the filename would be easy enough to solve by using an arch variable, but I don’t know how to go about the path difference since one has the arch and the other omits it.

The downloader is rootfs-http, I imagine a custom downloader for Amazon linux might be the fix here if there’s not an easy way?

Looks like a pongo2 pattern so you should be able to use if statements in there too.

{% if image.architecture == “arm64” %}URL1{% else %}URL2{% endif %}

Or something like that. I haven’t done much pongo2 templating lately :wink:

I had no idea that I could use logic in those! Welp, I’m going to be doing some pongo2 reading now :slight_smile:

Thanks so much for pointing me in the right direction, @stgraber!

I ended up with this as a working URL string:
https://cdn.amazonlinux.com/os-images/{{ image.release }}/{% if image.architecture == "arm64" %}container-arm64{% else %}container{% endif %}/amzn2-container-raw-{{ image.release }}-{{ image.architecture }}.tar.xz

Edit: The string was later modified to adjust for “aarch64” architecture as an input.