-
Notifications
You must be signed in to change notification settings - Fork 81
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
Add ability to set hostname via DHCP during install #726
Merged
bk201
merged 4 commits into
harvester:master
from
tserong:wip-set-hostname-via-dhcp-installer-only
May 23, 2024
Merged
Add ability to set hostname via DHCP during install #726
bk201
merged 4 commits into
harvester:master
from
tserong:wip-set-hostname-via-dhcp-installer-only
May 23, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tserong
force-pushed
the
wip-set-hostname-via-dhcp-installer-only
branch
from
May 14, 2024 04:10
9f637c2
to
c12f838
Compare
When installing Harvester, if the management interface is configured via DHCP, we will default the system hostname to the client hostname specified by the DHCP server. For interactive installation, the order of the "Configure hostname" and "Configure network" pages is swapped, so that "Configure network" comes first. This allows us to set DHCLIENT_SET_HOSTNAME="yes" when applying the management NIC config. If DHCP is used, and the DHCP server is configured to specify a hostname, the live environment will then automatically have its hostname set to whatever it got from the DHCP server. Then, on the hostname page, we can default the hostname to that value, which the user is still free to change should they wish. For automated/PXE installation, it works like this: - If os.hostname is specified in the harvester config, we use that. - If os.hostname is not specified, we use the DHCP provided hostname if set, otherwise we fall back to a randomly generated hostname. Related issue: harvester/harvester#1444 Signed-off-by: Tim Serong <[email protected]>
Signed-off-by: Tim Serong <[email protected]>
tserong
force-pushed
the
wip-set-hostname-via-dhcp-installer-only
branch
from
May 14, 2024 10:27
c12f838
to
2cac951
Compare
ibrokethecloud
approved these changes
May 15, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. thanks.
Signed-off-by: Tim Serong <[email protected]>
We need to get the remote config before looking up MAC addresses, otherwise config.ManagementInterface.Interfaces might not yet be set up correctly, and the later call to applyNetworks() will fail. This commit also simplifies the MAC address lookup loop to not need tmpInterfaces. Signed-off-by: Tim Serong <[email protected]>
bk201
approved these changes
May 23, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
We need to provide the option of allowing system hostnames to be set via DHCP.
Solution:
When installing Harvester, if the management interface is configured via DHCP, we will default the system hostname to the client hostname specified by the DHCP server.
For interactive installation, the order of the "Configure hostname" and "Configure network" pages is swapped, so that "Configure network" comes first. This allows us to set DHCLIENT_SET_HOSTNAME="yes" when applying the management NIC config. If DHCP is used, and the DHCP server is configured to specify a hostname, the live environment will then automatically have its hostname set to whatever it got from the DHCP server. Then, on the hostname page, we can default the hostname to that value, which the user is still free to change should they wish.
For automated/PXE installation, it works like this:
(This is an alternative to #717 - the advantage with this approach is that we set the hostname once, during installation, whereas #717 potentially allows the DHCP server to change the hostname of an installed system later, which would likely cause all sorts of trouble)
Related Issue:
harvester/harvester#1444
Test plan:
option host-name XXX
oruse-host-decl-names on
indhcpd.conf
)os.hostname
is not set in the harvester config yaml.Example dhcpd.conf snippet which should set the hostname to "harv-0-dhcp" for the MAC address 02:00:00:0D:62:E2: