Skip to content

Instantly share code, notes, and snippets.

View jeremylenz's full-sized avatar

Jeremy Lenz jeremylenz

  • New York, NY
View GitHub Profile
@jeremylenz
jeremylenz / fam_test_permissions.sh
Created August 30, 2022 15:41
run foreman-ansible-modules tests & VCRs on vagrant box
sudo chown vagrant: -R .
# run this on your workstation
# replace centos8-katello-devel-stable.example.com with your actual VM's hostname
# replace IdentityFile with the location of your identity file from 'vagrant ssh-config <box-name>'
ssh -L *:8080:centos8-katello-devel-stable.example.com:80 -L *:3808:centos8-katello-devel-stable.example.com:3808 -L *:3000:centos8-katello-devel-stable.example.com:3000 -L *:4433:centos8-katello-devel-stable.example.com:443 -o IdentityFile=/home/jeremylenz/code/forklift/.vagrant/machines/centos8-katello-devel-stable/libvirt/private_key vagrant@centos8-katello-devel-stable.example.com
# force import of a new job template erb file
JobTemplate.without_auditing do
template_files = Dir[File.join("#{Katello::Engine.root}/app/views/foreman/job_templates/**/*.erb")]
template_files.reject! { |file| file.end_with?('_ansible_default.erb') } unless Katello.with_ansible?
template_files.each do |template|
sync = !Rails.env.test? && Setting[:remote_execution_sync_templates]
# import! was renamed to import_raw! around 1.3.1
if JobTemplate.respond_to?('import_raw!')
template = JobTemplate.import_raw!(File.read(template), :default => true, :lock => true, :update => sync)
else
sudo yum update qpid-proton-c qpid-proton-c-devel
@jeremylenz
jeremylenz / rubocop.md
Created March 16, 2021 17:44
Get Rubocop working locally when using sshfs

To get Rubocop working with foreman's config, you have to locally install 3 gems:

gem install rubocop
gem install rubocop-rails
gem install rubocop-performance

Then Atom should be able to lint with rubocop.

@jeremylenz
jeremylenz / create_aks.rb
Last active January 20, 2021 19:26
create multiple AKs
include ForemanTasks
org = Organization.find_by(name: 'Default Organization')
cv = Katello::ContentView.find(2)
env = Katello::KTEnvironment.find_by(name: 'Library')
2.times do |idx|
ak = Katello::ActivationKey.new(
name: "ak_#{idx + 1}_#{SecureRandom.uuid.last(4)}",
organization: org,
content_view: cv,
@jeremylenz
jeremylenz / restart-pulp3.sh
Created January 12, 2021 15:16
Restart pulp3 services
sudo systemctl restart pulpcore*
@jeremylenz
jeremylenz / hammer-hack.sh
Last active August 10, 2023 14:50
steal partha's hammer settings and get hammer working on devel box
cd ~/hammer-cli-katello
bundle install
bundle exec bash
cd ~
wget https://partha.fedorapeople.org/devel/hammer.tgz
tar zxf hammer.tgz
ll .hammer # verify there's stuff in that dir
cd hammer-cli-katello
hammer ping
@jeremylenz
jeremylenz / dynflow_task_progress.rb
Created November 11, 2020 15:17
methods for tracking dynflow task progress example
module Actions
module Candlepin
module Owner
class UpstreamUpdate < Candlepin::Abstract
input_format do
param :organization_id
param :upstream
end
def run
rpm -ql tfm-rubygem-katello | head -n 1