debian-forge-composer/templates/packer/ansible/roles/common/tasks/packages.yml
Sanne Raymaekers 13aae7d532 templates/packer: invert tag logic
With the rpmcopy or rpmrepo_osbuild tags, the `Install worker rpm` stage
got skipped on RHEL and CI. Invert the tag logic and use `--tags`
instead of `--skip-tags`.
2024-05-21 09:40:11 +02:00

152 lines
3.3 KiB
YAML

---
- name: Add osbuild-composer repository
tags:
- ci
yum_repository:
name: "composer"
description: "osbuild-composer commit {{ COMPOSER_COMMIT }}"
baseurl: "http://osbuild-composer-repos.s3.amazonaws.com/osbuild-composer/{{ rpmrepo_distribution }}/{{ ansible_architecture }}/{{ COMPOSER_COMMIT }}"
enabled: yes
gpgcheck: no
priority: "5"
- name: Add osbuild repository
tags:
- ci
- fedora
yum_repository:
name: "osbuild"
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
- name: Upgrade all packages
tags:
- always
package:
name: "*"
state: latest
register: result
retries: 5
until: result is success
- name: Add Vector repo
tags:
- always
copy:
src: "{{ playbook_dir }}/roles/common/files/timber-vector.repo"
dest: /etc/yum.repos.d/
- name: Install required packages
tags:
- always
package:
name:
- jq
- unzip
- vector
register: result
retries: 5
until: result is success
- name: Download AWS CLI installer
tags:
- always
get_url:
url: "https://awscli.amazonaws.com/awscli-exe-linux-{{ ansible_architecture }}.zip"
dest: /tmp/awscli.zip
register: result
retries: 5
until: result is success
- name: Unpack AWS CLI installer
tags:
- always
unarchive:
src: /tmp/awscli.zip
dest: /tmp
remote_src: yes
- name: Run AWS installer
tags:
- always
command: /tmp/aws/install
- name: Cleanup AWS installer
tags:
- always
file:
path: "{{ item }}"
state: absent
loop:
- /tmp/awscli.zip
- /tmp/aws
- name: Create rpmbuild directory
tags:
- rhel
file:
path: "{{ item }}"
state: directory
with_items:
- /tmp/rpmbuild
- /tmp/rpmbuild/RPMS
- name: Push rpms
tags:
- rhel
ansible.posix.synchronize:
mode: push
src: "{{ playbook_dir }}/roles/common/files/rpmbuild/{{ ansible_architecture }}/RPMS"
dest: /tmp/rpmbuild
- name: Add repo config
tags:
- rhel
copy:
dest: /etc/yum.repos.d/osbuild.repo
content: |
[osbuild]
name=osbuild
baseurl=file:///tmp/rpmbuild/RPMS
enabled=1
gpgcheck=0
priority=1
- name: Install worker rpm
tags:
- ci
- rhel
package:
name:
- osbuild-composer-worker
state: present
- name: Install worker rpm from copr
tags:
- fedora
shell: |
dnf copr enable -y @osbuild/osbuild-composer
COMPOSER_COMMIT_SHORT=$(echo {{ COMPOSER_COMMIT }} | head -c 9)
COMPOSER_RPMS=$(dnf search -q --showduplicates osbuild-composer | grep -E "osbuild-composer-worker-[0-9]+.*g$COMPOSER_COMMIT_SHORT.*{{ ansible_architecture }}" | cut -f 1 -d ':')
if [ -z $COMPOSER_RPMS ]; then
echo $COMPOSER_COMMIT_SHORT worker rpms not available for on @osbuild/osbuild-composer copr
exit 1
fi
echo "installing rpms $COMPOSER_RPMS"
dnf install -y $COMPOSER_RPMS
- name: Cleanup rpmbuild dir
tags:
- always
file:
path: "{{ item }}"
state: absent
with_items:
- /tmp/rpmbuild
- /etc/yum.repos.d/osbuild.repo