• Stars
    star
    148
  • Rank 249,983 (Top 5 %)
  • Language HCL
  • License
    MIT License
  • Created almost 4 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Packer templates and other tools for building AlmaLinux images for various cloud platforms.

AlmaLinux OS Cloud Images

AlmaLinux OS Cloud Images is a project that contains Packer templates and other tools for building AlmaLinux OS images for various cloud platforms.

Available Official Images

Name Architecture Download URL
Generic Cloud (OpenStack) x86_64 AArch64 ppc64le s390x https://wiki.almalinux.org/cloud/Generic-cloud.html
Azure Community Gallery x86_64 AArch64 https://wiki.almalinux.org/cloud/Azure.html
Azure Marketplace x86_64 AArch64 https://wiki.almalinux.org/cloud/Azure.html
AWS Community AMI x86_64 AArch64 https://wiki.almalinux.org/cloud/AWS.html
AWS Marketplace AMI x86_64 AArch64 https://aws.amazon.com/marketplace/seller-profile?id=529d1014-352c-4bed-8b63-6120e4bd3342
Docker Hub x86_64 AArch64 ppc64le s390x https://wiki.almalinux.org/containers/docker-images.html
Quay.io x86_64 AArch64 ppc64le s390x https://quay.io/organization/almalinuxorg
LXC/LXD x86_64 AArch64 ppc64le https://images.linuxcontainers.org
Google Cloud x86_64 https://wiki.almalinux.org/cloud/Google.html
Oracle Cloud Infrastructure x86_64 AArch64 https://wiki.almalinux.org/cloud/OCI.html
OpenNebula x86_64 AArch64 https://wiki.almalinux.org/cloud/OpenNebula.html
Vagrant virtualbox(x86_64), libvirt(x86_64, x86_64 UEFI), vmware_desktop(x86_64), hyperv(x86_64), parallels(x86_64, AArch64) https://app.vagrantup.com/almalinux

Usage

Install or Update installed Packer plugins:

packer init -upgrade .

Generic Cloud (OpenStack compatible) images

AlmaLinux OS 8

x86_64 BIOS only (Default):

packer build -only=qemu.almalinux-8-gencloud-x86_64 .

x86_64 UEFI only:

See: How to build UEFI and Secure Boot supported Images

packer build -only=qemu.almalinux-8-gencloud-uefi-x86_64 .

AArch64:

packer build -only=qemu.almalinux-8-gencloud-aarch64 .

ppc64le:

packer build -only=qemu.almalinux-8-gencloud-ppc64le .

AlmaLinux OS 9

x86_64 BIOS+UEFI (Default):

See: How to build UEFI and Secure Boot supported Images

packer build -only=qemu.almalinux-9-gencloud-x86_64 .

x86_64 BIOS only:

packer build -only=qemu.almalinux-9-gencloud-bios-x86_64 .

AArch64:

packer build -only=qemu.almalinux-9-gencloud-aarch64 .

ppc64le:

packer build -only=qemu.almalinux-9-gencloud-ppc64le .

Azure VM Images

Both AlmaLinux OS 8 and 9 cloud images supports Generation 1 and Generation 2 VMs.

AlmaLinux OS 8

See: How to build UEFI and Secure Boot supported Images

x86_64 BIOS + UEFI:

packer build -only=qemu.almalinux-8-azure-x86_64 .

AlmaLinux OS 9

x86_64 BIOS + UEFI:

See: How to build UEFI and Secure Boot supported Images

packer build -only=qemu.almalinux-9-azure-x86_64 .

Amazon Machine Images (AMI)

AlmaLinux OS 8

x86_64 BIOS only:

Before building AMI's you need to configure AWS credentials as described in the Packer documentation. Basically, you need to define the following environment variables:

export AWS_ACCESS_KEY_ID='ENTER_YOUR_ACCESS_KEY_HERE'
export AWS_SECRET_ACCESS_KEY='ENTER_YOUR_SECRET_KEY_HERE'
export AWS_DEFAULT_REGION='us-east-1'

