Skip to content

Commit d1dd396

Browse files
authored
[v2.0.x] Hostname backports (#1371)
Always ensure a Rancher-vWXYZ transient hostname (#1264) If a static hostname is not available always set a transient hostname in the form "Rancher-VWXYZ". Do that also when in recovery mode. Fixes: rancher/elemental-operator#646 (cherry picked from commit 5e6bc8f) Signed-off-by: Francesco Giudici <[email protected]>
1 parent 8f490c3 commit d1dd396

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

framework/files/system/oem/01_elemental-rootfs.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ stages:
33
initramfs:
44
- if: '[ ! -f /run/cos/recovery_mode ]'
55
commands:
6-
- |
7-
if [ ! -e /usr/local/etc/hostname ]; then
8-
mkdir -p /usr/local/etc
9-
echo rancher-${RANDOM} > /usr/local/etc/hostname
10-
fi
11-
ln -sf /usr/local/etc/hostname /etc/hostname
6+
- ln -sf /usr/local/etc/hostname /etc/hostname
127
- if: '[ ! -f "/run/cos/recovery_mode" ]'
138
name: "Persist /etc/machine-id"
149
commands:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: "Fallback hostname"
2+
stages:
3+
initramfs:
4+
- if: '[ ! -f /etc/hostname ]'
5+
commands:
6+
- sysctl kernel.hostname=rancher-${RANDOM}

0 commit comments

Comments
 (0)