Read-only access to data in the chef-repository


#1

Dear Chefs,

I have a question about how to programmatically get read access to the data
in the chef-repository

We are a java-heavy shop, which mean than configuration gets baked into
software in two places, on our jenkins CI server during the .war build
process and on the target node as well.

I intend to store all the application configuration details in Chef
databags, details like:

target database server:
database auth credentials
clustering info
http port
https port
other ports

I intend to create maven target that grabs such information from the chef
server

I found that I can get read-only access from any server that is a
chef-client

$ knife search jboss_apps “type:production” -c /etc/chef/client.rb -F json

I had to add one value to client.rb to get the above to work

node_name ‘foo.example.com

I would love to know how to do this with pure ruby. Any ideas?

I need to query the chef-server, grab a bunch of values, then throw them
into jboss-foo.xml.erb template and compile that template. If you fellow
Chefs see any issues w/ this approach, pls let me know :slight_smile:


#2

You could try using their server-api[1] to access client or data bag
information.

[1] - http://wiki.opscode.com/display/chef/Server+API

On Fri, Nov 4, 2011 at 10:22 AM, Bryan Berry bryan.berry@gmail.com wrote:

Dear Chefs,

I have a question about how to programmatically get read access to the
data in the chef-repository

We are a java-heavy shop, which mean than configuration gets baked into
software in two places, on our jenkins CI server during the .war build
process and on the target node as well.

I intend to store all the application configuration details in Chef
databags, details like:

target database server:
database auth credentials
clustering info
http port
https port
other ports

I intend to create maven target that grabs such information from the chef
server

I found that I can get read-only access from any server that is a
chef-client

$ knife search jboss_apps “type:production” -c /etc/chef/client.rb -F json

I had to add one value to client.rb to get the above to work

node_name ‘foo.example.com

I would love to know how to do this with pure ruby. Any ideas?

I need to query the chef-server, grab a bunch of values, then throw them
into jboss-foo.xml.erb template and compile that template. If you fellow
Chefs see any issues w/ this approach, pls let me know :slight_smile:


#3

hmm, i could but then I would have to reverse-engineer coderanger’s pychef
https://github.com/coderanger/pychef/blob/master/chef/api.py in order to
handle the authentication properly

could be a little challenging

On Fri, Nov 4, 2011 at 4:40 PM, Bryan Baugher bjbq4d@gmail.com wrote:

You could try using their server-api[1] to access client or data bag
information.

[1] - http://wiki.opscode.com/display/chef/Server+API

On Fri, Nov 4, 2011 at 10:22 AM, Bryan Berry bryan.berry@gmail.comwrote:

Dear Chefs,

I have a question about how to programmatically get read access to the
data in the chef-repository

We are a java-heavy shop, which mean than configuration gets baked into
software in two places, on our jenkins CI server during the .war build
process and on the target node as well.

I intend to store all the application configuration details in Chef
databags, details like:

target database server:
database auth credentials
clustering info
http port
https port
other ports

I intend to create maven target that grabs such information from the chef
server

I found that I can get read-only access from any server that is a
chef-client

$ knife search jboss_apps “type:production” -c /etc/chef/client.rb -F json

I had to add one value to client.rb to get the above to work

node_name ‘foo.example.com

I would love to know how to do this with pure ruby. Any ideas?

I need to query the chef-server, grab a bunch of values, then throw them
into jboss-foo.xml.erb template and compile that template. If you fellow
Chefs see any issues w/ this approach, pls let me know :slight_smile:


#4

On Friday, November 4, 2011 at 8:54 AM, Bryan Berry wrote:

hmm, i could but then I would have to reverse-engineer coderanger’s pychef
https://github.com/coderanger/pychef/blob/master/chef/api.py in order to handle the authentication properly

could be a little challenging
If you’re interested in doing this with ruby, why not use knife exec?

http://wiki.opscode.com/display/chef/Knife+Exec


Dan DeLeo


#5

looks cool, i will investigate that

On Fri, Nov 4, 2011 at 4:59 PM, Daniel DeLeo dan@kallistec.com wrote:

On Friday, November 4, 2011 at 8:54 AM, Bryan Berry wrote:

hmm, i could but then I would have to reverse-engineer coderanger’s
pychef
https://github.com/coderanger/pychef/blob/master/chef/api.py in order
to handle the authentication properly

could be a little challenging
If you’re interested in doing this with ruby, why not use knife exec?

http://wiki.opscode.com/display/chef/Knife+Exec


Dan DeLeo


#6

there’s danryan’s spice gem: https://github.com/danryan/spice
which i’ve used to pull stuff out of databags.

On Fri, Nov 4, 2011 at 15:22, Bryan Berry bryan.berry@gmail.com wrote:

Dear Chefs,
I have a question about how to programmatically get read access to the data
in the chef-repository
We are a java-heavy shop, which mean than configuration gets baked into
software in two places, on our jenkins CI server during the .war build
process and on the target node as well.
I intend to store all the application configuration details in Chef
databags, details like:
target database server:
database auth credentials
clustering info
http port
https port
other ports
I intend to create maven target that grabs such information from the chef
server
I found that I can get read-only access from any server that is a
chef-client
$ knife search jboss_apps “type:production” -c /etc/chef/client.rb -F json
I had to add one value to client.rb to get the above to work
node_name 'foo.example.com
I would love to know how to do this with pure ruby. Any ideas?
I need to query the chef-server, grab a bunch of values, then throw them
into jboss-foo.xml.erb template and compile that template. If you fellow
Chefs see any issues w/ this approach, pls let me know :slight_smile: