Guest User

Untitled

a guest
Apr 16th, 2018
112
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/env ruby
  2.  
  3. #require File.dirname(__FILE__) + '/../../lib/nanite'
  4. require 'rubygems'
  5. require 'eventmachine'
  6. require 'nanite'
  7. require 'chef'
  8. require 'json'
  9.  
  10. EM.run do
  11.  
  12. Nanite.start_mapper(:host => 'localhost', :user => 'nanite', :pass => 'testing', :vhost => '/nanite', :log_level => 'debug')
  13.  
  14. resource = Chef::Resource::Package.new('telnet')
  15.  
  16. resource.action('install')
  17. resource.provider(Chef::Provider::Package::Yum)
  18.  
  19. payload = { :resource => resource }
  20.  
  21. # sfdchef01 is the chef server
  22. # sfdchef02 is the client which is running this script and the agent on port 8000
  23. server_name = 'sfdchef02.monster.com'
  24.  
  25. EM.add_timer(16) do
  26.  
  27. # Seems to hang after it gets inside the EM loop on the nanite request below
  28.  
  29. r = Nanite.mapper.request('/control/resource', payload, :target => server_name) do |response_full|
  30.  
  31. # Never gets here.
  32.  
  33. EM.stop_event_loop
  34. end
  35. end
  36. end
Add Comment
Please, Sign In to add comment