Skip to content

Commit a54b45c

Browse files
authored
ansible: update RHEL 8 container (#4231)
Register the RHEL 8 containers with our RHEL subscription so that we can install older versions of some packages (e.g. `gcc-toolset-10`) without having to pick individual RPMs from another Linux distribution. Install clang 19 instead of 20. Add Rust toolchain. Set the hostname of the containers when building and running them to make it easier to correlate the containers to the agent definition in Jenkins and Ansible sources. Refs: #4225 (comment)
1 parent fb93afc commit a54b45c

7 files changed

Lines changed: 59 additions & 31 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
3+
argument_specs:
4+
main:
5+
short_description: set up hosts for Docker containers

ansible/roles/docker/meta/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
3+
dependencies:
4+
- role: read-secrets

ansible/roles/docker/tasks/main.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,26 @@
175175
- "{{ containers }}"
176176
when: containers is defined and item.os.find('_arm_cross') != -1
177177

178-
- name: "docker : build image"
178+
- name: "docker : create RHEL secrets file"
179+
ansible.builtin.template:
180+
src: "{{ role_path }}/templates/rhel_secrets.j2"
181+
dest: /root/docker-container-{{ item.name }}/secrets.txt
182+
mode: "0600"
183+
with_items:
184+
- "{{ containers }}"
185+
when: containers is defined and (item.os == 'rhel8' or item.os == 'ubi81')
186+
187+
- name: "docker : build images"
179188
command: docker build -t node-ci:{{ item.name }} /root/docker-container-{{ item.name }}/
180189
with_items:
181190
- "{{ containers }}"
182-
when: containers is defined
191+
when: containers is defined and item.os != 'rhel8' and item.os != 'ubi81'
192+
193+
- name: "docker : build RHEL images"
194+
command: docker build --build-arg BUILDKIT_SANDBOX_HOSTNAME={{ item.name | regex_replace('_', '--') }} -t node-ci:{{ item.name }} /root/docker-container-{{ item.name }}/
195+
with_items:
196+
- "{{ containers }}"
197+
when: containers is defined and (item.os == 'rhel8' or item.os == 'ubi81')
183198

184199
- name: "docker : generate and copy init script"
185200
template:

ansible/roles/docker/templates/jenkins.service.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ WantedBy=multi-user.target
99
[Service]
1010
Type=simple
1111
User=root
12-
ExecStart=/usr/bin/docker run --init --rm -v /home/{{ server_user }}/{{ item.name }}/:/home/{{ server_user }} -v /home/{{ server_user }}/.ccache/:/home/{{ server_user }}/.ccache --name node-ci-{{ item.name }} --sysctl net.ipv4.ip_unprivileged_port_start=1024 node-ci:{{ item.name }}
12+
ExecStart=/usr/bin/docker run --init --rm -h {{ item.name | regex_replace('_', '--') }} -v /home/{{ server_user }}/{{ item.name }}/:/home/{{ server_user }} -v /home/{{ server_user }}/.ccache/:/home/{{ server_user }}/.ccache --name node-ci-{{ item.name }} --sysctl net.ipv4.ip_unprivileged_port_start=1024 node-ci:{{ item.name }}
1313
ExecStop=/usr/bin/docker stop -t 5 node-ci-{{ item.name }}
1414
Restart=always
1515
RestartSec=30

ansible/roles/docker/templates/rhel8.Dockerfile.j2

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,32 @@ ENV OSVARIANT docker
1212
ENV DESTCPU {{ arch }}
1313
ENV ARCH {{ arch }}
1414

15+
# Register with RHEL subscription to be able to install older versions of packages.
16+
COPY secrets.txt /secrets.txt
1517
# ccache is not in the default repositories so get it from EPEL 8.
16-
RUN dnf install --disableplugin=subscription-manager -y \
17-
https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \
18-
&& dnf update --disableplugin=subscription-manager -y \
19-
&& dnf install --disableplugin=subscription-manager -y \
18+
RUN . /secrets.txt \
19+
&& sed -i 's/\(def in_container():\)/\1\n return False/g' /usr/lib64/python*/*-packages/rhsm/config.py \
20+
&& subscription-manager register --org $RH_ORG --activationkey $RH_ACTIVATION_KEY \
21+
&& rm -rf /secrets.txt \
22+
&& dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \
23+
&& dnf update -y \
24+
&& dnf install -y \
2025
ccache \
21-
clang \
2226
gcc-c++ \
27+
gcc-toolset-10 \
2328
gcc-toolset-12 \
29+
gcc-toolset-14-libatomic-devel \
2430
git \
2531
java-17-openjdk-headless \
32+
llvm-toolset-19.1.7 \
2633
make \
2734
python3.12 \
2835
python3.12-pip \
2936
procps-ng \
37+
rust-toolset-1.84.1 \
3038
xz \
31-
&& dnf --disableplugin=subscription-manager clean all
32-
33-
RUN dnf install --disableplugin=subscription-manager -y \
34-
https://repo.almalinux.org/almalinux/8/AppStream/{{ ansible_architecture }}/os/Packages/gcc-toolset-14-libatomic-devel-14.2.1-1.1.el8_10.{{ ansible_architecture }}.rpm \
35-
http://vault.centos.org/centos/8-stream/AppStream/{{ ansible_architecture }}/os/Packages/gcc-toolset-10-binutils-2.35-11.el8.{{ ansible_architecture }}.rpm \
36-
http://vault.centos.org/centos/8-stream/AppStream/{{ ansible_architecture }}/os/Packages/gcc-toolset-10-gcc-10.3.1-1.2.el8_5.{{ ansible_architecture }}.rpm \
37-
http://vault.centos.org/centos/8-stream/AppStream/{{ ansible_architecture }}/os/Packages/gcc-toolset-10-gcc-c++-10.3.1-1.2.el8_5.{{ ansible_architecture }}.rpm \
38-
http://vault.centos.org/centos/8-stream/AppStream/{{ ansible_architecture }}/os/Packages/gcc-toolset-10-libstdc++-devel-10.3.1-1.2.el8_5.{{ ansible_architecture }}.rpm \
39-
http://vault.centos.org/centos/8-stream/AppStream/{{ ansible_architecture }}/os/Packages/gcc-toolset-10-runtime-10.1-0.el8.{{ ansible_architecture }}.rpm
39+
&& dnf clean all \
40+
&& subscription-manager unregister
4041

4142
RUN groupadd -r -g {{ server_user_gid.stdout_lines[0] }} {{ server_user }} \
4243
&& adduser -r -m -d /home/{{ server_user }}/ \
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
RH_ACTIVATION_KEY={{ secrets.rh_activationkey }}
2+
RH_ORG={{ secrets.rh_org }}

ansible/roles/docker/templates/ubi81.Dockerfile.j2

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,32 @@ ENV OSVARIANT docker
1212
ENV DESTCPU {{ arch }}
1313
ENV ARCH {{ arch }}
1414

15+
# Register with RHEL subscription to be able to install older versions of packages.
16+
COPY secrets.txt /secrets.txt
1517
# ccache is not in the default repositories so get it from EPEL 8.
16-
RUN dnf install --disableplugin=subscription-manager -y \
17-
https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \
18-
&& dnf update --disableplugin=subscription-manager -y \
19-
&& dnf install --disableplugin=subscription-manager -y \
18+
RUN chmod u+x /secrets.txt && . /secrets.txt \
19+
&& sed -i 's/\(def in_container():\)/\1\n return False/g' /usr/lib64/python*/*-packages/rhsm/config.py \
20+
&& subscription-manager register --org $RH_ORG --activationkey $RH_ACTIVATION_KEY \
21+
&& rm -rf /secrets.txt \
22+
&& dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \
23+
&& dnf update -y \
24+
&& dnf install -y \
2025
ccache \
21-
clang \
2226
gcc-c++ \
27+
gcc-toolset-10 \
2328
gcc-toolset-12 \
29+
gcc-toolset-14-libatomic-devel \
2430
git \
2531
java-17-openjdk-headless \
32+
llvm-toolset-19.1.7 \
2633
make \
2734
python3.12 \
2835
python3.12-pip \
2936
openssl-devel \
3037
procps-ng \
31-
&& dnf --disableplugin=subscription-manager clean all
32-
33-
RUN dnf install --disableplugin=subscription-manager -y \
34-
https://repo.almalinux.org/almalinux/8/AppStream/{{ ansible_architecture }}/os/Packages/gcc-toolset-14-libatomic-devel-14.2.1-1.1.el8_10.{{ ansible_architecture }}.rpm \
35-
http://vault.centos.org/centos/8-stream/AppStream/{{ ansible_architecture }}/os/Packages/gcc-toolset-10-binutils-2.35-11.el8.{{ ansible_architecture }}.rpm \
36-
http://vault.centos.org/centos/8-stream/AppStream/{{ ansible_architecture }}/os/Packages/gcc-toolset-10-gcc-10.3.1-1.2.el8_5.{{ ansible_architecture }}.rpm \
37-
http://vault.centos.org/centos/8-stream/AppStream/{{ ansible_architecture }}/os/Packages/gcc-toolset-10-gcc-c++-10.3.1-1.2.el8_5.{{ ansible_architecture }}.rpm \
38-
http://vault.centos.org/centos/8-stream/AppStream/{{ ansible_architecture }}/os/Packages/gcc-toolset-10-libstdc++-devel-10.3.1-1.2.el8_5.{{ ansible_architecture }}.rpm \
39-
http://vault.centos.org/centos/8-stream/AppStream/{{ ansible_architecture }}/os/Packages/gcc-toolset-10-runtime-10.1-0.el8.{{ ansible_architecture }}.rpm
38+
rust-toolset-1.84.1 \
39+
&& dnf clean all \
40+
&& subscription-manager unregister
4041

4142
RUN groupadd -r -g {{ server_user_gid.stdout_lines[0] }} {{ server_user }} \
4243
&& adduser -r -m -d /home/{{ server_user }}/ \

0 commit comments

Comments
 (0)