Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-4.7] Bug 1927783: [vsphere] set hostname with --static to provide consistent node name for CSR approval #2405

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion templates/common/vsphere/files/vsphere-hostname.yaml
Expand Up @@ -5,6 +5,9 @@ contents:
#!/usr/bin/env bash
set -e

# only run if the hostname is not set
test -f /etc/hostname && exit 0 || :

if vm_name=$(/bin/vmtoolsd --cmd 'info-get guestinfo.hostname'); then
/usr/bin/hostnamectl --transient set-hostname ${vm_name}
/usr/bin/hostnamectl set-hostname --static ${vm_name}
fi
7 changes: 7 additions & 0 deletions templates/common/vsphere/units/vsphere-hostname.service.yaml
Expand Up @@ -3,7 +3,14 @@ enabled: true
contents: |
[Unit]
Description=vSphere hostname
Requires=vmtoolsd.service
After=vmtoolsd.service

# Only run on first boot and only if the host does not have a name yet
ConditionPathExists=/etc/ignition-machine-config-encapsulated.json
ConditionPathExists=!/etc/hostname
ConditionVirtualization=vmware

Before=kubelet.service
Before=node-valid-hostname.service
Before=NetworkManager.service
Expand Down