Also, you need to create an S3 bucket that Packer will use for temporary image storing before importing it into EC2. It's strongly recommended creating the bucket in the us-east-1 region if you are going to submit your images to the Amazon Marketplace. Accordingly to Amazon's documentation, the self-service AMI scanner supports only that region.

After configuring the AWS credentials and creating the S3 bucket, run the following command to build an AMI and import it to EC2:

The Build process has two stages:

  • Stage 1: Build the first stage's AMI on your system and import it to the AWS.

  • Stage 2: Build the second stage's AMI on the EC2 Instance.

The First Stage:

QEMU:

packer build -var aws_s3_bucket_name="YOUR_S3_BUCKET_NAME" -only=qemu.almalinux-8-aws-stage1 .

VMware:

packer build -var aws_s3_bucket_name="YOUR_S3_BUCKET_NAME" -only=vmware-iso.almalinux-8-aws-stage1 .

If you are using a non-standard role name, it's possible to define it as a variable:

QEMU:

packer build -var aws_s3_bucket_name="YOUR_S3_BUCKET_NAME" \
    -var aws_role_name="YOUR_IAM_ROLE_NAME" -only=qemu.almalinux-8-aws-stage1 .

VMware:

packer build -var aws_s3_bucket_name="YOUR_S3_BUCKET_NAME" \
    -var aws_role_name="YOUR_IAM_ROLE_NAME" -only=vmware-iso.almalinux-8-aws-stage1 .

The Second Stage:

To finalize the AMI build process, you need to launch a minimum t2.micro EC2 instance from the first stage's AMI.

Launch an instance with the build-tools-on-ec2-userdata.yml Cloud-init User Data. It will install all needed packages - Packer, Ansible, Git and tmux (if your connection is not stable) and clone the repo automatically.

login as ec2-user:

cd cloud-images

Switch to the root user:

sudo su

Configure the AWS credentials:

export AWS_ACCESS_KEY_ID='ENTER_YOUR_ACCESS_KEY_HERE'
export AWS_SECRET_ACCESS_KEY='ENTER_YOUR_SECRET_KEY_HERE'
export AWS_DEFAULT_REGION='us-east-1'

Install or Update installed plugins:

packer.io init -upgrade .

Start the Build:

packer.io build -only=amazon-chroot.almalinux-8-aws-stage2 .

You can remove the first stage's AMI after the build complete

AArch64

Configure the AWS credentials:

export AWS_ACCESS_KEY_ID='ENTER_YOUR_ACCESS_KEY_HERE'
export AWS_SECRET_ACCESS_KEY='ENTER_YOUR_SECRET_KEY_HERE'
export AWS_DEFAULT_REGION='us-east-1'

Install or Update installed plugins:

packer init -upgrade .

Start the Build:

packer build -only=amazon-ebssurrogate.almalinux-8-aws-aarch64 .

AlmaLinux OS 9

Use one of these methods to set up your AWS credentials:

  • Static credentials
  • Environment variables
  • Shared credentials file
  • EC2 Role

See https://www.packer.io/plugins/builders/amazon#authentication for instructions.

Install or Update installed plugins:

packer init -upgrade .

Start the Build:

x86_64 BIOS only:

packer build -only=amazon-ebssurrogate.almalinux-9-ami-x86_64 .

AArch64

packer build -only=amazon-ebssurrogate.almalinux-9-ami-aarch64 .

Vagrant Boxes

AlmaLinux OS 8

Libvirt x86_64 BIOS only:

packer build -only=qemu.almalinux-8 .

Libvirt x86_64 UEFI only:

See:

packer build -only=qemu.almalinux-8-uefi .

VirtualBox x86_64:

packer build -only=virtualbox-iso.almalinux-8 .

VMware Desktop x86_64:

packer build -only=vmware-iso.almalinux-8 .

Parallels x86_64:

