Last active
February 1, 2021 22:05
-
-
Save ohadlevy/1620981 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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