Skip to content

Commit

Permalink
Always ensure a Rancher-vWXYZ transient hostname (#1264)
Browse files Browse the repository at this point in the history
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

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
  • Loading branch information
fgiudici authored and kkaempf committed Mar 5, 2024
1 parent fb0f33a commit 6935634
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 1 addition & 5 deletions framework/files/system/oem/01_elemental-rootfs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ stages:
initramfs:
- if: '[ ! -f /run/elemental/recovery_mode ]'
commands:
- |
if [ ! -e /run/elemental/persistent/etc/hostname ]; then
sysctl kernel.hostname=rancher-${RANDOM}
fi
ln -sf /run/elemental/persistent/etc/hostname /etc/hostname
- ln -sf /run/elemental/persistent/etc/hostname /etc/hostname
- if: '[ ! -f "/run/elemental/recovery_mode" ]'
name: "Persist /etc/machine-id"
commands:
Expand Down
6 changes: 6 additions & 0 deletions framework/files/system/oem/03_hostname.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: "Fallback hostname"
stages:
initramfs:
- if: '[ ! -f /etc/hostname ]'
commands:
- sysctl kernel.hostname=rancher-${RANDOM}

0 comments on commit 6935634

Please sign in to comment.