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

macosx hostname resource error when previously unset #8477

Open
hawksight opened this issue May 7, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@hawksight
Copy link

commented May 7, 2019

Description

Using the hostname resource on macosx, the chef run will fail if the hostname has not been set before. I've found this common across our mac devices. Obviously this is somewhat counter intuitive as I am attempting to use the resource to set the hostname on said devices.

Chef Version

14.12.9
Hosted Chef currently.

Platform Version

Macosx:

platform_version: 10.14.4
platform_build: 18E226

Replication Case

Use something like the following in a recipe and run against a macosx machine where the command /usr/sbin/scutil --get HostName returns HostName: not set

hostname 'set-machine-hostname' do
  hostname config['hostname']
  action :set
  retries 1
end

Client Output

Output from run locally.

hostname[set-machine-hostname] (enroll::default line 65) had an error: Mixlib::ShellOut::ShellCommandFailed: execute[set HostName via scutil] (/opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-14.10.9/lib/chef/resource/hostname.rb line 112) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /usr/sbin/scutil --get HostName ----
STDOUT:
STDERR: HostName: not set
---- End output of /usr/sbin/scutil --get HostName ----
Ran /usr/sbin/scutil --get HostName returned 1

Verifying whether the hostname is set with the same command the code uses:

❯ /usr/sbin/scutil --get HostName

HostName: not set

❯ echo $?

1

Possible line where code is failing:
https://github.com/chef/chef/blob/master/lib/chef/resource/hostname.rb#L114

Stacktrace

N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.