Last active
January 19, 2023 14:01
-
-
Save JRNC/62ebe4b9045ed06420f26be0d878e7e0 to your computer and use it in GitHub Desktop.
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
HOSTS=$(hammer host list --fields Id | grep -v ID | grep -v -- --) | |
for i in ${HOSTS} | |
do | |
subscriptions=$(hammer host subscription product-content --host-id $i --fields Name | grep -v "Red Hat" | grep -v "NAME" | grep -v -- ----------------------------------------------------------------------------) | |
echo "$subscriptions" > "$i" | |
hash=$(sha256sum $i | cut -d " " -f 1) | |
rm $i | |
echo $i >> $hash | |
echo $hash >> array | |
done | |
awk -i inplace '!seen[$0]++' array | |
while read hash | |
do | |
hammer host-collection create --name $hash --organization "CHANGEME" | |
ids=$(paste -d, -s $hash) | |
hammer host-collection add-host --name $hash --host-ids $ids --organization "CHANGEME" | |
done <array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script will identify and group hosts in Satellite that share the same exact set of subscriptions and create a host collection per grouping. This is helpful for teams that are preparing to enable Simple Content Access; however, need to first disable all of the unsubscribed repositories that set themselves to enabled by default. Instead of disabling unsubscribed repositories host by host, this will trim it down, so that you can disable unsubscribed repositories host collection by host collection. It is not perfect, but it decreases the amount of time required to perform this task.
This script should be run within its own dedicated directory (ideally), as it will create many files as part of the work that it is performing.
DISCLAIMER
This script is being made available publicly without support or guarantee of proper functionality. Please modify the script as you see fit for your needs and always test in a NON-production environment and ensure proper functionality for yourself.