Admin user home directories are not getting created, chef fails


#1

admin user home directories are not getting created, chef fails and also is there way avoid password in the receipe, please can someone look into below receipe??

Chef::Exceptions::EnclosingDirectoryDoesNotExist
    ------------------------------------------------
    Parent directory /home/user does not exist, cannot create /home/user/.ssh



===================================
receipe used:

admins = data_bag('admin_users')

admins.each do |login|
  admin = data_bag_item('admin_users', login)

  group login do
    action  :create
  end

  user login do
    comment admin['comment']
    gid     login
    shell   admin['shell']
    home    admin['homedir']
    password  'xyzxyzxyzxyzxyzxyzxyzxyzxyz'
    manage_home true
    action  [:create, :unlock]
  end

  if node[:platform_family] == "debian" then
    group "sudo" do
      action :modify
      members login
      append true
      system true
    end
    file "/etc/sudoers.d/#{login}" do
      owner "root"
      group "root"
      mode "0440"
      content "#{login} ALL = NOPASSWD: ALL"
    end
  elsif node[:platform_family] == "rhel" then
    file "/etc/sudoers.d/#{login}" do
      owner "root"
      group "root"
      mode "0440"
      content "#{login} ALL = NOPASSWD: ALL"
    end
  end

  directory admin['homedir'] + "/.ssh" do
    owner login
    group login
    mode "0700"
    action :create
  end

  file admin['homedir'] + "/.ssh\/authorized_keys" do
    owner login
    group login
    mode "0644"
    content admin['ssh-key']
    action :create
  end
end

#2

If you leave off the directory and file resources does it create /home/user/ properly?


#3

Does root have the rights to create home directories in /home/ ? I've seen environments where root did not, because it was an NFS mount with root_squash enabled.