Skip to content

Commit

Permalink
Add TIMEOUT option when building images (#223)
Browse files Browse the repository at this point in the history
Expose the timeout option in as a variable in packer `-var timeout
<value` or with make `TIMEOUT=<value>`, rather than hard-coding it.
  • Loading branch information
SK1Y101 authored Mar 25, 2024
1 parent 473f2e2 commit 8390032
Show file tree
Hide file tree
Showing 62 changed files with 299 additions and 52 deletions.
3 changes: 2 additions & 1 deletion alma8/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include ../scripts/check.mk

PACKER ?= packer
PACKER_LOG ?= 0
TIMEOUT ?= 1h

export PACKER_LOG

Expand All @@ -14,7 +15,7 @@ all: alma8.tar.gz
$(eval $(call check_packages_deps))

alma8.tar.gz: check-deps clean
${PACKER} init alma8.pkr.hcl && ${PACKER} build alma8.pkr.hcl
${PACKER} init alma8.pkr.hcl && ${PACKER} build -var timeout=${TIMEOUT} alma8.pkr.hcl

clean:
${RM} -rf output-alma8 alma8.tar.gz
6 changes: 6 additions & 0 deletions alma8/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ The installation runs in a non-interactive mode.

Note: alma8.pkr.hcl runs Packer in headless mode, with the serial port output from qemu redirected to stdio to give feedback on image creation process. If you wish to see more, change the value of `headless` to `false` in alma8.pkr.hcl, remove `[ "-serial", "stdio" ]` from `qemuargs` section and select `View`, then `serial0` in the qemu window that appears during build. This lets you watch progress of the image build script. Press `ctrl-b 2` to switch to shell to explore more, and `ctrl-b 1` to go back to log view.

### Makefile Parameters

#### TIMEOUT

The timeout to apply when building the image. The default value is set to 1h.

## Uploading an image to MAAS

```shell
Expand Down
8 changes: 7 additions & 1 deletion alma8/alma8.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ variable ks_mirror {
default = "${env("KS_MIRROR")}"
}

variable "timeout" {
type = string
default = "1h"
description = "Timeout for building the image"
}

locals {
ks_proxy = var.ks_proxy != "" ? "--proxy=${var.ks_proxy}" : ""
ks_os_repos = var.ks_mirror != "" ? "--url=${var.ks_mirror}/BaseOS/x86_64/os" : var.ks_os_repos
Expand All @@ -72,7 +78,7 @@ source "qemu" "alma8" {
iso_url = var.alma_iso_url
memory = 2048
qemuargs = [["-serial", "stdio"]]
shutdown_timeout = "1h"
shutdown_timeout = var.timeout
http_content = {
"/alma8.ks" = templatefile("${path.root}/http/alma8.ks.pkrtpl.hcl",
{
Expand Down
3 changes: 2 additions & 1 deletion alma9/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include ../scripts/check.mk

PACKER ?= packer
PACKER_LOG ?= 0
TIMEOUT ?= 1h

export PACKER_LOG

Expand All @@ -14,7 +15,7 @@ all: alma9.tar.gz
$(eval $(call check_packages_deps))

alma9.tar.gz: check-deps clean
${PACKER} init alma9.pkr.hcl && ${PACKER} build alma9.pkr.hcl
${PACKER} init alma9.pkr.hcl && ${PACKER} build -var timeout=${TIMEOUT} alma9.pkr.hcl

clean:
${RM} -rf output-alma9 alma9.tar.gz
6 changes: 6 additions & 0 deletions alma9/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ The installation runs in a non-interactive mode.

Note: alma9.pkr.hcl runs Packer in headless mode, with the serial port output from qemu redirected to stdio to give feedback on image creation process. If you wish to see more, change the value of `headless` to `false` in alma9.pkr.hcl, remove `[ "-serial", "stdio" ]` from `qemuargs` section and select `View`, then `serial0` in the qemu window that appears during build. This lets you watch progress of the image build script. Press `ctrl-b 2` to switch to shell to explore more, and `ctrl-b 1` to go back to log view.

### Makefile Parameters

#### TIMEOUT

The timeout to apply when building the image. The default value is set to 1h.

## Uploading an image to MAAS

```shell
Expand Down
8 changes: 7 additions & 1 deletion alma9/alma9.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ variable ks_mirror {
default = "${env("KS_MIRROR")}"
}

variable "timeout" {
type = string
default = "1h"
description = "Timeout for building the image"
}

locals {
ks_proxy = var.ks_proxy != "" ? "--proxy=${var.ks_proxy}" : ""
ks_os_repos = var.ks_mirror != "" ? "--url=${var.ks_mirror}/BaseOS/x86_64/os" : var.ks_os_repos
Expand All @@ -78,7 +84,7 @@ source "qemu" "alma9" {
iso_url = "${var.alma_iso_url}"
memory = 2048
qemuargs = [["-serial", "stdio"], ["-cpu", "host"]]
shutdown_timeout = "1h"
shutdown_timeout = var.timeout
http_content = {
"/alma9.ks" = templatefile("${path.root}/http/alma9.ks.pkrtpl.hcl",
{
Expand Down
3 changes: 2 additions & 1 deletion centos6/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include ../scripts/check.mk

PACKER ?= packer
PACKER_LOG ?= 0
TIMEOUT ?= 1h

export PACKER_LOG

Expand All @@ -14,7 +15,7 @@ all: centos6.tar.gz
$(eval $(call check_packages_deps))

centos6.tar.gz: check-deps clean
${PACKER} init centos6.pkr.hcl && ${PACKER} build centos6.pkr.hcl
${PACKER} init centos6.pkr.hcl && ${PACKER} build -var timeout=${TIMEOUT} centos6.pkr.hcl

clean:
${RM} -rf output-centos6 centos6.tar.gz
6 changes: 6 additions & 0 deletions centos6/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ centos6.pkr.hcl.

Installation is non-interactive.

### Makefile Parameters

#### TIMEOUT

The timeout to apply when building the image. The default value is set to 1h.

## Uploading an image to MAAS

```shell
Expand Down
8 changes: 7 additions & 1 deletion centos6/centos6.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ variable ks_mirror {
default = "${env("KS_MIRROR")}"
}

variable "timeout" {
type = string
default = "1h"
description = "Timeout for building the image"
}

locals {
ks_proxy = var.ks_proxy != "" ? "--proxy=${var.ks_proxy}" : ""
ks_os_repos = var.ks_mirror != "" ? "--url=${var.ks_mirror}/os/x86_64" : var.ks_os_repos
Expand All @@ -81,7 +87,7 @@ source "qemu" "centos6" {
iso_url = var.centos6_iso_url
memory = 2048
qemuargs = [["-serial", "stdio"]]
shutdown_timeout = "1h"
shutdown_timeout = var.timeout
http_content = {
"/centos6.ks" = templatefile("${path.root}/http/centos6.ks.pkrtpl.hcl",
{
Expand Down
3 changes: 2 additions & 1 deletion centos7/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include ../scripts/check.mk

PACKER ?= packer
PACKER_LOG ?= 0
TIMEOUT ?= 1h

export PACKER_LOG

Expand All @@ -14,7 +15,7 @@ all: centos7.tar.gz
$(eval $(call check_packages_deps))

centos7.tar.gz: clean check-deps
${PACKER} init centos7.pkr.hcl && ${PACKER} build centos7.pkr.hcl
${PACKER} init centos7.pkr.hcl && ${PACKER} build -var timeout=${TIMEOUT} centos7.pkr.hcl

clean:
${RM} -rf output-centos7 centos7.tar.gz
6 changes: 6 additions & 0 deletions centos7/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ centos7.pkr.hcl.

Installation is non-interactive.

### Makefile Parameters

#### TIMEOUT

The timeout to apply when building the image. The default value is set to 1h.

## Uploading an image to MAAS

```shell
Expand Down
8 changes: 7 additions & 1 deletion centos7/centos7.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ variable ks_mirror {
default = "${env("KS_MIRROR")}"
}

variable "timeout" {
type = string
default = "1h"
description = "Timeout for building the image"
}

locals {
ks_proxy = var.ks_proxy != "" ? "--proxy=${var.ks_proxy}" : ""
ks_os_repos = var.ks_mirror != "" ? "--url=${var.ks_mirror}/os/x86_64" : var.ks_os_repos
Expand All @@ -72,7 +78,7 @@ source "qemu" "centos7" {
iso_url = var.centos7_iso_url
memory = 2048
qemuargs = [["-serial", "stdio"]]
shutdown_timeout = "1h"
shutdown_timeout = var.timeout
http_content = {
"/centos7.ks" = templatefile("${path.root}/http/centos7.ks.pkrtpl.hcl",
{
Expand Down
3 changes: 2 additions & 1 deletion centos8-stream/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include ../scripts/check.mk

PACKER ?= packer
PACKER_LOG ?= 0
TIMEOUT ?= 1h

export PACKER_LOG

Expand All @@ -14,7 +15,7 @@ all: centos8-stream.tar.gz
$(eval $(call check_packages_deps))

centos8-stream.tar.gz: check-deps clean
${PACKER} init centos8-stream.pkr.hcl && ${PACKER} build centos8-stream.pkr.hcl
${PACKER} init centos8-stream.pkr.hcl && ${PACKER} build -var timeout=${TIMEOUT} centos8-stream.pkr.hcl

clean:
${RM} -rf output-centos8-stream centos8-stream.tar.gz
6 changes: 6 additions & 0 deletions centos8-stream/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ centos8-stream.pkr.hcl.

Installation is non-interactive.

### Makefile Parameters

#### TIMEOUT

The timeout to apply when building the image. The default value is set to 1h.

## Uploading an image to MAAS

```shell
Expand Down
8 changes: 7 additions & 1 deletion centos8-stream/centos8-stream.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ variable ks_mirror {
default = "${env("KS_MIRROR")}"
}

variable "timeout" {
type = string
default = "1h"
description = "Timeout for building the image"
}

locals {
ks_proxy = var.ks_proxy != "" ? "--proxy=${var.ks_proxy}" : ""
ks_os_repos = var.ks_mirror != "" ? "--url=${var.ks_mirror}/os/x86_64" : var.ks_os_repos
Expand All @@ -69,7 +75,7 @@ source "qemu" "centos8-stream" {
iso_url = var.centos8_stream_iso_url
memory = 2048
qemuargs = [["-serial", "stdio"]]
shutdown_timeout = "1h"
shutdown_timeout = var.timeout
http_content = {
"/centos8-stream.ks" = templatefile("${path.root}/http/centos8-stream.ks.pkrtpl.hcl",
{
Expand Down
3 changes: 2 additions & 1 deletion centos8/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ include ../scripts/check.mk
PACKER ?= packer
PACKER_LOG ?= 0
KS_MIRROR ?= http://mirrorlist.centos.org
TIMEOUT ?= 1h
export PACKER_LOG

.PHONY: all clean
Expand All @@ -14,7 +15,7 @@ all: centos8.tar.gz
$(eval $(call check_packages_deps))

centos8.tar.gz: check-deps clean
${PACKER} init centos8.pkr.hcl && ${PACKER} build centos8.pkr.hcl
${PACKER} init centos8.pkr.hcl && ${PACKER} build -var timeout=${TIMEOUT} centos8.pkr.hcl

clean:
${RM} -rf output-centos8 centos8.tar.gz
6 changes: 6 additions & 0 deletions centos8/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ centos8.pkr.hcl.

Installation is non-interactive.

### Makefile Parameters

#### TIMEOUT

The timeout to apply when building the image. The default value is set to 1h.

## Uploading an image to MAAS

```shell
Expand Down
8 changes: 7 additions & 1 deletion centos8/centos8.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ variable ks_mirror {
default = "${env("KS_MIRROR")}"
}

variable "timeout" {
type = string
default = "1h"
description = "Timeout for building the image"
}

locals {
ks_proxy = var.ks_proxy != "" ? "--proxy=${var.ks_proxy}" : ""
ks_os_repos = var.ks_mirror != "" ? "--url=${var.ks_mirror}/os/x86_64" : var.ks_os_repos
Expand All @@ -68,7 +74,7 @@ source "qemu" "centos8" {
iso_url = var.centos8_iso_url
memory = 2048
qemuargs = [["-serial", "stdio"]]
shutdown_timeout = "1h"
shutdown_timeout = var.timeout
http_content = {
"/centos8.ks" = templatefile("${path.root}/http/centos7.ks.pkrtpl.hcl",
{
Expand Down
3 changes: 2 additions & 1 deletion centos9-stream/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include ../scripts/check.mk

PACKER ?= packer
PACKER_LOG ?= 0
TIMEOUT ?= 1h

export PACKER_LOG

Expand All @@ -14,7 +15,7 @@ all: centos9-stream.tar.gz
$(eval $(call check_packages_deps))

centos9-stream.tar.gz: check-deps clean
${PACKER} init centos9-stream.pkr.hcl && ${PACKER} build centos9-stream.pkr.hcl
${PACKER} init centos9-stream.pkr.hcl && ${PACKER} build -var timeout=${TIMEOUT} centos9-stream.pkr.hcl

clean:
${RM} -rf output-centos9-stream centos9-stream.tar.gz
6 changes: 6 additions & 0 deletions centos9-stream/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ centos9-stream.pkr.hcl.

Installation is non-interactive.

### Makefile Parameters

#### TIMEOUT

The timeout to apply when building the image. The default value is set to 1h.

## Uploading an image to MAAS

```shell
Expand Down
8 changes: 7 additions & 1 deletion centos9-stream/centos9-stream.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ variable ks_mirror {
default = "${env("KS_MIRROR")}"
}

variable "timeout" {
type = string
default = "1h"
description = "Timeout for building the image"
}

locals {
ks_proxy = var.ks_proxy != "" ? "--proxy=${var.ks_proxy}" : ""
ks_os_repos = var.ks_mirror != "" ? "--url=${var.ks_mirror}/BaseOS/x86_64" : var.ks_os_repos
Expand All @@ -76,7 +82,7 @@ source "qemu" "centos9-stream" {
iso_url = var.centos9_stream_iso_url
memory = 2048
qemuargs = [["-serial", "stdio"], ["-cpu", "host"]]
shutdown_timeout = "1h"
shutdown_timeout = var.timeout
http_content = {
"/centos9-stream.ks" = templatefile("${path.root}/http/centos9-stream.ks.pkrtpl.hcl",
{
Expand Down
4 changes: 3 additions & 1 deletion debian/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export PACKER_LOG
SERIES ?= bullseye
BOOT ?= uefi
ARCH ?= amd64
TIMEOUT ?= 1h

ifeq ($(strip $(SERIES)),buster)
VERSION = 10
Expand Down Expand Up @@ -46,7 +47,8 @@ debian: check-deps clean
-var debian_series=${SERIES} \
-var debian_version=${VERSION} \
-var architecture=${ARCH} \
-var boot_mode=${BOOT} .
-var boot_mode=${BOOT} \
-var timeout=${TIMEOUT} .

clean:
${RM} -rf output-* debian-custom-*.gz \
Expand Down
4 changes: 4 additions & 0 deletions debian/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ for amd64 architecture.

Target image architecture. Supported values are amd64 (default) and arm64.

#### TIMEOUT

The timeout to apply when building the image. The default value is set to 1h.

### Default Username

The default username is ```debian```
Expand Down
Loading

0 comments on commit 8390032

Please sign in to comment.