packer: remove RHEL and x86_64-specific bits

Arch was easy.

For passing the repository distribution and osbuild_commit (it can be
different for each distro), I decided to go in the way of ansible
inventory directories. It adds a bit of structure but I think it's
the most clean solution.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2022-03-10 11:25:59 +01:00 committed by Ondřej Budai
parent cd394bf67d
commit ec070612ff
5 changed files with 57 additions and 10 deletions

View file

@ -0,0 +1,5 @@
---
# this is just a template!
# the actual content is generated by build/appsre-build-worker-packer.sh
rpmrepo_distribution: distro
osbuild_commit: abcdef

View file

@ -6,7 +6,7 @@
yum_repository:
name: "composer"
description: "osbuild-composer commit {{ COMPOSER_COMMIT }}"
baseurl: "http://osbuild-composer-repos.s3.amazonaws.com/osbuild-composer/rhel-8-cdn/x86_64/{{ COMPOSER_COMMIT }}"
baseurl: "http://osbuild-composer-repos.s3.amazonaws.com/osbuild-composer/{{ rpmrepo_distribution }}/{{ ansible_architecture }}/{{ COMPOSER_COMMIT }}"
enabled: yes
gpgcheck: no
priority: "5"
@ -16,11 +16,13 @@
- rpmrepo
yum_repository:
name: "osbuild"
description: "osbuild commit {{ OSBUILD_COMMIT }}"
baseurl: "http://osbuild-composer-repos.s3-website.us-east-2.amazonaws.com/osbuild/rhel-8-cdn/x86_64/{{ OSBUILD_COMMIT }}"
description: "osbuild commit {{ osbuild_commit }}"
baseurl: "http://osbuild-composer-repos.s3-website.us-east-2.amazonaws.com/osbuild/{{ rpmrepo_distribution }}/{{ ansible_architecture }}/{{ osbuild_commit }}"
enabled: yes
gpgcheck: no
priority: "5"
# if osbuild_commit is not defined, osbuild from distribution repositories is installed
when: osbuild_commit is defined
# We need EPEL for monit
- name: Add EPEL
@ -28,6 +30,7 @@
name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
state: present
disable_gpg_check: yes
when: ansible_distribution == 'RedHat'
- name: Upgrade all packages
package:
@ -55,7 +58,7 @@
- name: Download AWS CLI installer
get_url:
url: https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip
url: "https://awscli.amazonaws.com/awscli-exe-linux-{{ ansible_architecture }}.zip"
dest: /tmp/awscli.zip
register: result
retries: 5

View file

@ -15,9 +15,8 @@ variable "region" {
default = "us-east-1"
}
# Automatically set by environment variables in GitHub Actions.
# Automatically set by environment variables
variable "composer_commit" { type = string }
variable "osbuild_commit" { type = string }
# The name of the resulting AMI and the underlying EBS snapshot
variable "image_name" { type = string }

View file

@ -20,7 +20,6 @@ source "amazon-ebs" "image_builder" {
# Network configuration for the instance building our image.
associate_public_ip_address = true
ssh_interface = "public_ip"
instance_type = "c6a.large"
}
build {
@ -30,6 +29,7 @@ build {
# Use a static RHEL 8.5 Cloud Access Image.
source_ami = "ami-06f1e6f8b3457ae7c"
ssh_username = "ec2-user"
instance_type = "c6a.large"
# Set a name for the resulting AMI.
ami_name = "${var.image_name}"
@ -39,7 +39,6 @@ build {
AppCode = "IMGB-001"
Name = "${var.image_name}"
composer_commit = "${var.composer_commit}"
osbuild_commit = "${var.osbuild_commit}"
os = "rhel"
os_version = "8"
arch = "x86_64"
@ -59,8 +58,8 @@ build {
user = build.User
extra_arguments = [
"-e", "COMPOSER_COMMIT=${var.composer_commit}",
"-e", "OSBUILD_COMMIT=${var.osbuild_commit}",
"--skip-tags", "${var.ansible_skip_tags}",
]
inventory_directory = "${path.root}/ansible/inventory/${source.name}"
}
}