GithubHelp home page GithubHelp logo

uroesch / packer-linux Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 1.0 127 KB

Framework to create linux disk images for a corporate environment.

Ruby 13.68% HCL 36.93% Shell 24.24% HTML 25.15%
linux packer rhel ubuntu oraclelinux almalinux bios rocky-linux efi

packer-linux's Introduction

Build Linux Images with Packer

Project Goals

This project’s goal is to build a variety of Linux OS Images using Packer with the QEMU/KVM. The focus is to build OS images for a corporate environment where disk layout and the installed packages are as identical as possible.

A secondary goal is to build images for both BIOS and UEFI machines, but the focus is clearly set on the UEFI bulids.

A strong focus is to keep the CODE as DRY as possible and to try to keep the actual configuration for each new release to a minimum.

To keep the post-processing as generic as possible Ansible is used. The Ansible code has been decoupled to keep it modular and replaceable.

Project Scope

Target Platforms

This repo contains the packer instructions to build images for the following platforms:

  • QEMU (base image)

  • VMware

  • Hyper-V

  • Azure

There are plans to also create images for:

  • GCP (Google Compute Platform)

Supported Operating Systems

Full name Build name

Red Hat Enterprise Linux 7

rhel_7

Red Hat Enterprise Linux 8

rhel_8

Red Hat Enterprise Linux 9

rhel_9

CentOS 7

centos_7

Rocky Linux 8

rocky_8

Rocky Linux 9

rocky_9

Oracle Linux 7

oraclelinux_7

Oracle Linux 8

oraclelinux_8

Oracle Linux 9

oraclelinux_8

SUSE Enterprise Linux 15.2

sle_15

Ubuntu 18.04 LTS

ubuntu_18.04

Ubuntu 20.04 LTS

ubuntu_20.04

Ubuntu 22.04 LTS

ubuntu_22.04

Features

  • Can build both BIOS and UEFI based images.

  • Uses single GPT partition layout for both builds.

  • Same disklayout for all images.

  • Installation of cloud-init packages.

  • Conversion of QEMU qcow2 to Hyper-V (VHDX), Azure (VHD) and VMware (VMDK).

Dependencies

or

  • Packer

  • Ansible

  • Qemu with kernel extenstion KVM

  • Ruby

  • Rake

  • jq

Howto

Build with docker

The docker container contains the and the corresponding docker-packer script setup a noVNC websocket which can be used to monitor the progress of the build.

If building one container at the time the URL for connectiong is http://localhost:11180/vnc.html?host=localhost&port=11180

If running on a seperate machine one may open an SSH tunnel to view the content with a browser.

Build all images

docker-packer rake

The disk images are stored in the directory images.

Build a specific OS

Consult the build name in the operating system table.

In this example only Centos 7 is built.

docker-packer rake BUILD=centos_7

Build only for a specific target

In this example only Ubuntu 20.04 for Azure is built.

ℹ️
Requires a qcow2 base image to be present in the images directory.
docker-packer rake BUILD=centos_7 ONLY="*.azure"

Build locally

Build all images headless

rake

The disk images are stored in the directory images.

Build image with QEMU window

rake HEADLESS=false
Build only a specific OS
rake BUILD=ubuntu_20.04

Build only for a specific target

ℹ️
Requires a qcow2 base image to be present in the images directory.
rake BUILD=centos_7 ONLY='*.vmware'

Build image with BIOS firmware

rake BUILD=centos_7 FIRMWARE=bios

Build changes

All parameters are stored under the <os_name>.pkrvars.hcl files. e.g for CentOS 8 the file is called centos_8.pkrvars.hcl.

In the templates directory the kickstart, preseed and Cloud-Init templates are stored. The are ERB templates and use the config[] hash to refer to the variables defined in the packer variable files.

Some of the templates are symlinks to make changes for a certain of release global. E.g. the Centos 7, Red Hat Enterprise Linux 7 and Oracle Linux 7 share a common kickstart file.

packer-linux's People

Contributors

uroesch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

slakkara

packer-linux's Issues

[Request]: Add RHEL 7

What would you like to see implemented?

Add denitions for RHEL 7.

Target Operating System

Not applicable

[Request]: Add Debian 11

What would you like to see implemented?

Add Debian 11 builds.

Target Operating System

Not applicable

[Request]: Add more disk layouts

What would you like to see implemented?

Add more disk layout options besides the pcidss and default layout.

Target Operating System

All

[Issue]: Use cdrom build instead of url for all RHEL 7 derivatives kickstart files

What went wrong?

Use cdrom for the installation media on all RHEL 7 builds and derivatives in the kickstart file to speed up the build process.

Specify the build host system.

n/a

Are you building with docker?

  • Yes

Operating System with Errors

CentOS 7.x, Oracle Linux 7.x, Red Hat Enterprise Linux 7.x

Which generated disk image is not working?

QCOW2 (KVM, QEMU, Proxmox)

Relevant log output

n/a

[Issue]: Ubuntu 22.04 network does not work with vmware deploy

What went wrong?

When deploying a Ubuntu 22.04 machine with vmware the network stack in /etc/netplan does not configure the interface correctly.

A fix is to remove the original netplan file.

Specify the build host system.

Ubuntu 22.04

Are you building with docker?

  • Yes

Operating System with Errors

Ubuntu 22.04.x (jammy)

Which generated disk image is not working?

VMDK (vSphere, ESXi)

Relevant log output

No response

[Request]: Add Ubuntu 18.04

What would you like to see implemented?

Add Ubuntu 18.04 builds.

Target Operating System

New OS definition

[Request]: Add openSUSE 15

What would you like to see implemented?

Add openSUSE 15 build.

Target Operating System

New OS definition

[Request]: Add AlmaLinux 8

What would you like to see implemented?

Add AlmaLinux 8 defintion.

Target Operating System

Not applicable

[Request]: Add RHEL 8

What would you like to see implemented?

Add defnitions for RHEL 8.

Target Operating System

Not applicable

[Request]: Update VMDK parameters in the convert-diskimage.sh script

What would you like to see implemented?

Since qemu-img version 6.2.0 there are new vmdk parameters and disk image version can be set from version 6 to version 7.
Check the version of qem-img and change the parameters for vmdk depending on the underlying version.

Target Operating System

Not applicable

[Request]: Add RHEL 9

What would you like to see implemented?

Add defintions for RHEL 9.

Target Operating System

Not applicable

[Issue]: Use the locale variable in all kickstart templates

What went wrong?

The locale variable is only used in the ubuntu templates. Use them also in the kickstart templates.

Specify the build host system.

n/a

Are you building with docker?

  • Yes

Operating System with Errors

AlmaLinux 8.x, AlmaLinux 9.x, CentOS 7.x, Oracle Linux 7.x, Oracle Linux 8.x, Oracle Linux 9.x, Red Hat Enterprise Linux 7.x, Red Hat Enterprise Linux 8.x, Red Hat Enterprise Linux 9.x, Rocky Linux 8.x, Rocky Linux 9.x

Which generated disk image is not working?

All

Relevant log output

n/a

[Request]: Add Oracle Linux 7

What would you like to see implemented?

Add definstions for Oracle Linux 7.

Target Operating System

Not applicable

[Issue]: Build Centos 7 from CD only

What went wrong?

Centos 7 can not be built from ISO only. Check if this can be fixed.

Specify the build host system.

Ubuntu 20.04

Are you building with docker?

  • Yes

Operating System with Errors

CentOS 7.x

Which generated disk image is not working?

QCOW2 (KVM, QEMU, Proxmox)

Relevant log output

No response

[Request]: Add AlmaLinux 9

What would you like to see implemented?

Add AlmaLinux 9 defintion.

Target Operating System

Not applicable

[Issue]: VMDK image not booting up

What went wrong?

After uploading the generated vmdk images to vsphere 7.x and trying to start generates an EFI disk not found error.

Specify the build host system.

Ubuntu 22.04

Are you building with docker?

  • Yes

Operating System with Errors

Red Hat Enterprise Linux 7.x, Red Hat Enterprise Linux 8.x

Which generated disk image is not working?

VMDK (vSphere, ESXi)

Relevant log output

Attempting to start up from:
-> EFI Virtual disk (0.0)... No compatible bootloader found.
-> EFI Network

[Issue]: EFI issues on VMware when building with virtio

What went wrong?

When building second stage vor vmware with virtio as the disk drivers the configuration for grub are not properly updated and can cause issues when updating the kernel as some entries refer to /dev/vda instead of /dev/sda.

Specify the build host system.

n/a

Are you building with docker?

  • Yes

Operating System with Errors

All

Which generated disk image is not working?

VMDK (vSphere, ESXi)

Relevant log output

No response

[Request]: Add Rocky Linux 9

What would you like to see implemented?

Add defnitions for Rocky Linux 9

Target Operating System

Not applicable

[Request]: Add Oracle Linux 9

What would you like to see implemented?

Add defintions for Oracle Linux 9.

Target Operating System

Not applicable

[Request]: Add CentOS 7

What would you like to see implemented?

Add defnitions for CentOS 7.x.

Target Operating System

Not applicable

[Request]: Add Rocky Linux 8

What would you like to see implemented?

Add definitions for Rocky Linux 8.

Target Operating System

Not applicable

[Issue]: AlamaLinux 8.6 does no longer build

What went wrong?

The URLs in almalinux_8.6.pkrvars.hcl are no longer valid and require an update.
The build stops during validation of the URLs.

Specify the build host system.

n/a

Are you building with docker?

  • Yes

Operating System with Errors

AlmaLinux 8.x

Which generated disk image is not working?

QCOW2 (KVM, QEMU, Proxmox)

Relevant log output

N/A

[Issue]: Install fails due to missing package qemu-quest-agent

What went wrong?

During the base image build the package qemu-guest-agent is not found and crashes the subiquity process.

Specify the build host system.

Ubuntu 22.04

Are you building with docker?

  • Yes

Operating System with Errors

