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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hostname resource does not set fqdn on MacOS/Darwin #14063

Open
feld opened this issue Nov 13, 2023 · 1 comment
Open

Hostname resource does not set fqdn on MacOS/Darwin #14063

feld opened this issue Nov 13, 2023 · 1 comment
Labels
Status: Untriaged An issue that has yet to be triaged.

Comments

@feld
Copy link

feld commented Nov 13, 2023

Hostname, Domain name, and FQDNs should always be considered 3 separate values but I seem to run into this type of problem everywhere 馃槶馃ゴ

when darwin?
# darwin
execute "set HostName via scutil" do
command "/usr/sbin/scutil --set HostName #{new_resource.hostname}"
not_if { shell_out("/usr/sbin/scutil --get HostName").stdout.chomp == new_resource.hostname }
notifies :reload, "ohai[reload hostname]"
end
execute "set ComputerName via scutil" do
command "/usr/sbin/scutil --set ComputerName #{new_resource.hostname}"
not_if { shell_out("/usr/sbin/scutil --get ComputerName").stdout.chomp == new_resource.hostname }
notifies :reload, "ohai[reload hostname]"
end
shortname = new_resource.hostname[/[^\.]*/]
execute "set LocalHostName via scutil" do
command "/usr/sbin/scutil --set LocalHostName #{shortname}"
not_if { shell_out("/usr/sbin/scutil --get LocalHostName").stdout.chomp == shortname }
notifies :reload, "ohai[reload hostname]"
end

The code for the resource always uses "hostname" for all values passed to scutil and ignores the existence of fqdn in the recipe. It is written to assume that the "hostname" value is the FQDN (which it is not, and should not be). You can see that by the "shortname" variable created by trying to split off the first label of the hostname which it thinks is the FQDN...

e.g.,

hostname macbook do
  fqdn macbook.example.com
end

Will always force the MacOS client to have a hostname of macbook and the FQDN is never applied. This does behave correctly on Linux hosts, for example.

@feld feld added the Status: Untriaged An issue that has yet to be triaged. label Nov 13, 2023
@feld feld changed the title Hostname resources does not set fqdn on MacOS/Darwin Hostname resource does not set fqdn on MacOS/Darwin Nov 13, 2023
@williamtheaker
Copy link
Contributor

@feld would setting LocalHostName to the fqdn property fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Untriaged An issue that has yet to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants