How to use setuped credentials and parameters in ruby script to access with Chef::REST?

Knife can operate with chef server normally, by using knife.rb and saved
admin.pem in user home.

I have script on chef admin’s machine and I want that this script can
operate with chef server with same configs as knife operate with it. I.e.
without additional configuration as follows:

Define chef server parameters

chef_server_url="https://chef.example.com"
client_name = "adminws.example.local"
signing_key_filename="/etc/chef/client.pem"

That’s part of this script, where i need this variables:

Operate with chef server:

rest = Chef::REST.new(chef_server_url, client_name,

signing_key_filename)
#puts rest.get_rest("/data/#{bag}/#{item}")
rest.get_rest("/data/#{bag}/#{item}")

How i can make my script “universe”?


Faithfully yours,

CVision Lab System Administrator
Vladimir Skubriev

On Tuesday, August 26, 2014 at 3:44 AM, Vladimir Skubriev wrote:

Knife can operate with chef server normally, by using knife.rb and saved admin.pem in user home.

I have script on chef admin's machine and I want that this script can operate with chef server with same configs as knife operate with it. I.e. without additional configuration as follows:

Define chef server parameters

chef_server_url="https://chef.example.com"
client_name = "adminws.example.local"
signing_key_filename="/etc/chef/client.pem"

...

That's part of this script, where i need this variables:
...

Operate with chef server:

rest = Chef::REST.new(chef_server_url, client_name, signing_key_filename)
#puts rest.get_rest("/data/#{bag}/#{item}")
rest.get_rest("/data/#{bag}/#{item}")

...

How i can make my script "universe"?

--
Faithfully yours,

CVision Lab System Administrator
Vladimir Skubriev

Sorry for the late reply here. Probably your easiest option is to write your own knife plugin: Writing Custom Knife Plugins

--
Daniel DeLeo

Sorry for the late reply here.

No problem. That's OK.

Probably your easiest option is to write your own knife plugin:
Writing Custom Knife Plugins

Now I do not have a lot of time. I developing small project for self using.

https://github.com/cvisionlabops/keepassxml2chef

What do you think about it ?

I think writing knife-plugin is overkill for one human now.

But If people interested in it, then I think this is possible!

--
Daniel DeLeo

--
Faithfully yours,

CVision Lab System Administrator
Vladimir Skubriev

On Thursday, August 28, 2014 at 7:51 AM, Vladimir Skubriev wrote:

Sorry for the late reply here.
No problem. That's OK.
Probably your easiest option is to write your own knife plugin: Writing Custom Knife Plugins

Now I do not have a lot of time. I developing small project for self using.

https://github.com/cvisionlabops/keepassxml2chef

What do you think about it ?

I think writing knife-plugin is overkill for one human now.
Knife plugins are pretty easy, especially compared to the work you’ve already done. Here is a bare minimum knife plugin (sorry the formatting sucks):

module ThisIsAnExample
class Example < Chef::Knife
def run
puts "HELLLLOOOOOOO"
end
end
end

Put that in ~/.chef/plugins/knife/example.rb and then you can run knife example.

But If people interested in it, then I think this is possible!
Looks pretty cool, but we’re using a different password manager, so not something we can use ourselves.

--
Faithfully yours,

CVision Lab System Administrator
Vladimir Skubriev

--
Daniel DeLeo

Thank you for example. As soon as free time I am try to bring this to life.

As I uderstand if i place my code in placeholder, then i don't need to auth
with server. The code does this itself.

What password manager do you use ? I only know keepassx )

2014-08-28 19:01 GMT+04:00 Daniel DeLeo dan@kallistec.com:

On Thursday, August 28, 2014 at 7:51 AM, Vladimir Skubriev wrote:

Sorry for the late reply here.
No problem. That's OK.
Probably your easiest option is to write your own knife plugin:
Writing Custom Knife Plugins

Now I do not have a lot of time. I developing small project for self
using.

https://github.com/cvisionlabops/keepassxml2chef

What do you think about it ?

I think writing knife-plugin is overkill for one human now.
Knife plugins are pretty easy, especially compared to the work you’ve
already done. Here is a bare minimum knife plugin (sorry the formatting
sucks):

module ThisIsAnExample
class Example < Chef::Knife
def run
puts "HELLLLOOOOOOO"
end
end
end

Put that in ~/.chef/plugins/knife/example.rb and then you can run knife example.

But If people interested in it, then I think this is possible!
Looks pretty cool, but we’re using a different password manager, so not
something we can use ourselves.

--
Faithfully yours,

CVision Lab System Administrator
Vladimir Skubriev

--
Daniel DeLeo

--
Faithfully yours,

CVision Lab System Administrator
Vladimir Skubriev

On Friday, August 29, 2014 at 12:15 AM, Vladimir Skubriev wrote:

Thank you for example. As soon as free time I am try to bring this to life.

As I uderstand if i place my code in placeholder, then i don't need to auth with server. The code does this itself.

Knife will locate your config file and evaluate it, so that Chef::Config[:node_name] and such are populated with the correct values. Chef::REST.new will use this config if you don’t provide specific values as arguments. See: https://github.com/opscode/chef/blob/d1350f296095ff70baafbd4f5fa1e3737a4924d2/lib/chef/rest.rb#L59

What password manager do you use ? I only know keepassx )
We’re using lastpass

--
Daniel DeLeo

Thank you for a tip's.

I know about lastpass. There is another beautiful app for strore passwd.

2014-08-29 20:14 GMT+04:00 Daniel DeLeo dan@kallistec.com:

On Friday, August 29, 2014 at 12:15 AM, Vladimir Skubriev wrote:

Thank you for example. As soon as free time I am try to bring this to
life.

As I uderstand if i place my code in placeholder, then i don't need to
auth with server. The code does this itself.

Knife will locate your config file and evaluate it, so that
Chef::Config[:node_name] and such are populated with the correct values.
Chef::REST.new will use this config if you don’t provide specific values
as arguments. See:
https://github.com/opscode/chef/blob/d1350f296095ff70baafbd4f5fa1e3737a4924d2/lib/chef/rest.rb#L59

What password manager do you use ? I only know keepassx )
We’re using lastpass

--
Daniel DeLeo

--
Faithfully yours,

CVision Lab System Administrator
Vladimir Skubriev