Edit role programatically

Hello Masters

I know I can edit my role by simply executing command "knife role edit ". This will give me an editor and I can make changes, save and close it.
I want to automate editing of roles, which will include adding and deleting recipes from role. How can I do that?

Manish Mehra

Several options are available. You can use knife role from file or knife upload to ingest JSON data. You can use knife exec to write short Ruby scripts that manipulate Chef objects. Or you can use one of the API client libraries (chef-api, PyChef, Jclouds, etc) to write more complex scripts in whatever language you are comfortable with.

1 Like

Thanks Noah.I used knife role from file. Worked fine for me. :+1: