Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
katello-service stop
systemctl start postgresql
echo ""
echo "DELETING All task data"
echo ""
TABLE_COUNTS="select count(*) as foreman_tasks_tasks from foreman_tasks_tasks;
#!/bin/bash
echo '
SELECT table_name, pg_size_pretty(total_bytes) AS total
, pg_size_pretty(index_bytes) AS INDEX
, pg_size_pretty(toast_bytes) AS toast
, pg_size_pretty(table_bytes) AS TABLE
FROM (
SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes FROM (
@mccun934
mccun934 / create-queues.bash
Last active March 19, 2018 15:16
non parallel queue recreate
#!/bin/bash
recreateq(){
qpid-config --ssl-certificate=/etc/pki/katello/qpid_client_striped.crt -b amqps://localhost:5671 add queue pulp.agent.${1} --durable;
}
echo ""
echo "*** Clearing old qpid journal files.."
echo ""
# EG : ALTER USER Postgres WITH PASSWORD '<newpassword>';
CP_PASS=`grep jpa.config.hibernate.connection.password /etc/candlepin/candlepin.conf | awk -F= '{print $2}'`
F_PASS=`grep password /etc/foreman/database.yml | awk -F: '{print $2}' | sed 's/"//g'`
echo "ALTER USER candlepin WITH PASSWORD '$CP_PASS';" | sudo -u postgres psql
echo "ALTER USER foreman WITH PASSWORD '$F_PASS';" | sudo -u postgres psql
@mccun934
mccun934 / queue-create-p.bash
Created March 15, 2018 16:12
Qpid queue recreate in parallel
#!/bin/bash
recreateq(){
qpid-config --ssl-certificate=/etc/pki/katello/qpid_client_striped.crt -b amqps://localhost:5671 add queue pulp.agent.${1} --durable;
}
echo ""
echo "*** Clearing old qpid journal files.."
echo ""
@mccun934
mccun934 / setup-pulp-admin.bash
Last active March 13, 2018 17:09
Setup Pulp Admin
#!/bin/bash
pulpversion=$(rpm -qa pulp-server --queryformat "%{VERSION}")
yum -y install pulp-admin-client-${pulpversion} pulp-rpm-admin-extensions.noarch pulp-rpm-handlers.noarch
sed -i.bak "20,30s/^# host:.*/host: $(hostname -f)/g" /etc/pulp/admin/admin.conf
mkdir ~/.pulp
sudo cat /etc/pki/katello/certs/pulp-client.crt /etc/pki/katello/private/pulp-client.key > ~/.pulp/user-cert.pem
pulp-admin tasks list
@mccun934
mccun934 / sat-62-certs-regenerate.sh
Last active February 28, 2018 20:15
6.2 Certs Reset Regenerate
rm -rfv /etc/pki/katello{,.bak}
rm -rfv /etc/pki/katello-certs-tools{,.bak}
rm -rfv /etc/candlepin/certs/amqp{,.bak}
rm -rfv /etc/foreman-proxy/*ssl*
rm -rfv /etc/foreman/old-certs
rm -rfv /etc/foreman/*.pem
rm -rfv /var/lib/puppet/ssl
rm -rfv /root/ssl-build
satellite-installer --scenario satellite -v --certs-regenerate-ca=true --certs-regenerate=true
@mccun934
mccun934 / gist:6711c249ab077dfa8d7d526dcc501a8a
Created February 13, 2018 13:41
delete orphan dynflow data
cat <<EOF | foreman-rake console
persistence = ForemanTasks.dynflow.world.persistence
adapter = persistence.adapter
batch_size = 5
total = adapter.db.fetch("select count(dynflow_execution_plans.uuid) from dynflow_execution_plans left join foreman_tasks_tasks on (dynflow_execution_plans.uuid = foreman_tasks_tasks.external_id) where foreman_tasks_tasks.id IS NULL").first[:count]
deleted = 0
puts "about to delete #{total} execution plans"
while (plans_without_tasks = adapter.db.fetch("select dynflow_execution_plans.uuid from dynflow_execution_plans left join foreman_tasks_tasks on (dynflow_execution_plans.uuid = foreman_tasks_tasks.external_id) where foreman_tasks_tasks.id IS NULL LIMIT #{batch_size}").all.map { |x| x[:uuid] }) && !plans_without_tasks.empty?
persistence.delete_execution_plans({ 'uuid' => plans_without_tasks }, batch_size)
#!/bin/bash
###################################
# USAGE:
# ./subs-export.csv.bash <ORG NAME>
#
# NOTE: If you run this without the
# organization name as a parameter
# it will return 0 results.
###################################
@mccun934
mccun934 / task-cleanup.bash
Created February 8, 2018 15:42
Common task cleanup commands
# Delete all paused
foreman-rake foreman_tasks:cleanup TASK_SEARCH='label ~ *' AFTER='0d' STATES=paused VERBOSE=true
# Delete all stopped
foreman-rake foreman_tasks:cleanup TASK_SEARCH='label ~ *' AFTER='0d' STATES=stopped VERBOSE=true
# Delete everything