packer: rework variables
osbuild and composer commit SHAs now must be passed into packer using variables, no defaults are defined. Also, packer is no longer responsible for naming the AMIs, the name is also passed as a variable. imagebuilder_packer_sha was dropped entirely as the packer configuration now lives directly in osbuild-composer repository. Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
parent
0fb3634c2c
commit
b619e4875e
3 changed files with 9 additions and 44 deletions
|
|
@ -23,23 +23,19 @@ source "amazon-ebs" "image_builder" {
|
|||
# Apply tags to the instance that is building our image.
|
||||
run_tags = {
|
||||
AppCode = "IMGB-001"
|
||||
Name = "packer-builder-for-${local.ami_full_name}"
|
||||
composer_commit = "${var.composer_commit}"
|
||||
osbuild_commit = "${var.osbuild_commit}"
|
||||
imagebuilder_packer_commit = "${var.imagebuilder_packer_sha}"
|
||||
Name = "packer-builder-for-${var.image_name}"
|
||||
}
|
||||
|
||||
# Apply tags to the resulting AMI/EBS snapshot.
|
||||
tags = {
|
||||
AppCode = "IMGB-001"
|
||||
Name = "${local.ami_full_name}"
|
||||
Name = "${var.image_name}"
|
||||
composer_commit = "${var.composer_commit}"
|
||||
osbuild_commit = "${var.osbuild_commit}"
|
||||
imagebuilder_packer_commit = "${var.imagebuilder_packer_sha}"
|
||||
}
|
||||
|
||||
# Set a name for the resulting AMI.
|
||||
ami_name = "${local.ami_full_name}"
|
||||
ami_name = "${var.image_name}"
|
||||
|
||||
# Network configuration for the instance building our image.
|
||||
associate_public_ip_address = true
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
# Packer's HCL syntax doesn't have the same timestamp as the old Packer
|
||||
# version.
|
||||
locals {
|
||||
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
|
||||
|
||||
ami_name_append_pr = "testing-only"
|
||||
ami_full_name = "${var.ami_name}-${var.append_timestamp ? local.timestamp : local.ami_name_append_pr}"
|
||||
}
|
||||
|
|
@ -1,20 +1,5 @@
|
|||
##############################################################################
|
||||
## VARIABLES THAT ARE SAFE TO CHANGE 🤔
|
||||
|
||||
# Git SHA for the composer commit to include in the image.
|
||||
variable "composer_commit" {
|
||||
type = string
|
||||
default = "b075cac9e3d4a283918dbefa66cce46d372e3835"
|
||||
}
|
||||
|
||||
# Git SHA for the osbuild commit to include in the image.
|
||||
variable "osbuild_commit" {
|
||||
type = string
|
||||
default = "f7bf23fabaae6027b1e1147b27870d90d4b1911f"
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
## VARIABLES THAT PROBABLY SHOULD NOT BE CHANGED 😬
|
||||
# You need to specify all the following variables (except for region)
|
||||
# when running `packer build`
|
||||
|
||||
# AWS account configuration.
|
||||
variable "aws_access_key" { type = string }
|
||||
|
|
@ -25,16 +10,8 @@ variable "region" {
|
|||
}
|
||||
|
||||
# Automatically set by environment variables in GitHub Actions.
|
||||
variable "imagebuilder_packer_sha" { type = string }
|
||||
variable "composer_commit" { type = string }
|
||||
variable "osbuild_commit" { type = string }
|
||||
|
||||
# Default name for images (will have timestamp appended by default).
|
||||
variable "ami_name" {
|
||||
type = string
|
||||
default = "imagebuilder-service-image"
|
||||
}
|
||||
|
||||
# Set to True to append a timestamp to the AMI name.
|
||||
variable "append_timestamp" {
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
# The name of the resulting AMI and the underlying EBS snapshot
|
||||
variable "image_name" { type = string }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue