From 43872a13e4d4eede74836591f20580728c6778f4 Mon Sep 17 00:00:00 2001 From: David Galloway Date: Wed, 23 Oct 2019 09:18:49 -0400 Subject: [PATCH] Add jenkins-build user to mock group during slave setup Instead of during each individual job Signed-off-by: David Galloway --- ansible/examples/slave.yml | 8 ++++++++ ansible/examples/slave_libvirt.yml | 8 ++++++++ ansible/examples/slave_libvirt_static.yml | 8 ++++++++ ansible/examples/slave_static.yml | 8 ++++++++ ceph-ansible-rpm/build/build | 4 ---- ceph-medic-release/build/build_rpm | 4 ---- ceph-medic-rpm/build/build | 4 ---- 7 files changed, 32 insertions(+), 12 deletions(-) diff --git a/ansible/examples/slave.yml b/ansible/examples/slave.yml index 320f5426..aeba5e06 100644 --- a/ansible/examples/slave.yml +++ b/ansible/examples/slave.yml @@ -156,6 +156,7 @@ - rpmdevtools - openssl-devel - libffi-devel + - mock when: ansible_os_family == "RedHat" - name: install packages from epel (<=7) @@ -268,6 +269,13 @@ (ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'precise') or (ansible_distribution == 'Debian' and ansible_distribution_release == 'wheezy') + - name: "add {{ jenkins_user }} to mock group" + user: + name: "{{ jenkins_user }}" + groups: mock + append: yes + when: ansible_os_family == "RedHat" + - name: ensure the rpmmacros file exists to fix centos builds file: path: "/home/{{ jenkins_user }}/.rpmmacros" diff --git a/ansible/examples/slave_libvirt.yml b/ansible/examples/slave_libvirt.yml index 03ecccfe..4d800926 100644 --- a/ansible/examples/slave_libvirt.yml +++ b/ansible/examples/slave_libvirt.yml @@ -131,6 +131,7 @@ - openssl-devel - redhat-lsb-core - iproute + - mock when: ansible_os_family == "RedHat" - name: install packages from epel @@ -167,6 +168,13 @@ state: directory owner: "{{ jenkins_user }}" + - name: "add {{ jenkins_user }} to mock group" + user: + name: "{{ jenkins_user }}" + groups: mock + append: yes + when: ansible_os_family == "RedHat" + - name: Create .ssh directory file: path: "/home/{{ jenkins_user }}/.ssh" diff --git a/ansible/examples/slave_libvirt_static.yml b/ansible/examples/slave_libvirt_static.yml index 76c77b92..a6ace7ad 100644 --- a/ansible/examples/slave_libvirt_static.yml +++ b/ansible/examples/slave_libvirt_static.yml @@ -121,6 +121,7 @@ - python-virtualenv - openssl-devel - redhat-lsb-core + - mock when: ansible_os_family == "RedHat" - name: install packages from epel @@ -158,6 +159,13 @@ state: directory owner: "{{ jenkins_user }}" + - name: "add {{ jenkins_user }} to mock group" + user: + name: "{{ jenkins_user }}" + groups: mock + append: yes + when: ansible_os_family == "RedHat" + - name: Create .ssh directory file: path: "/home/{{ jenkins_user }}/.ssh" diff --git a/ansible/examples/slave_static.yml b/ansible/examples/slave_static.yml index cfb1e8ad..28493504 100644 --- a/ansible/examples/slave_static.yml +++ b/ansible/examples/slave_static.yml @@ -125,6 +125,7 @@ - rpmdevtools - openssl-devel - libffi-devel + - mock when: - ansible_os_family == "RedHat" @@ -233,6 +234,13 @@ (ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'precise') or (ansible_distribution == 'Debian' and ansible_distribution_release == 'wheezy') + - name: "add {{ jenkins_user }} to mock group" + user: + name: "{{ jenkins_user }}" + groups: mock + append: yes + when: ansible_os_family == "RedHat" + - name: ensure the rpmmacros file exists to fix centos builds file: path="/home/{{ jenkins_user }}/.rpmmacros" owner="{{ jenkins_user }}" state=touch diff --git a/ceph-ansible-rpm/build/build b/ceph-ansible-rpm/build/build index 1f642545..907c2042 100644 --- a/ceph-ansible-rpm/build/build +++ b/ceph-ansible-rpm/build/build @@ -12,10 +12,6 @@ PACKAGE=${JOB_NAME%-rpm} sudo yum -y install epel-release sudo yum -y install fedpkg mock -# Add the Jenkins slave UID to the mock group. -sudo usermod -a -G mock $(whoami) -newgrp mock - # Attempt the build. If it fails, print the mock logs to STDOUT. make rpm || ( tail -n +1 {root,build}.log && exit 1 ) diff --git a/ceph-medic-release/build/build_rpm b/ceph-medic-release/build/build_rpm index 4d528230..1d87ebea 100644 --- a/ceph-medic-release/build/build_rpm +++ b/ceph-medic-release/build/build_rpm @@ -10,10 +10,6 @@ set -ex sudo yum -y install epel-release sudo yum -y install fedpkg mock -# Add the Jenkins slave UID to the mock group. -sudo usermod -a -G mock $(whoami) -newgrp mock - # Attempt the build. If it fails, print the mock logs to STDOUT. make rpm || ( tail -n +1 {root,build}.log && exit 1 ) diff --git a/ceph-medic-rpm/build/build b/ceph-medic-rpm/build/build index 1f642545..907c2042 100644 --- a/ceph-medic-rpm/build/build +++ b/ceph-medic-rpm/build/build @@ -12,10 +12,6 @@ PACKAGE=${JOB_NAME%-rpm} sudo yum -y install epel-release sudo yum -y install fedpkg mock -# Add the Jenkins slave UID to the mock group. -sudo usermod -a -G mock $(whoami) -newgrp mock - # Attempt the build. If it fails, print the mock logs to STDOUT. make rpm || ( tail -n +1 {root,build}.log && exit 1 ) -- 2.39.5