Skip to content

Instantly share code, notes, and snippets.

@wbclark
Created June 28, 2022 23:06
Show Gist options
  • Save wbclark/489781bc4d146e554c1103c72e934c2a to your computer and use it in GitHub Desktop.
Save wbclark/489781bc4d146e554c1103c72e934c2a to your computer and use it in GitHub Desktop.
Clear smart_proxy_sync_histories for repositories for repositories on Red Hat Satellite, by passing a list of repository IDs
# This script clears the smart_proxy_sync_history for a set of repositories on Satellite, from a list of repository IDs.
#
# This is useful when you want to guarantee these repositories are synchronized on Capsules (with the Library environment) on the
# next 'Optimized' sync that is run, without having to run a full 'Complete' sync of the Capsule.
#
# The only required input is a list (Ruby Array) of repository_ids, on the first non-comment line below this documentation.
# Edit this Array of repository_ids to match the repository IDs that should be eligible for the next optimized syncs.
#
# For example, if I have the following repositories on Satellite:
#
# # hammer repository list --organization-id 1 --fields id,name
# ---|---------------------------------------------------------------------------------
# ID | NAME
# ---|---------------------------------------------------------------------------------
# 6 | Red Hat Ansible Engine 2.9 RPMs for Red Hat Enterprise Linux 7 Server x86_64
# 1 | Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server
# 3 | Red Hat Satellite Capsule 6.10 for RHEL 7 Server RPMs x86_64
# 4 | Red Hat Satellite Maintenance 6 for RHEL 7 Server RPMs x86_64
# 2 | Red Hat Satellite Tools 6.10 for RHEL 7 Server RPMs x86_64
# 5 | Red Hat Software Collections RPMs for Red Hat Enterprise Linux 7 Server x86_6...
# ---|---------------------------------------------------------------------------------
#
# And I want to sync Red Hat Satellite Tools 6.10 and Ansible Engine 2.9 on the next 'Optimized' Capsule sync,
# then I'll edit the Array below to have the values 2 and 6
repository_ids = [2, 6]
repository_ids.each { |repo_id| Katello::Repository.find(repo_id).clear_smart_proxy_sync_histories }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment