Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. this_time = Time.new
  2.  
  3. ruby_block 'Update sshd_config' do
  4. block do
  5. begin
  6. file = Chef::Util::FileEdit.new('/etc/ssh/sshd_config')
  7. rescue StandardError => e
  8. puts "==>### ERROR: #{e.message}"
  9. end
  10. file.search_file_replace_line(/#?GSSAPIAuthentication yes/, "GSSAPIAuthentication no #Updated by Chef #{this_time.inspect}")
  11. file.search_file_replace_line(/#?UseDNS yes/, "UseDNS no #Updated by Chef #{this_time.inspect}")
  12. if file.unwritten_changes?
  13. file.write_file
  14. notifies :restart, 'service[sshd]', :immediately
  15. end
  16. end
  17. end
  18.  
  19. service 'sshd' do
  20. action :nothing
  21. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement