sous-chefs / users

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

Break with Chef version 12.14.60 #354

Closed chrisduong closed 8 years ago

chrisduong commented 8 years ago

Cookbook version

2.x and 3.x

Chef-client version

12.14.60

Platform Details

Ubuntu 14.04

Scenario:

Run test-kitchen with suite sysadmin

Expected Result:

test-kitchen run successfully.

Actual Result:

test-kitchen failed, please the below log.

I notice that user resource has become to linux_user in the latest Chef version. I haven't figured out the different between them.

 Recipe: users::sysadmins
         * users_manage[sysadmin] action remove (up to date)
         * users_manage[sysadmin] action create
           * group[sysadmin] action create (skipped due to only_if)
           * linux_user[sysadmin] action create
             - create user sysadmin
* Parent directory /home/sysadmin does not exist, cannot create /home/sysadmin/.ssh
             ================================================================================
             Error executing action `create` on resource 'directory[/home/sysadmin/.ssh]'
             ================================================================================

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

             Resource Declaration:
             ---------------------
             # In /tmp/kitchen/cache/cookbooks/users/providers/manage.rb

       99:       directory "#{home_dir}/.ssh" do
             100:         owner u['uid'] ? validate_id(u['uid']) : u['username']
             101:         group validate_id(u['gid']) if u['gid']
             102:         mode '0700'
             103:         only_if { u['ssh_keys'] || u['ssh_private_key'] || u['ssh_public_key'] }
             104:       end
             105:

             Compiled Resource:
             ------------------
             # Declared in /tmp/kitchen/cache/cookbooks/users/providers/manage.rb:99:in `block (2 levels) in class_from_file'

             directory("/home/sysadmin/.ssh") do
        action [:create]
        retries 0
        retry_delay 2
        default_guard_interpreter :default
        path "/home/sysadmin/.ssh"
        declared_type :directory
        cookbook_name "users"
        owner "sysadmin"
        mode "0700"
        only_if { #code block }
             end

             Platform:
             ---------
             x86_64-linux

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

           Chef::Exceptions::EnclosingDirectoryDoesNotExist
           ------------------------------------------------
           directory[/home/sysadmin/.ssh] (/tmp/kitchen/cache/cookbooks/users/providers/manage.rb line 99) had an error: Chef::Exceptions::EnclosingDirectoryDoesNotExist: Parent directory /home/sysadmin does not exist, cannot create /home/sysadmin/.ssh

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/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 /tmp/kitchen/cache/cookbooks/users/recipes/sysadmins.rb:23:in `from_file'

           users_manage("sysadmin") do
             action [:remove, :create]
             updated true
             updated_by_last_action true
             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"
             group_name "sysadmin"
             cookbook "users"
           end

           Platform:
           ---------
           x86_64-linux
warp3r commented 8 years ago

Hi there,

I commited pull request #353 yesterday for this fix. TravisCI did fail for openSuse 13.2 although it builds ok in my test environments.

Regards Jordi

chrisduong commented 8 years ago

Hi @warp3r,

Seems weird, maybe Travis OpenSuse is not the same as the one we use. 😭

tomwix commented 8 years ago

We have the same issue here. Strange thing it is also reproduced in a clean kitchen environment. I think the problem maybe coming from the native resource "user" not the "users" community cookbook itself. This is because the "users" community cookbook uses the "user" resource to create the user and the home directory, and I used the "user" resource manually in my test environment and even though it came back with no error it did not create the home directory.

SonyDavid commented 8 years ago

I rolled a server back to Client 12.13.37 and the cookbook worked fine. Brought it to the current Client version and it fails. Reinstalled 12.13.27 and it worked again.

tas50 commented 8 years ago

This has been fixed in the 4.0 release of this cookbook. I've removed opensuse 13.2 from travis for now. Once we have Chef 12.14 on Travis that will be resolved since the users provider bug that prevents that test from running was fixed in 12.14.