Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this_time = Time.new
- ruby_block 'Update sshd_config' do
- block do
- begin
- file = Chef::Util::FileEdit.new('/etc/ssh/sshd_config')
- rescue StandardError => e
- puts "==>### ERROR: #{e.message}"
- end
- file.search_file_replace_line(/#?GSSAPIAuthentication yes/, "GSSAPIAuthentication no #Updated by Chef #{this_time.inspect}")
- file.search_file_replace_line(/#?UseDNS yes/, "UseDNS no #Updated by Chef #{this_time.inspect}")
- if file.unwritten_changes?
- file.write_file
- notifies :restart, 'service[sshd]', :immediately
- end
- end
- end
- service 'sshd' do
- action :nothing
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement