Skip to content

Commit f1e8449

Browse files
ondrejbudaicroissanne
authored andcommitted
rpmbuild.yml: don't run mock as root
osbuild/osbuild@a52e256 introduced running osbuild's test in the %check phase of an rpm build. A lot of osbuild's tests are gated on $UID == 0 (i.e. running as root). Thus, if $UID != 0, then a lot of tests are intentionally skipped. RPM building setups (koji, mockbuild.sh in this repository) usually run mock as a non-root user, thus the tests get skipped. However, this script actually runs mock as root, and thus these tests don't get skipped, causing a lot of failures because there are missing tools in the buildroot, some rootful tests require networking, or they cannot run in an environment missing certain privileges. This commit changes the playbook to run tasks as root only when they require it (subscription-manager, dnf). Mock is no longer run as root, aligning the rpm building process to what's common in other setups.
1 parent 3c0f341 commit f1e8449

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tools/appsre-ansible/rpmbuild.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
- name: Build osbuild rpms
3-
become: yes
43
remote_user: ec2-user
54
hosts: rpmbuilder
65
gather_facts: no
@@ -15,6 +14,7 @@
1514
ansible.builtin.setup:
1615

1716
- name: Add EPEL
17+
become: yes
1818
dnf:
1919
state: present
2020
name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
@@ -35,6 +35,7 @@
3535
3636
# RHEL mock templates don't work on RHUI, they use the CDN repos
3737
- name: Subscribe
38+
become: yes
3839
register: result
3940
retries: 5
4041
until: result is success
@@ -43,6 +44,7 @@
4344
org_id: "{{ RH_ORG_ID }}"
4445

4546
- name: Upgrade all packages
47+
become: yes
4648
package:
4749
name: "*"
4850
state: latest
@@ -96,6 +98,7 @@
9698
dest: /home/ec2-user/osbuild.spec
9799

98100
- name: Install build tools
101+
become: yes
99102
retries: 5
100103
delay: 20
101104
register: result
@@ -107,6 +110,17 @@
107110
- createrepo_c
108111
state: present
109112

113+
- name: Add ec2-user to mock group
114+
become: yes
115+
ansible.builtin.user:
116+
name: "{{ ansible_user }}"
117+
groups:
118+
- mock
119+
append: yes
120+
121+
- name: Reset connection to ensure the user is in the mock group
122+
ansible.builtin.meta: reset_connection
123+
110124
- name: Make osbuild srpm
111125
retries: 5
112126
delay: 20
@@ -178,6 +192,7 @@
178192
dest: /osbuild-composer/templates/packer/ansible/roles/common/files/rpmbuild/{{ ansible_architecture }}
179193

180194
- name: Unregister
195+
become: yes
181196
retries: 5
182197
delay: 20
183198
register: result

0 commit comments

Comments
 (0)