Last active
November 10, 2015 20:53
-
-
Save brandonweeks/71c860bc01d874bac8b5 to your computer and use it in GitHub Desktop.
Helpful Foreman queries
This file contains 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
-- Find hosts where name doesn't match certname | |
SELECT name,certname | |
FROM hosts | |
WHERE name != certname; | |
-- Find duplicate nics | |
SELECT count(*), host_id, identifier FROM nics GROUP BY host_id, identifier HAVING COUNT(*) > 1; | |
-- Cleanup duplicate nics | |
DELETE FROM nics | |
WHERE id in (SELECT MAX(id) | |
FROM nics | |
GROUP BY host_id, identifier | |
HAVING COUNT(*) > 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment