Skip to content

Instantly share code, notes, and snippets.

@ohadlevy
Last active February 1, 2021 22:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohadlevy/1620981 to your computer and use it in GitHub Desktop.
Save ohadlevy/1620981 to your computer and use it in GitHub Desktop.
#! /usr/share/foreman/script/rails runner -e production
Host.all.each do |host|
next unless host.dhcp?
print "#{host}..."
dhcp_record = host.dhcp_record
if dhcp_record.valid?
puts "VALID"
elsif dhcp_record.conflicting?
puts "CONFLICT"
warn "not going to do anything as we found conflicting dhcp records"
warn "we wanted #{dhcp_record.attrs.inspect} but found: #{dhcp_record.conflicts.map{|c| c.attrs.inspect}.join(', ')}"
else
print "missing..recreating.."
dhcp_record.create
puts "DONE"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment