Skip to content

Instantly share code, notes, and snippets.

View jlsherrill's full-sized avatar

Justin Sherrill jlsherrill

View GitHub Profile
@jlsherrill
jlsherrill / cleaning_up_missing_content.md
Created December 13, 2021 21:47
cleaning_up_missing_content.md

run:

foreman-rake console

Then inside the console run:

if Katello::Resources::Candlepin::Owner.all
 Katello::Content.all.each do |c| 
@jlsherrill
jlsherrill / ostree_FAM_example.yaml
Created November 5, 2021 19:37
ostree foreman ansible modules example
---
- name: Test Foreman Modules
hosts: localhost
gather_facts: false
collections:
- theforeman.foreman
vars:
validate_certs: "no"
username: "admin"
password: "changeme"
@jlsherrill
jlsherrill / cancel_pulp3_tasks.md
Last active July 26, 2021 22:54
cancel all running and wiating pulp3 tasks
yum install jq  # should be in epel
for href in `curl "https://$(hostname)/pulp/api/v3/tasks/?state=running&state=waiting"  --cert /etc/pki/katello/certs/pulp-client.crt --key /etc/pki/katello/private/pulp-client.key | jq '.results[].pulp_href' | awk -F '"' '{print $2}'`; do echo "https://$(hostname)$href" ;   curl "https://$(hostname)$href" -X PATCH -d '{"state": "canceled"}'  -H "Content-Type: application/json"  --cert /etc/pki/katello/certs/pulp-client.crt --key /etc/pki/katello/private/pulp-client.key ; done 



@jlsherrill
jlsherrill / adding_md5_katello_pulp3.md
Created July 23, 2021 18:27
adding md5 checksum to pulp3
PULP_SETTINGS='/etc/pulp/settings.py'  pulpcore-manager --report  handle-artifact-checksums  --checksums md5,sha1,sha224,sha256,sha384,sha512
foreman-installer     --foreman-proxy-content-pulpcore-allowed-content-checksums md5 \
    --foreman-proxy-content-pulpcore-allowed-content-checksums sha1 \
    --foreman-proxy-content-pulpcore-allowed-content-checksums sha224 \
    --foreman-proxy-content-pulpcore-allowed-content-checksums sha256 \
    --foreman-proxy-content-pulpcore-allowed-content-checksums sha384 \
 --foreman-proxy-content-pulpcore-allowed-content-checksums sha512
@jlsherrill
jlsherrill / cursor_not_found_fix.md
Last active April 22, 2021 17:36
Cursor not found during content migration
Prepare content for Pulp 3: 
Checking for valid Katello configuraton.
Starting task.
2021-04-21 20:50:47 -0400: Pre-migrating Pulp 2 ERRATUM content (general info) 43078/57958Migration failed, You will want to investigate: https://dhcp-8-29-228.lab.eng.rdu2.redhat.com/foreman_tasks/tasks/6b1d5918-1ecd-4628-b77f-ae128352c85e
rake aborted!
ForemanTasks::TaskError: Task 6b1d5918-1ecd-4628-b77f-ae128352c85e: Katello::Errors::Pulp3Error: Cursor not found, cursor id: 179922846418, full error: {'ok': 0.0, 'errmsg': 'Cursor not found, cursor id: 179922846418', 'code': 43, 'codeName': 'CursorNotFound'}
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.18.1.27/lib/katello/tasks/pulp3_migration.rake:35:in `block (2 levels) in <top (required)>'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => katello:pulp3_migration
@jlsherrill
jlsherrill / puppet_module_test_tips.txt
Created April 20, 2021 14:02
puppet module test tips
SPEC_FACTS_OS=redhat-7-x86_64 rake spec
bundle exec rake lint
@jlsherrill
jlsherrill / extract_certs.rb
Created February 4, 2021 00:38
extract repo certs
org = Organization.find(1)
path = Dir.mktmpdir("pulp-certs")
Katello::Repository.yum_type.in_default_view.in_organization(org).each do |repo|
filename = File.join(path, "#{repo.product.label}-#{repo.label}")
importer = repo.pulp_repo_facts['importers'].find{|i| i['id'] == 'yum_importer'}
if importer && importer['config']['ssl_client_cert']
combined = importer['config']['ssl_client_cert'] + importer['config']['ssl_client_key']
File.open(filename, 'w'){|file| file.write(combined) }
puts "Wrote #{filename}"
@jlsherrill
jlsherrill / testing_applicability_speed.rb
Created February 1, 2021 12:56
testing applicability speed
#testing applicability speed
def time
a = Time.now
yield
Time.now - a
end
count = 300
offset = rand(Katello::Host::ContentFacet.count) - count
@jlsherrill
jlsherrill / gist:fc38931fa490db98cfce59daba9849f6
Created January 18, 2021 21:53
Pulp3 migration treat all files as on_demand (not downloaded)
diff --git a/pulp_2to3_migration/app/pre_migration.py b/pulp_2to3_migration/app/pre_migration.py
index 899a08c..4adcd68 100644
--- a/pulp_2to3_migration/app/pre_migration.py
+++ b/pulp_2to3_migration/app/pre_migration.py
@@ -151,7 +151,7 @@ def pre_migrate_content_type(content_model, mutable_type, lazy_type, premigrate_
pulp2detail_pb.total -= 1
continue
- downloaded = record.downloaded if hasattr(record, 'downloaded') else False
+ downloaded = False
@jlsherrill
jlsherrill / gist:7c9f244f4674f2d27684a1f9bba831b0
Created October 23, 2020 15:13
katello-agent replacement POC
require 'qpid_proton'
MESSAGE = '{"data": {"consumer_id": "e6c21274-e8a2-4484-a4cb-8d4edba0710b", "task_id": "abcd"}, "pam": null, "replyto": "pulp.task", "request": {"args": [[{"type_id": "rpm", "unit_key": {"name": "screen"}}], {"importkeys": true}], "classname": "Content", "cntr": [[], {}], "kws": {}, "method": "uninstall"}, "routing": [null, "pulp.agent.e6c21274-e8a2-4484-a4cb-8d4edba0710b"], "secret": "abcdefg", "sn": "23fc34ce-2992-45df-91cc-4169f62d0e5f", "version": "2.0"}'
class SimpleSend < Qpid::Proton::MessagingHandler
def initialize(url, address, expected)
super()
@url = url
@address = address