[chef] Re: Re: Re: Managing users and groups - Current best practice


Chronological Thread 
  • From: Seth Falcon < >
  • To:
  • Cc:
  • Subject: [chef] Re: Re: Re: Managing users and groups - Current best practice
  • Date: Wed, 8 Dec 2010 11:36:25 -0800

Hey John,

On Tue, Dec 7, 2010 at 11:14 AM, John E. Vincent (lusis)
< >
 wrote:
> So I wanted to share what I ended up doing. I tried a few different
> methods using Set and what not. The set didn't quite work the way I
> wanted so for now I'm using Array#delete_if to compare the id of users
> with deleted_users. This is not the most efficient but having just
> found time to dive back into it today, I went with the quickest
> solution:
>
> https://gist.github.com/732237
>

Here's that avoids the inner loop (untested):

    groups = search(:groups)
    users = search(:users)
    deleted_users = search(:deleted_users)

    deleted_user_ids = deleted_users.inject({}) { |ids, u|
ids[u['id']] = 1; ids }
    # remove deleted users from the users array so we don't recreate them
    users.delete_if { |user| deleted_user_ids.has_key(user['id']) }


+ seth



Archive powered by MHonArc 2.6.16.

§