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

Removal of users fails when action set to remove in databag #422

Closed sjsadowski closed 3 years ago

sjsadowski commented 6 years ago

Cookbook version

5.3.1

Chef-client version

14.1.12

Platform Details

CentOS 7.5

Scenario:

Remove users

Steps to Reproduce:

Change an action for a user's databag to 'remove'

Expected Result:

User is removed

Actual Result:

Nothing; user is not removed - action seems to be ignored.

TyMac commented 5 years ago

Have the same issue on chef-client 13.6.4 - CentOS 7.4 and 7.5

raghukumarc commented 5 years ago

Cookbook version:

- users (5.3.1)

I have a data bag file as mentioned below

knife data bag show users deepak
WARNING: Unencrypted data bag detected, ignoring any provided secret options.
action: remove
groups:
  devops
  docker
id:     deepak

Running chef-client with why-run option (-W) doesn't delete the user (i have replaced the usernames with '...')

Recipe: base::users
  * users_manage[devops] action create
  ...
  ...
    * group[docker] action manage (up to date)
    * group[devops] action create (up to date)
     (up to date)
  * users_manage[devops-trainee] action create
    * group[devops-trainee] action create (up to date)
     (up to date)
  * users_manage[dev] action create (skipped due to only_if)
clarkdave commented 5 years ago

Not sure if this is your issue, but it's not super clear in the readme that you need to run the :remove action on the users_manage resource to actually pick up and remove users with "action": "remove" in the data bag:

users_manage :devops do
  group_id 2300
  action [:create, :remove]
end

If you run users_manage without specifying action, or just use action [:create], it'll just ignore any data bag users with action:remove.

You can also add "force": true to the user to force removal (useful if they might logged in), as described on the underlying user resource: https://docs.chef.io/resource_user.html#properties

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.

sjsadowski commented 3 years ago

Closing because this cookbook is unmaintained.