packer build -only=parallels-iso.almalinux-8 .

Hyper-V x86_64:

packer build -only="hyperv-iso.almalinux-8" .

With custom Virtual Switch:

packer build -var hyperv_switch_name="HyperV-vSwitch" -only="hyperv-iso.almalinux-8" .

AlmaLinux OS 9

Libvirt x86_64 BIOS + UEFI:

See:

packer build -only=qemu.almalinux-9 .

VirtualBox x86_64:

packer build -only=virtualbox-iso.almalinux-9 .

VMware Desktop x86_64:

packer build -only=vmware-iso.almalinux-9 .

VMware Desktop aarch64:

packer build -only=vmware-iso.almalinux-9-aarch64 .

Note: At this time, VMWare Fusion desktop, Apple M1 processer expects additional config settings to run vagrant box built for aarch64. It's behaviour of VMWare Fusion, not an issue of AlmaLinux.

Vagrant.configure("2") do |config|
    config.vm.box = "almalinux/9.aarch64"
    config.vm.box_version = "9.1.20230122"
    config.vm.provider "vmware_desktop" do |v|
        v.gui = true
        v.vmx["ethernet0.virtualdev"] = "vmxnet3"
    end
end

Parallels x86_64:

packer build -only=parallels-iso.almalinux-9 .

Parallels aarch64:

packer build -only=parallels-iso.almalinux-9-aarch64 .

Hyper-V x86_64:

packer build -only="hyperv-iso.almalinux-9" .

With custom Virtual Switch:

packer build -var hyperv_switch_name="HyperV-vSwitch" -only="hyperv-iso.almalinux-9" .

OpenNebula images

AlmaLinux OS 8

x86_64 BIOS only:

packer build -only=qemu.almalinux-8-opennebula-x86_64 .

AArch64:

packer build -only=qemu.almalinux-8-opennebula-aarch64 .

AlmaLinux OS 9

x86_64 BIOS + UEFI (Default)

packer build -only=qemu.almalinux-9-opennebula-x86_64 .

x86_64 BIOS only:

packer builder -only=qemu.almalinux-9-opennebula-bios-x86_64 .

AArch64:

packer build -only=qemu.almalinux-9-opennebula-aarch64 .

Oracle Cloud Infrastructure Images

AlmaLinux OS 8

Update the Oracle Cloud Agent RPM link if a newer version is available

ansible/roles/oci_guest/defaults/main.yml

x86_64 UEFI only (Default):

packer build -only=qemu.almalinux-8-oci-uefi-x86_64 .

x86_64 BIOS only:

packer build -only=qemu.almalinux-8-oci-x86_64 .

AArch64:

packer build -only=qemu.almalinux-8-oci-aarch64 .

AlmaLinux OS 9

x86_64 BIOS + UEFI (Default):

packer build -only=qemu.almalinux-9-oci-x86_64 .

x86_64 BIOS only:

packer build -only=qemu.almalinux-9-oci-bios-x86_64 .

AArch64

packer build -only=qemu.almalinux-9-oci-aarch64 .

DigitalOcean images

You need to setup a key for packer to use. This is done by going to DigitalOcean's cloud console.

Make it available through an environment variable:

export DIGITALOCEAN_API_TOKEN="ENTER_YOUR_ACCESS_TOKEN_HERE"

A space needs to be created in order to import the image through it. Please, read the relevant documentation. Take note of the access and secret keys in order to use them later on.

There are a few environment variables you will need to make available.

  • The spaces bucket name through DIGITALOCEAN_SPACE_NAME.
  • The bucket's access key through DIGITALOCEAN_SPACES_ACCESS_KEY.
  • The bucket's secret key through DIGITALOCEAN_SPACES_SECRET_KEY.

You can do this by exporting them as well:

export DIGITALOCEAN_SPACE_NAME='YOUR_SPACES_BUCKET_NAME'
export DIGITALOCEAN_SPACES_ACCESS_KEY='YOUR_BUCKET_ACCESS_KEY'
export DIGITALOCEAN_SPACES_SECRET_KEY='YOUR_BUCKET_SECRET_KEY'

