Skip to content

Instantly share code, notes, and snippets.

On your Satellite server
# foreman-rake console
...
User.current = User.first
ForemanTasks.async_task(::Actions::Katello::Repository::MetadataGenerate, Katello::Repository.where(pulp_id: "Ten_Capsule_Org-Dev-demo-repos-Demo-demo3").first)
#!/bin/bash
# This will delete all tasks and associated task data from anything older than
# the number of days specified below defaulting to 120 days.
DAYS_AGO=120
echo ""
echo "DELETING All tasks and associated data from [$DAYS_AGO] days ago"
echo ""
@mccun934
mccun934 / gist:f090dd96d667c1fe54726bcf0b06a8f5
Created February 9, 2017 19:14
republish metadata for repo
irb(main):002:0> User.current = User.anonymous_admin
=> #<User id: 1, login: "foreman_admin", firstname: "Anonymous", lastname: "Admin", mail: nil, admin: true,
irb(main):003:0> Katello::Repository.where(id: 1317)
=> #<ActiveRecord::Relation [#<Katello::Repository id: 1317, name: "Red Hat Satellite 6.2 for RHEL 7 Server RPMs x86_6
irb(main):004:0> ForemanTasks.sync_task(::Actions::Katello::Repository::MetadataGenerate, Katello::Repository.where(id: 1317).first)
=> #<ForemanTasks::Task::DynflowTask id: "5170d237-7c78-46d3-8df9-55790413af92", type: "ForemanTasks::Task::DynflowTask", label:
irb(main):005:0>
@mccun934
mccun934 / switch-ondemand.bash
Created February 6, 2017 23:44
switch all repos in org-id 1 to on_demand
for i in $(hammer repository list --organization-id 1 | grep -e "^[[:digit:]]" | awk '{print $1}' | sort -n); do hammer repository update --id $i --download-policy 'on_demand' --organization-id 1; done
@mccun934
mccun934 / gist:e42b74be4a4f6cf67e34a3cb6ece1a06
Created January 31, 2017 18:15
Enable Candlepin CURL API access
# /etc/candlepin/candlepin.conf
candlepin.auth.basic.enable=true
candlepin.auth.trusted.enable=true
@mccun934
mccun934 / gist:5412e46ede9c4692b8666f2a77d51f0d
Created January 28, 2017 15:49
delete / clear qpid queue
# for each of such $queue:
# rm -rf /var/lib/qpidd/.qpidd/qls/jrnl/${queue}
# qpid-config --ssl-certificate=/etc/pki/katello/qpid_client_striped.crt -b amqps://localhost:5671 add queue $queue --durable
@mccun934
mccun934 / capsule-clear.bash
Created January 24, 2017 19:22
This clears all Pulp content from a capsule so it can be re-synced
mongo pulp_database --eval "db.units_distribution.drop();db.units_docker_blob.drop();db.units_docker_image.drop();db.units_docker_manifest.drop();db.units_docker_tag.drop();db.units_drpm.drop();db.units_erratum.drop();db.units_iso.drop();db.units_package_category.drop();db.units_package_environment.drop();db.units_package_group.drop();db.units_puppet_module.drop();db.units_rpm.drop();db.units_srpm.drop();db.units_yum_repo_metadata_file.drop();db.repo_content_units.drop();"
mongo pulp_database --eval 'db.repo_importers.update({"scratchpad": {$ne: null}}, {$set: {"scratchpad.repomd_revision": null}}, {"multi":true})'
rm -rf /var/lib/pulp/content/units/*
// Engineering update
Here are few items to check before doing the ugprade from 6.2.0 to 6.2.7:
1) Verify a qpid queue from 6.1 is actually removed:
# qpid-stat -q --ssl-certificate=/etc/pki/katello/qpid_client_striped.crt -b amqps://localhost:5671 | grep event
make sure you only see 1 line in that, similar to:
https://access.redhat.com/node/208995
# foreman-rake console
Loading production environment (Rails 3.2.8)
irb(main):001:0> ForemanTasks::Task.where(:state => :planned).where(:label => "Actions::Katello::Repository::Sync").destroy_all
irb(main):002:0> ForemanTasks::Task.where(:state => :planned).where(:label => "Actions::Katello::System::GenerateApplicability").destroy_all
irb(main):003:0> ForemanTasks::Task.where(:state => :paused).where(:label => "Actions::Host::GenerateApplicability").destroy_all
irb(main):004:0> ForemanTasks::Task.where(:label => "Actions::Candlepin::ListenOnCandlepinEvents").destroy_all
@mccun934
mccun934 / gist:2d5026e49a1f66d503348c359d6b16a5
Last active March 17, 2017 19:13
Reset the metadata resync flag for all repos
The below method can help cases where content is not synchronizing to your satellite or not updating:
1) Login to the UI, go to Content -> Products -> Red Hat Enterprise Linux ->
find the repo that has the 7.3 packages in it and click the details page
2) On details page there is a 'mirror on sync' setting. Ensure that is set to Yes
3) Go to a terminal and execute this from your root shell on the Satellite:
# curl http://people.redhat.com/~mmccune/reset-resync-flag.bash > reset-resync-flag.bash