Error remove already removed user
Closed this issue · 5 comments
user_account 'xxx' do
action :remove
end
brings error in knife solo cook
Error executing action remove
on resource 'user_account[xxx]'
I'm getting this problem as well. Basically, the first run for removing a user works, but once the user's deleted the user::data_bag recipe tries to remove already removed users. Here's the stack trace:
* user_account[firstname.lastname] action remove
================================================================================
Error executing action `remove` on resource 'user_account[firstname.lastname]'
================================================================================
ArgumentError
-------------
can't find user for firstname.lastname
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/user/providers/account.rb:134:in `getpwnam'
/var/chef/cache/cookbooks/user/providers/account.rb:134:in `block in authorized_keys_resource'
/var/chef/cache/cookbooks/user/providers/account.rb:130:in `authorized_keys_resource'
/var/chef/cache/cookbooks/user/providers/account.rb:40:in `block in class_from_file'
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/user/recipes/data_bag.rb
36: user_account username do
37: %w{comment uid gid home shell password system_user manage_home create_group
38: ssh_keys ssh_keygen}.each do |attr|
39: send(attr, u[attr]) if u[attr]
40: end
41: action u['action'].to_sym if u['action']
42: end
43:
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/user/recipes/data_bag.rb:36:in `block in from_file'
user_account("firstname.lastname") do
action [:remove]
retries 0
retry_delay 2
guard_interpreter :default
cookbook_name "user"
recipe_name "data_bag"
comment "Firstname Lastname"
home "/home/firstname.lastname"
ssh_keys "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDb5n4GLb2QVB7TNMAxi8a9AEaTmDfHi2k9HuYJTcj/q4wIZbOYJWkNI14IMl7DVNXudvr1ebIOq2aFnHeVqBnfo9vy2WO1yCS4YiPJWjDByzEUveQQSu5nIag551r/oGUvmg3Y6pDX0Mxu0whHmJF0+J7o7NcRNS8clyKGVd0sqrQY4h5B8CDE62Fak+qgys2GdL856kjFwnXoyyjhsTIjxKcTavMmuVh954PwqGk11u7flYIHD+YFrTToAZ9rEspmRddoaMh8OW4Nnq7ioEV05cJzGFzpIht4pr4GTiPM1jdpGnEe8f+aP8V+gGDrp3fNpJSIKPIWyNBYWZFMHQQD user@mail.com"
username "firstname.lastname"
end
Recipe: timezone::default
* execute[update-tzdata] action run
- execute dpkg-reconfigure -f noninteractive tzdata
Running handlers:
[2014-04-28T11:20:59-07:00] ERROR: Running exception handlers
Running handlers complete
[2014-04-28T11:20:59-07:00] ERROR: Exception handlers complete
[2014-04-28T11:20:59-07:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 3 resources updated in 8.229891765 seconds
[2014-04-28T11:20:59-07:00] ERROR: user_account[firstname.lastname] (user::data_bag line 36) had an error: ArgumentError: can't find user for firstname.lastname
[2014-04-28T11:20:59-07:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
I managed to resolve this just by downloading the latest SNAPSHOT version of the cookbook (i.e. the latest code, but not a release). Also, it took me a few too many minutes to realize that just because I removed my data bag from my local repo doesn't mean Chef Server has removed it!
Getting the same issue (same getpwnam call failing) when using chef-client with -W (whyrun/simulate). After some digging pretty sure #89 will resolve my issue.
This should be fixed in the 0.5.0
release of this cookbook. If you are still seeing the problem please raise a new issue and I'd be happy to take a look.