Skip to content

Instantly share code, notes, and snippets.

@brandonweeks
Last active November 10, 2015 20:53
Show Gist options
  • Save brandonweeks/71c860bc01d874bac8b5 to your computer and use it in GitHub Desktop.
Save brandonweeks/71c860bc01d874bac8b5 to your computer and use it in GitHub Desktop.
Helpful Foreman queries
-- 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