-
Notifications
You must be signed in to change notification settings - Fork 129
Add cookbook support #20
base: master
Are you sure you want to change the base?
Conversation
An annoying nit is that due to the class level attributes attribute, we can not use the attributes attribute for cookbook attributes.
Hi :) one question - when it will be merged? |
@coderanger I know this PR is old, but it would be nice to support attribute search results. Is there any plan on adding attribute search results to pyChef? |
@innomation Could you clarify what you are asking for as this PR is for search cookbooks. |
@aryn-lacy Thanks for the reply. I was hoping to use pyChef to gather the attributes from a node search (in my case, recipe attribute). I couldn't find anything in the pyChef docs about displaying attributes, and sthe only thing online I found was to use bash command to load the attributes. I'd prefer to stay away from using bash/subprocess within my python code if possible. Any idea if this will be implemented in the future? |
It may already be implemented but I am attempting to maintain a new fork with all these PRs eventually pulled in. Could you add the bash commands here? I may be able to help you with your code to get this to work. |
I haven't seen any documentation for pulling up particular search node attributes in pyChef. I'm currently pulling a list of hosts from Chef, and then applying the attributes argument to the knife search node command using subprocess. My script in gathering chef nodes looks like this, based on a query that defines the operating system. It would be ideal if I could add the attributes argument within the chef.Search function. I've tried injecting '-a recipes' a number of ways in the chef.Search function, but none of it works.
I've omitted some of the following script, but am posting to show the snippet on how I'm grabbing the attributes using subprocess from a list of hosts I've gathered in chef.Search function.
It would be ideal to use the -a option in chef.Search to define which attribute I would like to gather. As far as I'm aware, I don't know of any way to do so in pyChef. |
Ok so you can absolutely do this already with the library. The
|
Thank you @aryn-lacy ! I've made a minor edit to my pasted code, as there were some mistakes, but after making the correct changes with your code, I'm retrieving the node recipes. For my understanding, is the ['automatic'] nodes attribute you've used based on the attribute identified by Ohai at the start of a Chef Infra Client run? |
Automatic attributes are Ohai attributes but also any other attributes that chef automatically adds like the |
This adds a class for dealing with cookbooks. Unfortunately an annoying nit is that due to the class level attributes attribute, we can not use the attributes attribute for cookbook attributes.
Please let me know if you want anything else for inclusion.
Examples: