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

The users::sysadmins recipe fails on OS X #118

Closed
wolf31o2 opened this Issue Nov 20, 2015 · 7 comments

Comments

Projects
None yet
3 participants
@wolf31o2

I am including the users::sysadmins recipe, which works on Linux, on OSX, and it fails...

Log:

Recipe: users::sysadmins
  * users_manage[sysadmin] action remove
    * user[foo] action remove (up to date)
...
  * users_manage[sysadmin] action create
    * user[test] action create (up to date)
    * directory[/Users/test/.ssh] action create
      * cannot determine user id for 'test', does the user exist on this system?
      ================================================================================
      Error executing action `create` on resource 'directory[/Users/test/.ssh]'
      ================================================================================

      Chef::Exceptions::UserIDNotFound
      --------------------------------
      cannot determine user id for 'alvin', does the user exist on this system?

      Resource Declaration:
      ---------------------
      # In /var/chef/cache/cookbooks/users/providers/manage.rb

      114:         directory "#{home_dir}/.ssh" do
      115:           owner u['username']
      116:           group u['gid'] || u['username']
      117:           mode "0700"
      118:         end
      119:

      Compiled Resource:
      ------------------
      # Declared in /var/chef/cache/cookbooks/users/providers/manage.rb:114:in `block (2 levels) in class_from_file'

      directory("/Users/test/.ssh") do
        action [:create]
        retries 0
        retry_delay 2
        default_guard_interpreter :default
        path "/Users/test/.ssh"
        declared_type :directory
        cookbook_name "users"
        owner "test"
        group "test"
        mode "0700"
      end


    ================================================================================
    Error executing action `create` on resource 'users_manage[sysadmin]'
    ================================================================================

    Chef::Exceptions::UserIDNotFound
    --------------------------------
    directory[/Users/test/.ssh] (/var/chef/cache/cookbooks/users/providers/manage.rb line 114) had an error: Chef::Exceptions::UserIDNotFound: cannot determine user id for 'test', does the user exist on this system?

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/users/recipes/sysadmins.rb

     23: users_manage "sysadmin" do
     24:   group_id 2300
     25:   action [ :remove, :create ]
     26: end

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/users/recipes/sysadmins.rb:23:in `from_file'

    users_manage("sysadmin") do
      action [:remove, :create]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :users_manage
      cookbook_name "users"
      recipe_name "sysadmins"
      group_id 2300
      data_bag "users"
      search_group "sysadmin"
      cookbook "users"
      group_name "sysadmin"
    end


Running handlers:
[2015-11-20T15:42:41-08:00] ERROR: Running exception handlers
Running handlers complete
[2015-11-20T15:42:41-08:00] ERROR: Exception handlers complete
Chef Client failed. 1 resources updated in 06 seconds
[2015-11-20T15:42:42-08:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-11-20T15:42:42-08:00] ERROR: users_manage[sysadmin] (users::sysadmins line 23) had an error: Chef::Exceptions::UserIDNotFound: directory[/Users/test/.ssh] (/var/chef/cache/cookbooks/users/providers/manage.rb line 114) had an error: Chef::Exceptions::UserIDNotFound: cannot determine user id for 'test', does the user exist on this system?
[2015-11-20T15:42:42-08:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Obviously, the user is not created. Running id test shows as much. However, the user resource is called and says "up to date" on the user.

This is on Chef 12.5.1 using the 1.8.2 users cookbook.

@cdoughty-r7

This comment has been minimized.

Show comment
Hide comment
@cdoughty-r7

cdoughty-r7 Nov 24, 2015

We are also experiencing this too. From the output it looks like it expects the user to have a group name matching the username (which on mac is not standard practice). I was able to manually do this to work around the issue

sudo dscl . -create /groups/username
sudo dscl . -append /groups/username gid 4200
sudo dscl . -append /groups/username passwd "*"

After the above code the chef exception went away for me.

We are also experiencing this too. From the output it looks like it expects the user to have a group name matching the username (which on mac is not standard practice). I was able to manually do this to work around the issue

sudo dscl . -create /groups/username
sudo dscl . -append /groups/username gid 4200
sudo dscl . -append /groups/username passwd "*"

After the above code the chef exception went away for me.

@iennae

This comment has been minimized.

Show comment
Hide comment
@iennae

iennae Dec 16, 2015

Contributor

Curious question, does the users_manage resource work as expected in general on the mac?

Contributor

iennae commented Dec 16, 2015

Curious question, does the users_manage resource work as expected in general on the mac?

@wolf31o2

This comment has been minimized.

Show comment
Hide comment
@wolf31o2

wolf31o2 Dec 16, 2015

@iennae

This comment has been minimized.

Show comment
Hide comment
@iennae

iennae Dec 16, 2015

Contributor

Thanks :) I suspect this is an overall problem.

Contributor

iennae commented Dec 16, 2015

Thanks :) I suspect this is an overall problem.

@wolf31o2

This comment has been minimized.

Show comment
Hide comment
@wolf31o2

wolf31o2 Dec 17, 2015

It looks to me like the user resource doesn't do the correct thing on Mac.

My cookbook:

mac-agent01:usertest root# cat recipes/default.rb
# Test for Mac OS X

group 'foo' do
  gid 1000
  action :create
end

user 'foo' do
  uid 1000
  shell '/bin/bash'
  comment 'Test user'
  home '/dev/null'
  supports manage_home: false
  action :create
end

The Chef run:

mac-agent01:usertest root# chef-solo -o usertest
[2015-12-16T16:12:20-08:00] WARN: *****************************************
[2015-12-16T16:12:20-08:00] WARN: Did not find config file: /etc/chef/solo.rb, using command line options.
[2015-12-16T16:12:20-08:00] WARN: *****************************************
Starting Chef Client, version 12.5.1
[2015-12-16T16:12:22-08:00] WARN: Run List override has been provided.
[2015-12-16T16:12:22-08:00] WARN: Original Run List: []
[2015-12-16T16:12:22-08:00] WARN: Overridden Run List: [recipe[usertest]]
Compiling Cookbooks...
Converging 2 resources
Recipe: usertest::default
  * group[foo] action create
    - create foo
  * user[foo] action create
    - create user foo

Running handlers:
Running handlers complete
Chef Client finished, 2/2 resources updated in 03 seconds

...and now, what I get from poking around...

mac-agent01:usertest root# id foo
id: foo: no such user
mac-agent01:usertest root# su - foo
su: unknown login: foo
mac-agent01:usertest root# dscl . -list /groups | grep foo
foo
mac-agent01:usertest root# dscl . -list /users | grep foo
foo
mac-agent01:usertest root# touch file-test
mac-agent01:usertest root# chown foo:foo file-test
chown: foo: illegal user name

While I see a user/group in dscl, we're missing something to actually have a working user.

It looks to me like the user resource doesn't do the correct thing on Mac.

My cookbook:

mac-agent01:usertest root# cat recipes/default.rb
# Test for Mac OS X

group 'foo' do
  gid 1000
  action :create
end

user 'foo' do
  uid 1000
  shell '/bin/bash'
  comment 'Test user'
  home '/dev/null'
  supports manage_home: false
  action :create
end

The Chef run:

mac-agent01:usertest root# chef-solo -o usertest
[2015-12-16T16:12:20-08:00] WARN: *****************************************
[2015-12-16T16:12:20-08:00] WARN: Did not find config file: /etc/chef/solo.rb, using command line options.
[2015-12-16T16:12:20-08:00] WARN: *****************************************
Starting Chef Client, version 12.5.1
[2015-12-16T16:12:22-08:00] WARN: Run List override has been provided.
[2015-12-16T16:12:22-08:00] WARN: Original Run List: []
[2015-12-16T16:12:22-08:00] WARN: Overridden Run List: [recipe[usertest]]
Compiling Cookbooks...
Converging 2 resources
Recipe: usertest::default
  * group[foo] action create
    - create foo
  * user[foo] action create
    - create user foo

Running handlers:
Running handlers complete
Chef Client finished, 2/2 resources updated in 03 seconds

...and now, what I get from poking around...

mac-agent01:usertest root# id foo
id: foo: no such user
mac-agent01:usertest root# su - foo
su: unknown login: foo
mac-agent01:usertest root# dscl . -list /groups | grep foo
foo
mac-agent01:usertest root# dscl . -list /users | grep foo
foo
mac-agent01:usertest root# touch file-test
mac-agent01:usertest root# chown foo:foo file-test
chown: foo: illegal user name

While I see a user/group in dscl, we're missing something to actually have a working user.

@iennae

This comment has been minimized.

Show comment
Hide comment
@iennae

iennae Dec 17, 2015

Contributor

Thanks for the check! Will work to get this fixed.

Contributor

iennae commented Dec 17, 2015

Thanks for the check! Will work to get this fixed.

@iennae

This comment has been minimized.

Show comment
Hide comment
@iennae

iennae Jan 9, 2016

Contributor

Please check out version 2.0.1. I'm closing this issue now, please reopen if you find that it doesn't work for you.

Contributor

iennae commented Jan 9, 2016

Please check out version 2.0.1. I'm closing this issue now, please reopen if you find that it doesn't work for you.

@iennae iennae closed this Jan 9, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment