Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add multiple members to a group by chef

Tags:

chef-infra

How can I add multiple members to a group by chef?

I tried like this, but it fails.

group "git" do
  action :modify
  members "foo, bar"
  append true
end

I can do like this, but members seems to accept multiple users. How can I use it?

%w(foo bar).each do |m|
  group "git" do
    action :modify
    members m
    append true
  end
end
like image 866
ironsand Avatar asked Apr 12 '14 05:04

ironsand


1 Answers

Most arguments that accept multiple inputs in Chef work with standard ruby array syntax. I can't find an example just now, and it's very frustrating that the group docs don't provide an example of multiple users. In fact, they just say

members Indicates which users should be set or appended to a group.

And only provide examples with single users. That said, members ["foo", "bar"] should be the way to go.

like image 98
Patrick M Avatar answered Oct 13 '22 19:10

Patrick M