Skip to content

Instantly share code, notes, and snippets.

@wbclark
Created August 12, 2020 14:35
Show Gist options
  • Save wbclark/b647987d18538c4850fec9ec38067adf to your computer and use it in GitHub Desktop.
Save wbclark/b647987d18538c4850fec9ec38067adf to your computer and use it in GitHub Desktop.

Revisions

  1. wbclark created this gist Aug 12, 2020.
    29 changes: 29 additions & 0 deletions import-pools-refresh-repos.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    #!/bin/bash

    echo "Importing Subscription Pools from Candlepin."

    echo '
    namespace :katello do
    task :import_subscriptions => ["environment"] do
    User.current = User.anonymous_api_admin
    puts _("Importing Subscriptions")
    Katello::Subscription.import_all
    Katello::Pool.import_all
    end
    end
    ' | foreman-rake console

    echo "Refreshing repository certificates."

    echo '
    organizations = Organization.all
    organizations.each do |org|
    repositories = ::Katello::Repository.in_default_view.in_product(::Katello::Product.redhat.in_org(org))
    repositories.each do |repo|
    task = ForemanTasks.async_task(Actions::Katello::Repository::RefreshRepository, repo)
    puts "task.id #{task.id}"
    end
    end
    ' | foreman-rake console

    echo "Repository refresh tasks initiated. Please check Monitor -> Tasks to verify when complete."