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

@ -0,0 +1,101 @@
---
- name: Build osbuild rpms
become: yes
remote_user: ec2-user
hosts: rpmbuilder
tasks:
- name: Add EPEL
dnf:
name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
state: present
disable_gpg_check: yes
- name: Upgrade all packages
package:
name: "*"
state: latest
register: result
retries: 5
until: result is success
- name: Create rpmbuild directory
file:
path: "{{ item }}"
state: directory
with_items:
- /tmp/rpmbuild
- /tmp/rpmbuild/SOURCES
- /tmp/rpmbuild/RPMS
- name: Download osbuild-composer archive
get_url:
url: "https://github.com/osbuild/osbuild-composer/archive/{{ COMPOSER_COMMIT }}.tar.gz"
dest: "/tmp/rpmbuild/SOURCES/osbuild-composer-{{ COMPOSER_COMMIT }}.tar.gz"
- name: Download osbuild-composer spec
get_url:
url: "https://raw.githubusercontent.com/osbuild/osbuild-composer/{{ COMPOSER_COMMIT }}/osbuild-composer.spec"
dest: /tmp/osbuild-composer.spec
- name: Download osbuild archive
get_url:
url: "https://github.com/osbuild/osbuild/archive/{{ OSBUILD_COMMIT }}.tar.gz"
dest: "/tmp/rpmbuild/SOURCES/osbuild-{{ OSBUILD_COMMIT }}.tar.gz"
- name: Download osbuild spec
get_url:
url: "https://raw.githubusercontent.com/osbuild/osbuild/{{ OSBUILD_COMMIT }}/osbuild.spec"
dest: /tmp/osbuild.spec
- name: Install build tools
package:
name:
- rpm-build
- mock
- createrepo_c
state: present
- name: Make osbuild srpm
command: >-
rpmbuild -bs
--define "commit {{ OSBUILD_COMMIT }}"
--define "_topdir /tmp/rpmbuild"
--define "_srpmfilename %%{NAME}.srpm"
/tmp/osbuild.spec
- name: Mockbuild osbuild
shell: >-
mock
--rebuild
--define "commit {{ OSBUILD_COMMIT }}"
--define "_rpmfilename %%{NAME}.rpm"
--resultdir /tmp/rpmbuild/RPMS
/tmp/rpmbuild/SRPMS/osbuild-*.src.rpm
- name: Make osbuild-composer srpm
command: >-
rpmbuild -bs
--define "commit {{ COMPOSER_COMMIT }}"
--define "_topdir /tmp/rpmbuild"
--define "_srpmfilename %%{NAME}.srpm"
/tmp/osbuild-composer.spec
- name: Mockbuild osbuild-composer
shell: >-
mock
--rebuild
--define "commit {{ COMPOSER_COMMIT }}"
--define "_rpmfilename %%{NAME}.rpm"
--resultdir /tmp/rpmbuild/RPMS
/tmp/rpmbuild/SRPMS/osbuild-composer-*.src.rpm
- name: Create a repository from the artifacts
command: createrepo_c /tmp/rpmbuild/RPMS
- name: Fetch rpms
ansible.posix.synchronize:
mode: pull
src: /tmp/rpmbuild/RPMS
dest: /osbuild-composer/rpmbuild