Now, you're all setup. You can try building the image with:

AlmaLinux OS 8

x86_64 BIOS only:

packer build -only qemu.almalinux-8-digitalocean-x86_64 .

AlmaLinux OS 9

x86_64 BIOS only:

packer build -only qemu.almalinux-9-digitalocean-x86_64 .

Import the image to DigitalOcean:

You can upload your image or Import it via URL from the GitHub release section.

In Images >> Custom Images section, click on Import via URL and enter the URL of image file : https://github.com/AlmaLinux/cloud-images/releases/download/digitalocean-20210810/almalinux-8-DigitalOcean-8.4.20210810.x86_64.qcow2

HOW TOs

How to build UEFI and Secure Boot supported Images

You need a 1.0.7 or newer version of the QEMU packer plugin and OVMF to build UEFI images.

The ovmf_code and ovmf_vars Packer variables are set to default OVMF Secure Boot paths for the EL and Fedora. Use the table below for the OVMF package name and the firmware paths for your distro.

Distro Package ovmf_code ovmf_code
Arch Linux edk2-ovmf /usr/share/OVMF/OVMF_CODE.secboot.fd /usr/share/OVMF/OVMF_VARS.fd
Debian and derivatives ovmf /usr/share/OVMF/OVMF_CODE.secboot.fd /usr/share/OVMF/OVMF_VARS.ms.fd
Gentoo edk2-ovmf /usr/share/edk2-ovmf/OVMF_CODE.secboot.fd /usr/share/edk2-ovmf/OVMF_VARS.secboot.fd
OpenSUSE qemu-ovmf-x86_64 /usr/share/qemu/ovmf-x86_64-smm-ms-code.bin /usr/share/qemu/ovmf-x86_64-smm-ms-vars.bin

If your distro is not present in the table above or you want to build in different combinations like without Secure Boot, with AMD SEV or Intel TDX, check QEMU firmware metadata files in /usr/share/qemu/firmware for the correct paths and combinations.

EL:

packer build -var qemu_binary="/usr/libexec/qemu-kvm" -only=qemu.almalinux-9-gencloud-x86_64 .

Fedora:

packer build -only=qemu.almalinux-8-azure-x86_64 .

Debian and derivatives:

packer build -var ovmf_code="/usr/share/OVMF/OVMF_CODE.secboot.fd" -var ovmf_vars="/usr/share/OVMF/OVMF_VARS.ms.fd" -only=qemu.almalinux-8-gencloud-uefi-x86_64 .

or set the ovmf_code and ovmf_vars Packer variables in .auto.pkrvars.hcl file:

uefi.auto.pkrvars.hcl in OpenSUSE:

ovmf_code = "/usr/share/qemu/ovmf-x86_64-smm-ms-code.bin"
ovmf_vars = "/usr/share/qemu/ovmf-x86_64-smm-ms-vars.bin"

How to use UEFI supported Vagrant boxes

Libvirt:

AlmaLinux OS 8 - almalinux/8.uefi UEFI only

AlmaLinux OS 9 almalinux/9 BIOS + UEFI

Copy the OVMF NVRAM file:

cp /usr/share/OVMF/OVMF_VARS.secboot.fd OVMF_VARS.secboot_almalinux-uefi.fd

Set these values:

  • libvirt.loader - Location of OVMF_CODE
  • libvirt.nvram - Copied OVMF_VARS file
  • libvirt.machine_type = "q35"

Example Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
    config.vm.box = "almalinux/8.uefi"
    config.vm.hostname = "almalinux8-uefi.test"

    config.vm.provider "libvirt" do |libvirt|
        libvirt.qemu_use_session = false
        libvirt.memory = 2048
        libvirt.loader = "/usr/share/OVMF/OVMF_CODE.secboot.fd"
        libvirt.nvram = "OVMF_VARS.secboot_almalinux-uefi.fd"
        libvirt.machine_type = "q35"
    end
