user3794478
user3794478

Reputation: 11

Obtaining list of groups in Chef?

Brand new to Chef. I was curious if there's a way to obtain a list of groups in Chef? Essentially I want to create a restricted windows user who isn't a member of any group. Something like:

TheseAreAllTheWindowsGroupsOnTheSystem.each do |groupName|
   group groupName do
        action :modify
        excluded_members: username
    end
end

Upvotes: 0

Views: 315

Answers (1)

sethvargo
sethvargo

Reputation: 26997

You can use Ohai for this.

node['etc']['group'].each do |group_name, info|
  # ...
end

I do not have a Windows system handy, but that is the key on Linuxes. You can run ohai on a Windows machine and see all the information available:

$ ohai

Upvotes: 1

Related Questions