osbuildexecutor/aws.ec2: set hostname of executor via cloud-init

This way much more of the journal will be captured under the new
hostname.
This commit is contained in:
Sanne Raymaekers 2024-06-20 13:40:07 +02:00
parent 14052e25db
commit 2a621521a8
7 changed files with 29 additions and 15 deletions

View file

@ -6,6 +6,7 @@ After=cloud-final.service
[Service]
Type=oneshot
ExecStart=/usr/local/libexec/worker-initialization-scripts/set_executor_hostname.sh
ExecStart=/usr/local/libexec/worker-initialization-scripts/worker_executor.sh
[Install]

View file

@ -0,0 +1,11 @@
#!/bin/bash
set -euo pipefail
source /tmp/cloud_init_vars
if [[ -z "$OSBUILD_EXECUTOR_HOSTNAME" ]]; then
echo "OSBUILD_EXECUTOR_HOSTNAME not set, skipping."
exit 0
fi
echo "Setting system hostname to $OSBUILD_EXECUTOR_HOSTNAME."
hostnamectl set-hostname "$OSBUILD_EXECUTOR_HOSTNAME"