Hey Anthony,
You can use a guard in this case to check and execute the resource 'only_if' the condition is true. You can use ruby or specify a command.
```
$ cat test.rb
group "sensu" doaction :modifymembers "vagrant"append trueonly_if "getent passwd vagrant"
end
$ chef-apply test.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* group[sensu] action modify (skipped due to only_if)
```Grabbed the guard form this post - http://stackoverflow.com/questions/24856339/chef-initialize-new-linux-user-if-it-doesnt-already-existHTH-Eric HelgesonOn Sat, Feb 28, 2015 at 4:42 PM, Anthony Kong < " target="_blank"> > wrote:HiI have this definition on my cookbookgroup "sensu" do
action :modify
members "vagrant"
append true
end
it will throw an exception when I run it on ec2 because there is no user vagrantHow can I avoid the exception? Is there any way to detect the user exist? I have checked the doc https://docs.chef.io/resource_group.html but there is nothing obviousCheers,
Archive powered by MHonArc 2.6.16.