Last active
December 2, 2021 15:56
-
-
Save jclaret/763785abe851c9f987d6e243f8242e33 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
# Satellite | |
## Tasks Status | |
sudo su - postgres -c "psql -d foreman -c 'select label,count(label),state,result from foreman_tasks_tasks where state <> '\''stopped'\'' group by label,state,result ORDER BY label;'" | |
## Foreman-rake commands - https://access.redhat.com/solutions/1754193 | |
### Cancel Tasks | |
> foreman-rake console | |
irb(main):001:0> ForemanTasks::Task.find("799bc5fb-2d4c-4d0d-9d7d-4e42e9a8ace8").destroy | |
### Synchronize a repository from CDN | |
> foreman-rake console | |
irb(main):001:0> User.current = User.anonymous_admin | |
irb(main):002:0> repo = ::Katello::Repository.find(4) | |
irb(main):003:0> ForemanTasks.async_task(::Actions::Katello::Repository::Sync, repo) | |
### Manually invoke publishing a repository from a content view (fill :pulp_id and :source_pulp_id accordingly) | |
> foreman-rake console | |
irb(main):001:0> User.current = User.anonymous_admin | |
irb(main):002:0> pulpid = "Default_Organization-Library-test_3-Red_Hat_Enterprise_MRG_Messaging-Red_Hat_Enterprise_MRG_Messaging_3_for_RHEL_6_Server_RPMs_x86_64_6Server" | |
irb(main):003:0> srcpulpid = "Default_Organization-test_3-2_0-Red_Hat_Enterprise_MRG_Messaging-Red_Hat_Enterprise_MRG_Messaging_3_for_RHEL_6_Server_RPMs_x86_64_6Server" | |
irb(main):004:0> ForemanTasks.async_task(::Actions::Pulp::Repository::DistributorPublish, :pulp_id => pulpid, :source_pulp_id => srcpulpid, :distributor_type_id => "yum_clone_distributor") | |
### Manually invoke synchronizing a CV in given LE to a Capsule (fill CAPSULE.FQDN and LE_NAME and CV_NAME accordingly) | |
> foreman-rake console | |
irb(main):001:0> User.current = User.anonymous_admin | |
irb(main):002:0> capsule = ::SmartProxy.find_by_name('CAPSULE.FQDN') | |
irb(main):003:0> env_id = ::Katello::KTEnvironment.find_by_name('LE_NAME').id | |
irb(main):004:0> cv_id = ::Katello::ContentView.find_by_name('CV_NAME').id | |
irb(main):005:0> ForemanTasks.async_task(Actions::Katello::CapsuleContent::Sync, capsule, :environment_id => env_id, :content_view_id => cv_id) | |
### Manually invoke synchronizing a repository to a Capsule (fill :capsule_id and :repo_pulp_id accordingly) | |
> foreman-rake console | |
irb(main):001:0> User.current = User.anonymous_admin | |
irb(main):002:0> ForemanTasks.async_task(::Actions::Pulp::Consumer::SyncCapsule, :capsule_id => 2, :repo_pulp_id => "Red_Hat-Library-cv_test-Red_Hat_Enterprise_Linux_Server-Red_Hat_Satellite_Tools_6_2_for_RHEL_6_Server_RPMs_x86_64") | |
### Cleanup tasks | |
#### Removes any completed task older than 30 days. | |
foreman-rake foreman_tasks:cleanup TASK_SEARCH='' AFTER='30d' VERBOSE=true | |
foreman-rake foreman_tasks:cleanup TASK_SEARCH='label ~ Actions::Katello::CapsuleContent::Sync' STATES='running' VERBOSE=true NOOP=true | |
foreman-rake foreman_tasks:cleanup TASK_SEARCH='label ~ Actions::Katello::CapsuleContent::Sync'STATES='running' VERBOSE=true | |
#### Periodically trim candlepin events (cp_event table) | |
https://bugzilla.redhat.com/show_bug.cgi?id=1591908 | |
echo "delete from cp_event where timestamp < now() - interval '14 days';" | sudo -u postgres psql -d candlepin | |
#### Periodically trim Satellite audits report | |
https://bugzilla.redhat.com/show_bug.cgi?id=1703496 | |
foreman-rake audits:expire days=365 | |
#### Compact mongodb | |
https://access.redhat.com/solutions/3190172 | |
service mongod stop | |
sudo -u mongodb mongod --dbpath /var/lib/mongodb --repair | |
katello-service start | |
#### Compact postgresql | |
katello-service stop | |
systemctl start postgresql.service | |
su - postgres -c 'vacuumdb --full --dbname=foreman' | |
# Capsule | |
## Troubleshoot Capsule | |
https://access.redhat.com/solutions/3344721 | |
## fix a broken repository on Capsule | |
On Capsule: | |
pulpAdminPassword=$(grep ^default_password /etc/pulp/server.conf | cut -d' ' -f2) | |
repo=PulpRepoID | |
curl -i -H "Content-Type: application/json" -X DELETE -u admin:$pulpAdminPassword https://$(hostname -f)/pulp/api/v2/repositories/${repo}/ | |
# MongoDB | |
## Compact MongoDB - https://access.redhat.com/solutions/3190172 | |
>foreman-maintain service stop --exclude=rh-mongodb34-mongod.service | |
>mongodump --host localhost --out /some/path/to/mongo_dump | |
>foreman-maintain service stop --only=rh-mongodb34-mongod.service | |
>sudo -u mongodb mongod --dbpath /var/lib/mongodb --repair | |
## MongoDB Tasks status | |
mongo pulp_database --eval "DBQuery.shellBatchSize = 10000000; db.task_status.find({ 'state': { \$nin : ['cancelled'] }}).shellPrint()" > task_status | |
mongo pulp_database --eval 'printjson(db.task_status.find({"state": {"$in": ["waiting", "running"]}}).toArray())' | |
mongo pulp_database --eval 'printjson(db.task_status.find({"state": {"$in": ["waiting", "running"]}}).toArray())' > tasks.json | |
mongo pulp_database --eval 'printjson(db.task_status.find({"state": {"$in": ["waiting", "running"]}}).count())' | |
## MongoDB Cancel Task | |
mongo pulp_database --eval 'db.task_status.update({"task_id": "7e5e7428-53d1-4662-a227-d20b5afd0e35"}, {$set: {"state": "canceled"}})' | |
# Qpid | |
## Queue Status | |
qpid-stat --ssl-certificate=/etc/pki/pulp/qpid/client.crt -b amqps://localhost:5671 -q | |
qpid-stat --ssl-certificate=/etc/pki/pulp/qpid/client.crt -b amqps://localhost:5671 -q resource_manager | |
## Purge Qpid queues | |
foreman-mantainer service stop --exclude=qpidd | |
qpid-tool --ssl-certificate=/etc/pki/katello/qpid_client_striped.crt -b amqps://localhost:5671 | |
> qpid: list queue (wait 10 seconds) | |
> qpid: call 1545 purge 0 {} | |
foreman-mantainer service restart | |
# Pulp | |
## Pulp Status | |
curl -v https://$(hostname -f)/pulp/api/v2/status/ | python -m json.tool | |
## Change the number of pulp workers | |
edit /etc/default/pulp_workers and place there: | |
PULP_CONCURRENCY=8 | |
## Cancel Pulp Tasks | |
pulpAdminPassword=$(grep ^default_password /etc/pulp/server.conf | cut -d' ' -f2) | |
grep task_id tasks.json | awk -F\" '{print $4}' | xargs -Ixxx pulp-admin -u admin -p $pulpAdminPassword tasks cancel --task-id xxx | |
curl -k -u admin:<pw> -X DELETE "https://localhost/pulp/api/v2/task_groups/ae13786d-a14d-4d30-963b-0e0ed144cef8/" | |
pulp-admin -vv (API queries) |
Listing the django settings can be interesting as well :
sudo -u pulp PULP_SETTINGS='/etc/pulp/settings.py' DJANGO_SETTINGS_MODULE='pulpcore.app.settings' dynaconf list
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi, For Pulp3, if you want to authenticate and run command, here to list all rpm repositories, you can do :
Also a nice command to know, deleting orphan when you have some problem uploading files to repositories :
foreman-rake katello:delete_orphaned_content