end

How to build Generic Cloud images on ppc64le

Load the KVM-HV kernel module

modprobe kvm_hv

Verify that the KVM kernel module is loaded

lsmod | grep kvm

If KVM loaded successfully, the output of this command includes kvm_hv.

The external packer plugins don't have the ppc64le builds yet, So use internal packer plugins.

mv versions.pkr.hcl versions.pkr.hcl.ignore

Requirements

  • Packer >= 1.7.0
  • Ansible >= 2.12
  • VirtualBox (for VirtualBox images only)
  • Parallels (for Parallels images only)
  • VMWare Workstation (for VMWare images and Amazon AMI's only)
  • QEMU (for Generic Cloud, Vagrant Libvirt, AWS AMI, OpenNebula and DigitalOcean images only)
  • EDK II (for only UEFI supported x86_64 ones and all AArch64 images)

FAQ:

Nothing happens after invoking the packer command

The cracklib-dicts's /usr/sbin/packer takes precedence over Hashicorp's /usr/bin/packer in the $PATH. Use packer.io instead of the packer. See: https://learn.hashicorp.com/tutorials/packer/get-started-install-cli#troubleshooting

ln -s /usr/bin/packer /usr/bin/packer.io

"qemu-system-x86_64": executable file not found in $PATH

Output:

Failed creating Qemu driver: exec: "qemu-system-x86_64": executable file not found in $PATH

By default, Packer looks for QEMU binary as qemu-system-x86_64. If it is different in your system, You can set your qemu binary with the qemu_binary Packer variable.

on EL - /usr/libexec/qemu-kvm

packer build -var qemu_binary="/usr/libexec/qemu-kvm" -only=qemu.almalinux-8-gencloud-x86_64 .

or set the qemu_binary Packer variable in .auto.pkrvars.hcl file:

qemu_on_el.auto.pkrvars.hcl

qemu_binary = "/usr/libexec/qemu-kvm"

Failed to connect to the host via scp with OpenSSH >= 9.0/9.0p1 and EL9

OpenSSH >= 9.0/9.0p1 and EL9 support was added in scp_90 branch instead of the main for backward compatibility. Please switch to this branch with git checkout scp_90

The Ansible's ansible.builtin.template module gives error on EL9 and >= OpenSSH 9.0/9.0p1 (2022-04-08) Host OS.

Error output:

fatal: [default]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via scp: bash: line 1: /usr/lib/sftp-server: No such file or directory\nConnection closed\r\n", "unreachable": true}

EL9 and OpenSSH >=9.0 deprecated the SCP protocol. Use the new -O flag until Ansible starts to use SFTP directly.

From OpenSSH 9.0/9.0p1 (2022-04-08) release note:

In case of incompatibility, the scp(1) client may be instructed to use the legacy scp/rcp using the -O flag.

See: OpenSSH SCP deprecation in RHEL 9: What you need to know

Add extra_arguments = [ "--scp-extra-args", "'-O'" ] to the Packer's Ansible Provisioner Block:

  provisioner "ansible" {
    playbook_file    = "./ansible/gencloud.yml"
    galaxy_file      = "./ansible/requirements.yml"
    roles_path       = "./ansible/roles"
    collections_path = "./ansible/collections"
    extra_arguments  = [ "--scp-extra-args", "'-O'" ]
    ansible_env_vars = [
      "ANSIBLE_PIPELINING=True",
      "ANSIBLE_REMOTE_TEMP=/tmp",
      "ANSIBLE_SSH_ARGS='-o ControlMaster=no -o ControlPersist=180s -o ServerAliveInterval=120s -o TCPKeepAlive=yes'"
    ]
  }

Packer's Ansible Plugin can't connect via SSH on SHA1 disabled system

FIXED: Starting with the 1.1.0 version, ECDSA keypair is generated and used by default instead of RSA.

To upgrade the plugin and disable SHA1:

packer init -upgrade .
update-crypto-policies --set DEFAULT

Error output:

fatal: [default]: UNREACHABLE! => {"changed": false, "msg": "Data could not be sent to remote host \"127.0.0.1\". Make sure this host can be reached over ssh: ssh_dispatch_run_fatal: Connection to 127.0.0.1 port 43729: error in libcrypto\r\n", "unreachable": true}

Enable the SHA1 on the system's default crypto policy until Packer's Ansible Plugin use a stronger key types and signature algorithms(rsa-sha2-256, rsa-sha2-512, ecdsa-sha2-nistp256, ssh-ed25519) than ssh-rsa.

Fedora and EL:

update-crypto-policies --set DEFAULT:SHA1

How to build AlmaLinux OS cloud images on EL

EL8:

See:

EL9:

See:

References

License

Licensed under the MIT license, see the LICENSE file for details.

More Repositories

1

almalinux-deploy

EL to AlmaLinux migration tool.
Shell
541
star
2

raspberry-pi

AlmaLinux Raspberry Pi
133
star
3

docker-images

Home for AlmaLinux Docker image RootFS files and production version of sources
Shell
94
star
4

mirrors

The AlmaLinux project mirrors configuration and tools.
Python
86
star
5

wiki

The AlmaLinux project documentation.
Shell
69
star
6

almalinux.org

almalinux.org official web site sources.
HTML
40
star
7

wsl-images

Visual Studio solution and kickstart file to generate WSL images and the associated appx.
C++
39
star
8

build-system

The AlmaLinux OS project Build System documentation and issue tracker.
25
star
9

sig-livemedia

AlmaLinux SIG/Live-media
Ruby
21
star
10

leapp-data

ELevate related data
Python
11
star
11

alma-sbom

AlmaLinux OS SBOM data management utility.
Python
10
star
12

ansible-almalinux.ci

Ansible collection for AlmaLinux OS CI.
Python
9
star
13

albs-node

AlmaLinux Build System build node.
Python
8
star
14

albs-web-server

Python
8
star
15

container-images

8
star
16

infra-devops

Infra and DevOps Utils, like Kickstart to RootFS file builder in docker/podman environment, using AlmaLinux as foundation. This utility can be used in CI/CD pipeline to build docker RootFS files
Shell
7
star
17

alts

AlmaLinux Test System
Python
7
star
18

osv-database

7
star
19

albs-infra

Python
4
star
20

gitea-listener

Python
3
star
21

almalinux-infra

AlmaLinux infrastructure provisioning toolchain.
HCL
3
star
22

Hardware-Certification-Suite

Shell
3
star
23

certifications

Certification Test Results
3
star
24

infra-ansible

AlmaLinux infrastructure Ansible playbooks and roles
Jinja
3
star
25

albs-frontend

Vue
2
star
26

sig-HPCAI

Example configuration files for deploying Slurm and other HPC software on AlmaLinux
2
star
27

albs-deploy

Jinja
2
star
28

updates

2
star
29

pes

The AlmaLinux Package Evolution Service
Python
2
star
30

albs-sign-node

Python
2
star
31

bootc-images

Dockerfile
2
star
32

build-system-rfes

Requests for the AlmaLinux Build System enhancement.
Python
1
star
33

AlmaLinuxBoardBusiness

A tracker for AlmaLinux Foundation Board legal and other questions
1
star
34

py-bitwarden-wrapper

Python
1
star
35

immudb-wrapper

The wrapper around Python Codetorary Immudb client.
Python
1
star
36

openqa-createhdds

OpenQA Helper Repo, Cloned and extended from Fedora https://pagure.io/fedora-qa/createhdds.git
Python
1
star
37

almalinux-backgrounds-extras

AlmaLinux Background Extras - files for KDE and XFCE use
1
star
38

os-autoinst-distri-almalinux

Perl
1
star