Skip to content

Instantly share code, notes, and snippets.

View jlsherrill's full-sized avatar

Justin Sherrill jlsherrill

View GitHub Profile
@jlsherrill
jlsherrill / gist:8cde84fa7a39913c29b10ecb15996591
Created March 2, 2022 14:43
Mirror on sync vs mirroring policy
Mirror on sync in 6.9 and earlier: Would make sure content is added/removed to match upstream repo, would generate new metadata
Mirror on sync in 6.10.0-6.10.2: Would make sure content is added/removed to match upstream repo, would mirror metadata from upstream
Mirroing policy additive: Only adds content, doesn't mirror metadata (The same as mirror on sync off)
Mirroing policy Content Only: Same as "Mirror on sync in 6.9 and earlier"
Mirroing policy Complete: Same as "Mirror on sync in 6.10.0-6.10.2"
@jlsherrill
jlsherrill / delete_repo_reference.md
Created January 18, 2022 21:46
delete repository references on 404
foreman-rake console
Katello::Pulp3::RepositoryReference.all.select do |ref|
  api = Katello::RepositoryTypeManager.repository_types[ref.root_repository.content_type].pulp3_api_class.new(SmartProxy.pulp_primary)
  api.repositories_api.read(ref.repository_href)  
rescue => e
 if e&.code == 404
@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