Skip to content

Commit 76456b5

Browse files
bdellegrazienpalm
andauthored
feat(runner): support Ubuntu 24.04 (#4246)
On Ubuntu 24.04 there is another variable `ID_LIKE` that appears in the `/etc/os-release` file. This change fixes the regex to only match `ID` and not `ID_LIKE` closes #4245 --------- Co-authored-by: Niek Palm <[email protected]> Co-authored-by: Niek Palm <[email protected]>
1 parent aebef80 commit 76456b5

File tree

5 files changed

+99
-39
lines changed

5 files changed

+99
-39
lines changed

examples/multi-runner/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
This module shows how to create GitHub action runners with multiple runner configuration together in one deployment. This example has the configurations for the following runner types with the relevant labels supported by them as matchers:
44

55
- Linux ARM64 `["self-hosted", "linux", "arm64", "amazon"]`: Amazon Linux ARM64 non ephemeral runner based on module defaults
6-
- Linux Ubuntu `["self-hosted", "linux", "x64", "ubuntu-latest"]` or `["self-hosted", "linux", "x64", "ubuntu-2204"]`: Ubuntu runners non ephemeral based on a custom start script.
6+
- Linux Ubuntu 24.04 `["self-hosted", "linux", "x64", "ubuntu-latest"]` or `["self-hosted", "linux", "x64", "ubuntu-2404"]`: Ubuntu runners non ephemeral based on a custom start script.
7+
- Linux Ubuntu 22.04 `["self-hosted", "linux", "x64", "ubuntu-2204"]`: Ubuntu runners non ephemeral based on a custom start script.
78
- Linux X64 `["self-hosted", "linux", "x64", "amazon"]`: Amazon X64 Linux runners ephemeral with retry enabled.
89
- Windows X64 `["self-hosted", "windows", "x64", "servercore-2022"]`: Windows X64 Servercore 2022 runners non ephemeral based on a custom start script.
910

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
matcherConfig:
2+
exactMatch: true
3+
labelMatchers:
4+
- [self-hosted, linux, x64, ubuntu-2204]
5+
fifo: true
6+
redrive_build_queue:
7+
enabled: false
8+
maxReceiveCount: null
9+
runner_config:
10+
runner_os: linux
11+
runner_architecture: x64
12+
runner_run_as: ubuntu
13+
runner_name_prefix: ubuntu-2204-x64_
14+
enable_ssm_on_runners: true
15+
credit_specification: standard
16+
instance_types:
17+
- t3a.large
18+
- m5ad.large
19+
- m5a.large
20+
runners_maximum_count: 1
21+
delay_webhook_event: 0
22+
scale_down_schedule_expression: cron(* * * * ? *)
23+
userdata_template: ./templates/user-data.sh
24+
ami:
25+
owners:
26+
- "099720109477" # Canonical's Amazon account ID
27+
filter:
28+
name:
29+
- ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*
30+
state:
31+
- available
32+
block_device_mappings:
33+
- device_name: /dev/sda1
34+
delete_on_termination: true
35+
volume_type: gp3
36+
volume_size: 30
37+
encrypted: true
38+
iops: null
39+
throughput: null
40+
kms_key_id: null
41+
snapshot_id: null
42+
runner_log_files:
43+
- log_group_name: syslog
44+
prefix_log_group: true
45+
file_path: /var/log/syslog
46+
log_stream_name: "{instance_id}"
47+
- log_group_name: user_data
48+
prefix_log_group: true
49+
file_path: /var/log/user-data.log
50+
log_stream_name: "{instance_id}/user_data"
51+
- log_group_name: runner
52+
prefix_log_group: true
53+
file_path: /opt/actions-runner/_diag/Runner_**.log
54+
log_stream_name: "{instance_id}/runner"

examples/multi-runner/templates/runner-configs/linux-x64-ubuntu.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ matcherConfig:
22
exactMatch: true
33
labelMatchers:
44
- [self-hosted, linux, x64, ubuntu-latest]
5-
- [self-hosted, linux, x64, ubuntu-2204]
5+
- [self-hosted, linux, x64, ubuntu-2404]
66
fifo: true
77
redrive_build_queue:
88
enabled: false
@@ -11,7 +11,7 @@ runner_config:
1111
runner_os: linux
1212
runner_architecture: x64
1313
runner_run_as: ubuntu
14-
runner_name_prefix: ubuntu-2204-x64_
14+
runner_name_prefix: ubuntu-2404-x64_
1515
enable_ssm_on_runners: true
1616
credit_specification: standard
1717
instance_types:
@@ -27,7 +27,7 @@ runner_config:
2727
- "099720109477" # Canonical's Amazon account ID
2828
filter:
2929
name:
30-
- ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*
30+
- ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-amd64-server-*
3131
state:
3232
- available
3333
block_device_mappings:

examples/multi-runner/templates/user-data.sh

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,67 +15,72 @@ set -x
1515
${pre_install}
1616

1717
# Install AWS CLI
18-
apt-get update
19-
DEBIAN_FRONTEND=noninteractive apt-get install -y \
20-
awscli \
18+
apt-get -q update
19+
DEBIAN_FRONTEND=noninteractive apt-get install -q -y \
2120
build-essential \
21+
ca-certificates \
2222
curl \
2323
git \
2424
iptables \
2525
jq \
26+
systemd-container \
2627
uidmap \
2728
unzip \
2829
wget
2930

31+
install -m 0755 -d /etc/apt/keyrings
32+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
33+
chmod a+r /etc/apt/keyrings/docker.asc
34+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" > /etc/apt/sources.list.d/docker.list
35+
apt-get -q update
36+
apt-get -q -y install docker-ce docker-ce-cli containerd.io docker-ce-rootless-extras docker-buildx-plugin docker-compose-plugin
37+
systemctl disable --now docker.socket docker.service
38+
39+
# avoid /tmp, might be mounted no-exec
40+
curl -fsSL -o "awscliv2.zip" "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"
41+
unzip -q awscliv2.zip
42+
aws/install
43+
rm -rf aws awscliv2.zip
44+
3045
user_name=ubuntu
3146
user_id=$(id -ru $user_name)
3247

3348
# install and configure cloudwatch logging agent
34-
wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb
35-
dpkg -i -E ./amazon-cloudwatch-agent.deb
36-
amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c ssm:${ssm_key_cloudwatch_agent_config}
49+
curl -fsSL -o "/tmp/amazon-cloudwatch-agent.deb" https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb
50+
dpkg -i -E /tmp/amazon-cloudwatch-agent.deb
51+
rm -f /tmp/amazon-cloudwatch-agent.deb
52+
amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c "ssm:${ssm_key_cloudwatch_agent_config}"
3753

3854
# configure systemd for running service in users accounts
39-
cat >/etc/systemd/[email protected] <<-EOF
40-
41-
[Unit]
42-
Description=User Manager for UID %i
43-
After=user-runtime-dir@%i.service
44-
Wants=user-runtime-dir@%i.service
45-
46-
[Service]
47-
LimitNOFILE=infinity
48-
LimitNPROC=infinity
49-
User=%i
50-
PAMName=systemd-user
51-
Type=notify
52-
53-
[Install]
54-
WantedBy=default.target
55-
55+
mkdir -p /etc/systemd/system/user-$user_id.slice.d
56+
cat > /etc/systemd/system/user-$user_id.slice.d/resources.conf <<- EOF
57+
[Slice]
58+
TasksMax=infinity
5659
EOF
57-
58-
echo export XDG_RUNTIME_DIR=/run/user/$user_id >>/home/$user_name/.bashrc
60+
mkdir -p /home/$user_name/.config/systemd/
61+
cat > /home/$user_name/.config/systemd/user.conf <<- EOF
62+
[Manager]
63+
DefaultLimitNOFILE=infinity
64+
DefaultLimitNPROC=infinity
65+
EOF
66+
chown $user_name:$user_name /home/$user_name/.config/systemd/user.conf /home/$user_name/.config/systemd /home/$user_name/.config/
5967

6068
systemctl daemon-reload
61-
systemctl enable [email protected]
62-
systemctl start [email protected]
6369

64-
curl -fsSL https://get.docker.com/rootless >>/opt/rootless.sh && chmod 755 /opt/rootless.sh
65-
su -l $user_name -c /opt/rootless.sh
66-
echo export DOCKER_HOST=unix:///run/user/$user_id/docker.sock >>/home/$user_name/.bashrc
67-
echo export PATH=/home/$user_name/bin:$PATH >>/home/$user_name/.bashrc
70+
echo export XDG_RUNTIME_DIR="/run/user/$user_id" >> "/home/$user_name/.bashrc"
6871

6972
# Run docker service by default
7073
loginctl enable-linger $user_name
71-
su -l $user_name -c "systemctl --user enable docker"
74+
machinectl shell "$user_name@.host" /usr/bin/dockerd-rootless-setuptool.sh install
75+
echo export DOCKER_HOST="unix:///run/user/$user_id/docker.sock" >> "/home/$user_name/.bashrc"
76+
echo export PATH="/home/$user_name/bin:$PATH" >> "/home/$user_name/.bashrc"
7277

7378
${install_runner}
7479

7580
# config runner for rootless docker
7681
cd /opt/actions-runner/
77-
echo DOCKER_HOST=unix:///run/user/$user_id/docker.sock >>.env
78-
echo PATH=/home/$user_name/bin:$PATH >>.env
82+
echo DOCKER_HOST="unix:///run/user/$user_id/docker.sock" >> .env
83+
echo PATH="/home/$user_name/bin:$PATH" >> .env
7984

8085
${post_install}
8186

modules/runners/templates/install-runner.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ tar xzf ./$file_name
4242
echo "Delete tar file"
4343
rm -rf $file_name
4444

45-
os_id=$(awk -F= '/^ID/{print $2}' /etc/os-release)
45+
os_id=$(awk -F= '/^ID=/{print $2}' /etc/os-release)
4646
echo OS: $os_id
4747

4848
# Install libicu on non-ubuntu

0 commit comments

Comments
 (0)