Skip to content

Instantly share code, notes, and snippets.

@rcmorano
Created December 20, 2011 12:45
Show Gist options
  • Save rcmorano/1501462 to your computer and use it in GitHub Desktop.
Save rcmorano/1501462 to your computer and use it in GitHub Desktop.
Create a databag through Chef's REST API
#!/usr/bin/ruby
require 'chef/config'
require 'chef/log'
require 'chef/rest'
$chef_server_url = "https://localhost"
$client_name = "chef-admin"
$signing_key_filename="/root/.chef/chef-admin.pem"
rest = Chef::REST.new($chef_server_url, $client_name, $signing_key_filename)
unless rest.get_rest('/data/').include? 'users'
databag = {
"name" => "users"
}
rest.post_rest('/data/',databag)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment