Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Works with Satellite 6.5 and later
# https://access.redhat.com/solutions/2273561
rm -f /etc/candlepin/certs/keystore
rm -f /etc/candlepin/certs/truststore
rm -f /etc/tomcat/truststore
rm -f /etc/candlepin/certs/amqp/*
rm -rf /etc/pki/katello/nssdb/*
@mccun934
mccun934 / deleted_puppet_envs65-later.md
Last active February 1, 2023 19:35 — forked from jlsherrill/deleted_puppet_envs.md
recover from deleted puppet environments from 6.5 or later

when publishing a content view if you get:

Validation failed: Puppet environment can't be blank

or

ActiveRecord::RecordInvalid: Validation failed: Name has already been taken
namespace :taskbench do
desc <<~END_DESC
Loads up some tasks
END_DESC
def parallelize(param_lists)
max_number_of_forks ||= ENV['forks'].to_i || 10
page = 0
page_size = param_lists.length/max_number_of_forks
namespace :taskbench do
desc <<-END_DESC
Loads up some tasks
END_DESC
def parallelize(param_lists, max_number_of_forks = 20)
page = 0
page_size = max_number_of_forks
@mccun934
mccun934 / taskbench.rake
Last active July 1, 2019 21:26
taskbench.rake
namespace :taskbench do
desc <<-END_DESC
Loads up some tasks
END_DESC
task :hostupdate => :environment do
puts 'Starting task load..'
User.current = User.anonymous_admin
for y in 0..100
@mccun934
mccun934 / gist:879cefe4ce6cd39e70fe8058e8bca2a2
Created May 15, 2019 21:48
postgres settings without comments or whitespace
cat postgresql.conf |awk '{$1=$1};1' |grep -v "^#" | egrep -v "^[ ]*$|^#" |more
@mccun934
mccun934 / gist:b25876d81d8940be1f758370b84b4e30
Created March 28, 2019 17:17
Sequel::Migrator::Error: More than 1 row in migrator table
# foreman-rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
TABLE dynflow_schema_info
rake aborted!
Sequel::Migrator::Error: More than 1 row in migrator table
/opt/theforeman/tfm/root/usr/share/gems/gems/sequel-4.20.0/lib/sequel/extensions/migration.rb:590:in `schema_dataset'
/opt/theforeman/tfm/root/usr/share/gems/gems/sequel-4.20.0/lib/sequel/extensions/migration.rb:444:in `initialize'
@mccun934
mccun934 / mem-process-sum
Created March 25, 2019 16:26
sum up the ram used by all processes with a given name.
#!!bin/bash
# requires 'bc' installed
# Sum up the RAM used by processes with given name
# eg:
# $ mem-process-sum postgres
# 1.6777 GB
ps aux | sort -nk6 |grep $1 | awk '{print $6}' | paste -sd+ | bc | awk '{$1=$1/(1024^2); print $1,"GB";}'
@mccun934
mccun934 / publish-loop.bash
Created March 16, 2019 14:36
republish all content views in a loop
while true;
do
hammer --no-headers --csv content-view list | grep -v "Default Org" | awk -F, '{print $1}' | xargs -I arg1 -n 1 hammer -u admin -p changeme content-view publish --id arg1;
done
## Logging
ErrorLog "/var/log/httpd/foreman-ssl_error_ssl.log"
ServerSignature Off
CustomLog "/var/log/httpd/foreman-ssl_access_ssl.log" combined
# Add custom forwarded log to track origin IP addresses through a smart-proxy
CustomLog "/var/log/httpd/foreman-ssl_forwarded_ssl.log" forwarded