Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- require 'rubygems'
- require 'chef'
- require 'chef/node'
- require 'chef/rest'
- # A registration for your API access
- api_user = "monkey"
- # A password for the API access
- api_pass = "pants"
- # A validation token, if you use them
- validation_token = nil
- # The name of a node to look up - replace dots with _
- node_name = "latte_local"
- rest = Chef::REST.new(Chef::Config[:registration_url])
- ## Basically, all this tear up stuff should be replaced with
- ## two method calls when CHEF-66 gets closed.
- # First, we're going to create a false registration for
- # API access
- rest.register(api_user, api_pass, validation_token)
- # Then we authenticate
- rest.authenticate(api_user, api_pass)
- # Now you can do whatever you want, assuming you are validated
- node = rest.get_rest("nodes/#{node_name}")
- node[:signal] = "noise"
- # Save it
- rest.put_rest("nodes/#{node_name}", node)
Add Comment
Please, Sign In to add comment