Guest User

Untitled

a guest
Feb 28th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #!/usr/bin/ruby
  2.  
  3. require 'rubygems'
  4. require 'chef'
  5. require 'chef/node'
  6. require 'chef/rest'
  7.  
  8. # A registration for your API access
  9. api_user = "monkey"
  10. # A password for the API access
  11. api_pass = "pants"
  12. # A validation token, if you use them
  13. validation_token = nil
  14. # The name of a node to look up - replace dots with _
  15. node_name = "latte_local"
  16.  
  17. rest = Chef::REST.new(Chef::Config[:registration_url])
  18.  
  19. ## Basically, all this tear up stuff should be replaced with
  20. ## two method calls when CHEF-66 gets closed.
  21.  
  22. # First, we're going to create a false registration for
  23. # API access
  24. rest.register(api_user, api_pass, validation_token)
  25.  
  26. # Then we authenticate
  27. rest.authenticate(api_user, api_pass)
  28.  
  29. # Now you can do whatever you want, assuming you are validated
  30. node = rest.get_rest("nodes/#{node_name}")
  31. node[:signal] = "noise"
  32.  
  33. # Save it
  34. rest.put_rest("nodes/#{node_name}", node)
Add Comment
Please, Sign In to add comment