tools: AppSRE packer build

This commit is contained in:
sanne 2021-12-17 18:21:39 +01:00 committed by Tom Gundersen
parent d967790ea5
commit 71da979c81
9 changed files with 323 additions and 35 deletions

View file

@ -1,6 +1,8 @@
---
- name: Add osbuild-composer repository
tags:
- rpmrepo
yum_repository:
name: "composer"
description: "osbuild-composer commit {{ COMPOSER_COMMIT }}"
@ -10,6 +12,8 @@
priority: "5"
- name: Add osbuild repository
tags:
- rpmrepo
yum_repository:
name: "osbuild"
description: "osbuild commit {{ OSBUILD_COMMIT }}"
@ -42,7 +46,6 @@
package:
name:
- jq
- osbuild-composer-worker
- unzip
- monit
- vector
@ -74,3 +77,48 @@
loop:
- /tmp/awscli.zip
- /tmp/aws
- name: Create rpmbuild directory
tags:
- rpmcopy
file:
path: "{{ item }}"
state: directory
with_items:
- /tmp/rpmbuild
- /tmp/rpmbuild/RPMS
- name: Push rpms
tags:
- rpmcopy
ansible.posix.synchronize:
mode: push
src: "{{ playbook_dir }}/roles/common/files/rpmbuild/RPMS"
dest: /tmp/rpmbuild
- name: Add repo config
tags:
- rpmcopy
copy:
dest: /etc/yum.repos.d/osbuild.repo
content: |
[osbuild]
name=osbuild
baseurl=file:///tmp/rpmbuild/RPMS
enabled=1
gpgcheck=0
priority=100
- name: Install worker rpm
package:
name:
- osbuild-composer-worker
state: present
- name: Cleanup rpmbuild dir
file:
path: "{{ item }}"
state: absent
with_items:
- /tmp/rpmbuild
- /etc/yum.repos.d/osbuild.repo

View file

@ -39,7 +39,6 @@ source "amazon-ebs" "image_builder" {
# Network configuration for the instance building our image.
associate_public_ip_address = true
security_group_ids = ["sg-04bbbb35"]
ssh_interface = "public_ip"
ssh_username = "ec2-user"
instance_type = "c5.large"
@ -50,9 +49,11 @@ build {
provisioner "ansible" {
playbook_file = "${path.root}/ansible/playbook.yml"
user = "ec2-user"
extra_arguments = [
"-e", "COMPOSER_COMMIT=${var.composer_commit}",
"-e", "OSBUILD_COMMIT=${var.osbuild_commit}",
"--skip-tags", "${var.ansible_skip_tags}",
]
}
}

View file

@ -15,3 +15,9 @@ variable "osbuild_commit" { type = string }
# The name of the resulting AMI and the underlying EBS snapshot
variable "image_name" { type = string }
# Skip ansible tags
variable "ansible_skip_tags" {
type = string
default = ""
}