-
Notifications
You must be signed in to change notification settings - Fork 106
/
afterburn-hostname.service
38 lines (35 loc) · 1.67 KB
/
afterburn-hostname.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
[Unit]
Description=Afterburn Hostname
Documentation=https://coreos.github.io/afterburn/
# These platforms do not provide the hostname via DHCP
# options, thus it needs to be fetched from the metadata
# and statically applied on first-boot.
ConditionKernelCommandLine=|ignition.platform.id=aliyun
ConditionKernelCommandLine=|ignition.platform.id=azure
ConditionKernelCommandLine=|ignition.platform.id=azurestack
ConditionKernelCommandLine=|ignition.platform.id=digitalocean
ConditionKernelCommandLine=|ignition.platform.id=exoscale
ConditionKernelCommandLine=|ignition.platform.id=hetzner
ConditionKernelCommandLine=|ignition.platform.id=ibmcloud
ConditionKernelCommandLine=|ignition.platform.id=kubevirt
ConditionKernelCommandLine=|ignition.platform.id=proxmoxve
ConditionKernelCommandLine=|ignition.platform.id=scaleway
ConditionKernelCommandLine=|ignition.platform.id=vultr
# We order this service after sysroot has been mounted
# but before ignition-files stage has run, so ignition can
# overwrite the configured hostname with e.g. a static one
# Also order after ignition-remount-sysroot just for
# safety for systems that mount /sysroot ro
After=initrd-root-fs.target
Before=ignition-files.service
OnFailure=emergency.target
OnFailureJobMode=isolate
[Service]
ExecStart=/usr/bin/afterburn --cmdline --hostname=/sysroot/etc/hostname
# Add hack to mark the file as needing relabelling, as the hostname
# file dropped by afterburn will be unlabelled causing SELinux denials.
# see: https://github.com/coreos/ignition/issues/635
ExecStart=/bin/sh -c 'mkdir -p /run/tmpfiles.d'
ExecStart=/bin/sh -c 'echo "z /etc/hostname - - -" > /run/tmpfiles.d/hostname-relabel.conf'
Type=oneshot
RemainAfterExit=yes