sous-chefs / users

Development repository for the users cookbook
https://supermarket.chef.io/cookbooks/users
Apache License 2.0
138 stars 218 forks source link

STDERR: usermod: user 'm30868' does not exist in /etc/passwd #413

Closed jblaine closed 3 years ago

jblaine commented 6 years ago

Cookbook version

5.2.1

Chef-client version

12.17.44

Platform Details

RHEL 7

Scenario:

New JSON data bag defined and uploaded to chef server for a new user. Should result in the user being created and added to group(s).

JSON data:

{
    "id"        : "m30868",
    "uid"       : "64005",
    "gid"       : "10",
    "username"  : "m30868",
    "comment"   : "Carol",
    "home"      : "/home_local/m30868",
    "groups"    : [ "r701-staff" ],
    "shell"     : "/bin/bash",
    "action"    : [ "create", "manage", "modify", "lock" ],
    "ssh_keys"  : [
"ssh-rsa AAAAB3NzaC1yc2EAAblahblahblah carol"
]
}

Steps to Reproduce:

users_manage 'r701-staff' do
  action :create
  group_id 64000
  data_bag 'users'
end

Expected Result:

Expect the user to be created and added to the group

Actual Result:

    * linux_user[m30868] action create

      ================================================================================
      Error executing action `create` on resource 'linux_user[m30868]'
      ================================================================================

      Mixlib::ShellOut::ShellCommandFailed
      ------------------------------------
      Expected process to exit with [0], but received '6'
      ---- Begin output of ["usermod", "-c", "Carol", "-g", "10", "-u", "64005", "-d", "/home_local/m30868", "-m", "m30868"] ----
      STDOUT:
      STDERR: usermod: user 'm30868' does not exist in /etc/passwd
      ---- End output of ["usermod", "-c", "Carol", "-g", "10", "-u", "64005", "-d", "/home_local/m30868", "-m", "m30868"] ----
      Ran ["usermod", "-c", "Carol", "-g", "10", "-u", "64005", "-d", "/home_local/m30868", "-m", "m30868"] returned 6

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

       70:     user u['username'] do
       71:       uid validate_id(u['uid'])
       72:       gid validate_id(u['gid']) if u['gid']
       73:       shell u['shell']
       74:       comment u['comment']
       75:       password u['password'] if u['password']
       76:       salt u['salt'] if u['salt']
       77:       iterations u['iterations'] if u['iterations']
       78:       manage_home manage_home
       79:       home home_dir
       80:       action u['action'] if u['action']
       81:     end
       82:

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

      linux_user("m30868") do
        action [:create, :manage, :modify, :lock]
        supports {:manage_home=>false, :non_unique=>false}
        retries 0
        retry_delay 2
        default_guard_interpreter :default
        username "m30868"
        comment "Carol"
        uid 64005
        gid 10
        home "/home_local/m30868"
        shell "/bin/bash"
        manage_home true
        iterations 27855
        declared_type :user
        cookbook_name "r701-local-users"
      end
mengesb commented 6 years ago

Per usermod(1) in unix, exit 6 is: The login to be modified does not exist, the group does not exist, or the login shell does not exist

Have you tried with cookbook version 5.3.1 since that's the latest release?

github-actions[bot] commented 3 years ago

Marking stale due to inactivity. Remove stale label or comment or this will be closed in 7 days. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help! Thanks, Sous-Chefs.

github-actions[bot] commented 3 years ago

Closing due to inactivity. If this is still an issue please reopen or open another issue. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help! Thanks, Sous-Chefs.