Skip to content

Commit

Permalink
Always ensure a Rancher-vWXYZ transient hostname (rancher#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

(cherry picked from commit 5e6bc8f)

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
  • Loading branch information
fgiudici committed Apr 17, 2024
1 parent 8f490c3 commit b976773
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 1 addition & 6 deletions framework/files/system/oem/01_elemental-rootfs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ stages:
initramfs:
- if: '[ ! -f /run/cos/recovery_mode ]'
commands:
- |
if [ ! -e /usr/local/etc/hostname ]; then
mkdir -p /usr/local/etc
echo rancher-${RANDOM} > /usr/local/etc/hostname
fi
ln -sf /usr/local/etc/hostname /etc/hostname
- ln -sf /usr/local/etc/hostname /etc/hostname
- if: '[ ! -f "/run/cos/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 b976773

Please sign in to comment.