Ubuntu 20.04.x (focal)

Which generated disk image is not working?

QCOW2 (KVM, QEMU, Proxmox)

Relevant log output

Apr 28 12:54:42 ubuntu-server subiquity_log.2194[17276]: Running command ['mount', '--make-private', '/target/dev'] with allowed return codes [0] (capture=False)
Apr 28 12:54:42 ubuntu-server subiquity_log.2194[17276]: Running command ['umount', '/target/dev'] with allowed return codes [0] (capture=False)
Apr 28 12:54:42 ubuntu-server subiquity_log.2194[17276]: system install failed for ['qemu-guest-agent']: Unexpected error while running command.
Apr 28 12:54:42 ubuntu-server subiquity_log.2194[17276]: Command: ['unshare', '--fork', '--pid', '--', 'chroot', '/target', 'eatmydata', 'apt-get', '--quiet', '--assume-yes', '--option=Dpkg::options::=--force-unsafe-io', '--option=Dpkg::Options::=--force-confold', 'install', 'qemu-guest-agent']
Apr 28 12:54:42 ubuntu-server subiquity_log.2194[17276]: Exit code: 100

[Issue]: Crypt root password in kickstart file

What went wrong?

Crypt the password in the kickstart file for RHEL 8 and RHEL 9 based OSes. Check the one from RHEL 7 and derivates.

E.g.

-rootpw <%= config['ssh_password'] %>
+rootpw --iscrypted <%= PasswordFactory.sha512(config['root_password']).hashed %>

Specify the build host system.

n/a

Are you building with docker?

  • Yes

Operating System with Errors

AlmaLinux 8.x, AlmaLinux 9.x, Oracle Linux 8.x, Oracle Linux 9.x, Red Hat Enterprise Linux 8.x, Red Hat Enterprise Linux 9.x, Rocky Linux 8.x, Rocky Linux 9.x

Which generated disk image is not working?

QCOW2 (KVM, QEMU, Proxmox)

Relevant log output

N/A

[Issue]: Device /dev/vda3 in /var/cache/debconf/config.dat to /dev/sda3 for vmware

What went wrong?

While building with qemu the efi device for grub-efi-amd64 is /dev/vda3 registered in the file /var/cache/debconf/config.dat for VMware installations this value must be changed to /dev/sda3 or installations of the package grub-efi-amd64 will fail.

Specify the build host system.

Ubuntu 22.04

Are you building with docker?

  • Yes

Operating System with Errors

Ubuntu 20.04.x (focal), Ubuntu 22.04.x (jammy)

Which generated disk image is not working?

VMDK (vSphere, ESXi)

Relevant log output

No response

[Issue]: Rocky Linux 9.1 does no longer build.

What went wrong?

Stops at the selection screen in kickstart

image

Specify the build host system.

Ubuntu 22.04

Are you building with docker?

  • Yes

Operating System with Errors

Rocky Linux 9.x

Which generated disk image is not working?

QCOW2 (KVM, QEMU, Proxmox)

Relevant log output

See attached image.

[Issue]: AlamaLinux 9.0 does no longer build

What went wrong?

The alamalinux_9.0.pkrvars.hcl URLs no longer work and need to be updated.

Specify the build host system.

n/a

Are you building with docker?

  • Yes

Operating System with Errors

AlmaLinux 9.x

Which generated disk image is not working?

QCOW2 (KVM, QEMU, Proxmox)

Relevant log output

N/A

[Issue]: Packer can't download the ISO directly

What went wrong?

The variable iso_base_url has a trailing / which results in a url with two slashes which packer does not handle correctly.
Remove the trailing slash from all iso_base_url variables.

Specify the build host system.

n/a

Are you building with docker?

  • Yes

Operating System with Errors

All

Which generated disk image is not working?

Not applicable

Relevant log output

2023/04/27 09:36:26 ui: ^[[1;32m==> qemu.base: Download failed source path error: stat /media/uroesch/work/github/packer-linux/iso/ubuntu_22.10/ubuntu-22.10-live-server-amd64.iso: no such file or directory^[[0m
2023/04/27 09:36:26 ui: ^[[1;32m==> qemu.base: Trying https://releases.ubuntu.com/22.10//ubuntu-22.10-live-server-amd64.iso^[[0m
2023/04/27 09:36:26 packer-builder-qemu plugin: Acquiring lock for: https://releases.ubuntu.com/22.10//ubuntu-22.10-live-server-amd64.iso?checksum=sha256%3A874452797430a94ca240c95d8503035aa145bd03ef7d84f9b23b78f3c5099aed (packer/../iso/ubuntu_22.10/ubuntu-22.10-live-server-amd64.iso.lock)
2023/04/27 09:36:26 ui: ^[[1;32m==> qemu.base: Trying https://releases.ubuntu.com/22.10//ubuntu-22.10-live-server-amd64.iso?checksum=sha256%3A874452797430a94ca240c95d8503035aa145bd03ef7d84f9b23b78f3c5099aed^[[0m
2023/04/27 09:36:27 packer-builder-qemu plugin: closing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.