Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jnikolak/eb4675eabc60d02743e4ba6ebe2c18b4 to your computer and use it in GitHub Desktop.
Save jnikolak/eb4675eabc60d02743e4ba6ebe2c18b4 to your computer and use it in GitHub Desktop.
#DELETE DUPLICATES
# Locate hosts in katello_systems and order themn
su - postgres -c "psql foreman -c \"select uuid,id from katello_systems ORDER BY uuid asc;\"" >/tmp/uuid.out
# In above we have 396 Duplicates Content hosts
# Take that data and uniquely sort out
sort | uniq -d -w 36 /tmp/uuid.out | wc -l
396
# Then we can awk the file to get the id only.
uniq -d -w 36 /tmp/uuid.out | awk '{print $3}' > unique_id.out
# Then we can use hammer
for i in $(cat unique_id.out); do hammer content-host delete --id $i;done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment