Skip to content

Instantly share code, notes, and snippets.

Avatar

Justin Sherrill jlsherrill

View GitHub Profile
@jlsherrill
jlsherrill / ostree_FAM_example.yaml
Created Nov 5, 2021
ostree foreman ansible modules example
View ostree_FAM_example.yaml
---
- 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 Jul 26, 2021
cancel all running and wiating pulp3 tasks
View cancel_pulp3_tasks.md
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 Jul 23, 2021
adding md5 checksum to pulp3
View adding_md5_katello_pulp3.md
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 Apr 22, 2021
Cursor not found during content migration
View cursor_not_found_fix.md
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
View puppet_module_test_tips.txt
SPEC_FACTS_OS=redhat-7-x86_64 rake spec
bundle exec rake lint
View extract_certs.rb
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}"
View testing_applicability_speed.rb
#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 Jan 18, 2021
Pulp3 migration treat all files as on_demand (not downloaded)
View gist:fc38931fa490db98cfce59daba9849f6
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
View gist:7c9f244f4674f2d27684a1f9bba831b0
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
View importing_older_postgresql_data.sh
#mount large filesystem (200GB) onto /mnt/
setenforce 0
cd /mnt/
tar -xzf pgsql_data.tar.gz
#link /var/lib/pgsql from /mnt