Skip to content

Commit ad11ee3

Browse files
authored
ansible: prepare runner provisioning for Ubuntu bare-metal hosts (#223)
Add support for provisioning Ubuntu 24.04 (Noble) bare-metal AWS hosts as runners, alongside the existing Amazon Linux 2 (RedHat family) and s390x LinuxONE (Debian family) hosts, without changing behavior for either. - base: start (and enable) the docker service on Debian hosts, mirroring the RedHat path. On Ubuntu cloud-init first boot docker.io may not be up yet when qemu-user-static / the runner units need it; idempotent on s390x. - base/runner: make the apt installs resilient to first-boot dpkg-lock contention from apt-daily/unattended-upgrades (lock_timeout + retries). - runner: derive runner names from the EC2 instance ID on all EC2 hosts (system_vendor == "Amazon EC2"), not just Amazon Linux, so Ubuntu EC2 hosts get stable, collision-free names. Non-EC2 hosts (s390x) still skip the metadata lookup; the retained Amazon-distribution clause keeps AL2 behavior identical. - add ansible/requirements.yml (community.docker, amazon.aws) and document it, for the manual operator workflow / ansible-core installs. - fix stale runner_libbpf_ci_repo_branch defaults (master -> main). Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
1 parent 774eff8 commit ad11ee3

6 files changed

Lines changed: 41 additions & 7 deletions

File tree

ansible/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ sudo dnf install -y ansible
55
```
66

77

8+
## Required collections
9+
10+
The playbook uses modules from `community.docker` (`docker_login`) and `amazon.aws`
11+
(`ec2_metadata_facts`). The `ansible` metapackage bundles these; if you installed
12+
`ansible-core` only, install them explicitly:
13+
14+
```
15+
ansible-galaxy collection install -r ansible/requirements.yml
16+
```
17+
18+
819
## Inventory
920

1021
The [inventory](https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html) is where we define our hosts, hostgroup, possibly variable...

ansible/inventory_example.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ all:
6161
vars:
6262
ansible_ssh_common_args: -o 'ProxyCommand ......'
6363
runner_libbpf_ci_repo_url: https://github.com/libbpf/ci
64-
runner_libbpf_ci_repo_branch: master
64+
runner_libbpf_ci_repo_branch: main
6565
runner_gh_apps:
6666
- name: kernel-patches-runner
6767
id: a-github-app-id

ansible/requirements.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
collections:
3+
- name: community.docker
4+
- name: amazon.aws

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,20 @@
55
state: present
66
name: "{{ base_packages }}"
77
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
813
tags: [install]
914

15+
- name: Start docker
16+
become: true
17+
service:
18+
name: docker
19+
state: started
20+
enabled: true
21+
1022
- name: Gather the package facts
1123
ansible.builtin.package_facts:
1224

ansible/roles/runner/defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ runner_docker_mount_volume: false
1515
runner_gh_tokens:
1616
owner/repository: gh token for owner/repository
1717
runner_libbpf_ci_repo_url: https://github.com/libbpf/ci.git
18-
runner_libbpf_ci_repo_branch: master
18+
runner_libbpf_ci_repo_branch: main
1919
runner_repo_list:
2020
- {name: owner1/repository1, instances: 2}
2121
- {name: owner1/repository2, instances: 1}

ansible/roles/runner/tasks/main.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
state: present
1919
name: python3-docker
2020
update_cache: yes
21+
lock_timeout: 300
22+
register: python3_docker_install
23+
until: python3_docker_install is succeeded
24+
retries: 30
25+
delay: 10
2126
when: ansible_os_family == 'Debian'
2227

2328
- name: Create runner directory
@@ -75,18 +80,20 @@
7580
set_fact:
7681
runner_name_prefix: "{{ '%s-' | format(runner_prefix) if runner_prefix }}{{ ansible_hostname }}"
7782

78-
# When running on Amazon Linux hosts, we override the runner_name_prefix with the ec2's instance ID.
79-
# When testing in Amazon Linux VMs, the `Load ec2 metadata facts` task will fail and we will fallback
80-
# on using hostname.
81-
- name: Set runner_name_prefix to instance ID for Amazon hosts
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.
88+
- name: Set runner_name_prefix to instance ID for EC2 hosts
8289
block:
8390
- name: Load ec2 metadata facts
8491
amazon.aws.ec2_metadata_facts:
8592

8693
- name: Set runner name prefix with instance ID
8794
set_fact:
8895
runner_name_prefix: "{{ '%s-' | format(runner_prefix) if runner_prefix }}{{ ansible_ec2_instance_id }}"
89-
when: ansible_distribution == 'Amazon'
96+
when: ansible_system_vendor == 'Amazon EC2' or ansible_distribution == 'Amazon'
9097
ignore_errors: yes
9198

9299
- name: Generate runner env

0 commit comments

Comments
 (0)