Skip to content

Commit f0c390d

Browse files
authored
ansible: drop Amazon Linux 2 / RedHat support after Ubuntu migration (#224)
The AWS bare-metal runner fleet has been migrated from Amazon Linux 2 (RedHat family) to Ubuntu 24.04, and AL2 is decommissioned. Every host is now Debian family (Ubuntu EC2 and s390x LinuxONE both use the apt path), so the RedHat/Amazon-conditional code is unreachable. Remove it and collapse the now single-OS base role. - base: delete the RedHat task/vars files and the ansible_os_family include dispatch; fold the package list (incl. docker.io) into defaults and inline the Debian tasks into tasks/main.yml. - runner: drop the "Install docker pip on Amazon Linux" task and the tautological `ansible_os_family == 'Debian'` guard; simplify the EC2 instance-id block to `ansible_system_vendor == 'Amazon EC2'`. - docs: base README is now Debian-only; ansible README install uses apt. amazon.aws (ec2_metadata_facts) and community.docker (docker_login) are still required and kept. The qemu-user-static role is left unchanged: it remains live on the s390x hosts (registers binfmt_misc handlers). Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
1 parent ad11ee3 commit f0c390d

9 files changed

Lines changed: 89 additions & 132 deletions

File tree

ansible/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Install `ansible`
22

33
```
4-
sudo dnf install -y ansible
4+
sudo apt install -y ansible
55
```
66

77

ansible/roles/base/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
## Description
44

5-
This role is used to install basic packages that may be required by any deployment.
5+
This role installs the basic packages required by any deployment on our
6+
Debian-family (Ubuntu / s390x LinuxONE) hosts, starts docker, and performs
7+
common host setup (disabling auditd, and configuring swap on s390x).
68

7-
Some default packages that apply to both RedHat based and Debian based is set in [defaults/main.yml](defaults/main.yml) file.
9+
The package list lives in [defaults/main.yml](defaults/main.yml).
810

9-
Each specific distro that has different package name has a file under [vars/](vars/) with a list of packages (example: `docker.io` for Debian, `podman-docker` for RedHat).
10-
11-
It also provides handler that can be useful to any other roles, such as
11+
It also provides handlers that can be useful to any other roles, such as
1212
- `"reset systemd failed"`: runs `systemctl reset-failed`
1313
- `"reload systemd daemon"`: essentially runs `systemctl daemon-reload`
1414

ansible/roles/base/defaults/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
2-
__base_packages:
2+
base_packages:
33
- curl
44
- git
55
- jq
66
- python3-pip
77
- vim
8+
- docker.io
89

910
# swap config for s390x
1011
swap_file_path: /swapfile

ansible/roles/base/tasks/main.yml

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,76 @@
11
---
2-
- name: Include OS-specific variables.
3-
include_vars: "{{ ansible_os_family }}.yml"
2+
- name: Install base packages
3+
become: true
4+
apt:
5+
state: present
6+
name: "{{ base_packages }}"
7+
update_cache: yes
8+
lock_timeout: 300
9+
register: base_packages_install
10+
until: base_packages_install is succeeded
11+
retries: 30
12+
delay: 10
13+
tags: [install]
414

5-
- name: Build package list
6-
set_fact:
7-
base_packages: "{{ __base_packages + __base_distro_packages }}"
15+
- name: Start docker
16+
become: true
17+
service:
18+
name: docker
19+
state: started
20+
enabled: true
821

9-
- include_tasks: "setup-{{ ansible_os_family }}.yml"
22+
- name: Gather the package facts
23+
ansible.builtin.package_facts:
24+
25+
# Auditd is spamming the logs when the workers are busy.
26+
# Disable for now
27+
- name: Disable auditd
28+
become: true
29+
ansible.builtin.systemd:
30+
name: auditd
31+
state: stopped
32+
enabled: no
33+
masked: yes
34+
when: "'auditd' in ansible_facts.packages"
35+
36+
- name: Set up swap space on s390x
37+
when: ansible_architecture == "s390x"
38+
block:
39+
- name: Check if swap file exists
40+
ansible.builtin.stat:
41+
path: "{{ swap_file_path }}"
42+
register: swap_file
43+
44+
- name: Create swap file
45+
become: true
46+
ansible.builtin.command:
47+
cmd: "fallocate -l {{ swap_file_size }} {{ swap_file_path }}"
48+
creates: "{{ swap_file_path }}"
49+
when: not swap_file.stat.exists
50+
51+
- name: Set swap file permissions
52+
become: true
53+
ansible.builtin.file:
54+
path: "{{ swap_file_path }}"
55+
mode: "0600"
56+
57+
- name: Make swap file
58+
become: true
59+
ansible.builtin.command:
60+
cmd: "mkswap {{ swap_file_path }}"
61+
when: not swap_file.stat.exists
62+
63+
- name: Enable swap file
64+
become: true
65+
ansible.builtin.command:
66+
cmd: "swapon {{ swap_file_path }}"
67+
register: swapon_result
68+
changed_when: swapon_result.rc == 0
69+
failed_when: false
70+
71+
- name: Add swap to fstab
72+
become: true
73+
ansible.builtin.lineinfile:
74+
path: /etc/fstab
75+
line: "{{ swap_file_path }} none swap sw 0 0"
76+
state: present

ansible/roles/base/tasks/setup-Debian.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

ansible/roles/base/tasks/setup-RedHat.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

ansible/roles/base/vars/Debian.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

ansible/roles/base/vars/RedHat.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

ansible/roles/runner/tasks/main.yml

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
---
22

3-
# Used by ansible modules later
4-
- name: Install docker pip on Amazon Linux
5-
become: yes
6-
ansible.builtin.pip:
7-
name:
8-
# AL2 python's version is compiled against openssl 1.0, urllib3>=2.0 needs openssl 1.1.1
9-
- urllib3<2.0
10-
- docker
11-
extra_args: --user
12-
executable: pip3
13-
when: ansible_distribution == 'Amazon'
14-
15-
- name: Install python3-docker on Ubuntu
3+
# Used by ansible modules later (docker_login)
4+
- name: Install python3-docker
165
become: yes
176
ansible.builtin.apt:
187
state: present
@@ -23,7 +12,6 @@
2312
until: python3_docker_install is succeeded
2413
retries: 30
2514
delay: 10
26-
when: ansible_os_family == 'Debian'
2715

2816
- name: Create runner directory
2917
become: yes
@@ -80,11 +68,11 @@
8068
set_fact:
8169
runner_name_prefix: "{{ '%s-' | format(runner_prefix) if runner_prefix }}{{ ansible_hostname }}"
8270

83-
# On EC2 hosts (Amazon Linux metal and Ubuntu metal alike) we override the runner_name_prefix
84-
# with the ec2's instance ID for stable, collision-free runner names. Non-EC2 hosts (e.g. s390x
85-
# LinuxONE, vendor "IBM") are skipped so we never block on the 169.254.169.254 metadata endpoint.
86-
# If amazon.aws is missing or the metadata endpoint is unreachable, `ignore_errors` lets us fall
87-
# back to the hostname-based prefix set above.
71+
# On EC2 hosts we override the runner_name_prefix with the ec2's instance ID for stable,
72+
# collision-free runner names. Non-EC2 hosts (e.g. s390x LinuxONE, vendor "IBM") are skipped so
73+
# we never block on the 169.254.169.254 metadata endpoint. If amazon.aws is missing or the
74+
# metadata endpoint is unreachable, `ignore_errors` lets us fall back to the hostname-based
75+
# prefix set above.
8876
- name: Set runner_name_prefix to instance ID for EC2 hosts
8977
block:
9078
- name: Load ec2 metadata facts
@@ -93,7 +81,7 @@
9381
- name: Set runner name prefix with instance ID
9482
set_fact:
9583
runner_name_prefix: "{{ '%s-' | format(runner_prefix) if runner_prefix }}{{ ansible_ec2_instance_id }}"
96-
when: ansible_system_vendor == 'Amazon EC2' or ansible_distribution == 'Amazon'
84+
when: ansible_system_vendor == 'Amazon EC2'
9785
ignore_errors: yes
9886

9987
- name: Generate runner env

0 commit comments

Comments
 (0)