Skip to content

Instantly share code, notes, and snippets.

View sayan3296's full-sized avatar

Sayan Das sayan3296

  • Red Hat Inc.
  • Pune, India
  • 00:26 (UTC +05:30)
View GitHub Profile
@sayan3296
sayan3296 / register_to_satellite.yaml
Created December 8, 2023 11:45
register_to_satellite using Global Registration Method
---
# vim: ts=2 sw=2 ai expandtab
- name: Register to Satellite
  hosts: clients
  connection: smart
  gather_facts: true
  become: true
  vars_files:
    - satellite_credentials.yml
@sayan3296
sayan3296 / foreman-rake db:migrate VERSION=0 SCOPE=foreman_puppet
Created November 24, 2023 12:00
foreman-rake db:migrate VERSION=0 SCOPE=foreman_puppet
I, [2023-11-24 16:30:23+0530 #155557] INFO -- : --- Execution step 'Check for Puppet capsules from the database' finished ---
I, [2023-11-24 16:30:23+0530 #155557] INFO -- : --- Execution step 'Remove Puppet feature' [puppet-remove-puppet] started ---
D, [2023-11-24 16:30:23+0530 #155557] DEBUG -- : Running command rpm -q 'rubygem-foreman_puppet' with stdin nil
D, [2023-11-24 16:30:23+0530 #155557] DEBUG -- : output of the command:
rubygem-foreman_puppet-5.0.0-1.el8sat.noarch
D, [2023-11-24 16:30:23+0530 #155557] DEBUG -- : Running command foreman-rake db:migrate VERSION=0 SCOPE=foreman_puppet with stdin nil
D, [2023-11-24 16:30:37+0530 #155557] DEBUG -- : output of the command:
== 20220421204325 DropEnvironmentFromHostAndHg: reverting =====================
== 20220421204325 DropEnvironmentFromHostAndHg: reverted (0.0000s) ============
@sayan3296
sayan3296 / Cleanup stale and Re-enable puppet
Created November 24, 2023 10:11
Properly cleanup broken DB after puppet purge and then re-enable puppet
First step,
--> Cascade delete two offending tables
--> and delete these migrations i.e. 20090905150132 20101121140000 20201125113903 20200803113803 20200722171017 20200803113531 20200803113903 20211111125003 from schema_migration tables
Command to do both at once:
# cat << EOF |foreman-rake console
User.current = User.anonymous_admin
ActiveRecord::Base.connection.drop_table(:hostgroup_puppet_facets, if_exists: true, force: :cascade)
ActiveRecord::Base.connection.drop_table(:host_puppet_facets, if_exists: true, force: :cascade)
@sayan3296
sayan3296 / leapp_best_practices_satellite_capsule.txt
Last active May 26, 2023 10:27
This contains the best practices for a leapp activity to be performed on a Satellite or Capsule 6.11 server
** LEAPP Best Practices from RHEL Point of view: https://access.redhat.com/articles/7012979
A) Ensure /var/lib/pgsql/data is empty
B) The postgresql data
Satellite\Capsule 6.11 on RHEL 7 -> postgres data resides on /var/opt/rh/rh-postgresql12/
Satellite\Capsule 6.11 on RHEL 8 -> postgres data resides on /var/lib/pgsql
@sayan3296
sayan3296 / product_certs_capsule_611_el7.txt
Created May 26, 2023 10:11
The file contains all required product certs for the Capsule 6.11 running on RHEL 7
# ls -ld /etc/pki/product /etc/pki/product-default/
drwxr-xr-x. 2 root root 51 Jun 3 11:02 /etc/pki/product
drwxr-xr-x. 2 root root 21 Feb 15 2022 /etc/pki/product-default/
# for i in `ls /etc/pki/product/* /etc/pki/product-default/*`; do ls -l $i; done
-rw-r--r--. 1 root root 2183 May 24 19:31 /etc/pki/product/269.pem
-rw-r--r--. 1 root root 2139 May 24 19:31 /etc/pki/product/408.pem
-rw-r--r--. 1 root root 2171 Jun 3 11:02 /etc/pki/product/479.pem
-rw-r--r--. 1 root root 2171 Oct 7 2021 /etc/pki/product-default/479.pem
@sayan3296
sayan3296 / product_certs_satellite_611_el7.txt
Created May 26, 2023 10:11
The file contains all required product certs for the Satellite 6.11 running on RHEL 7
# ls -ld /etc/pki/product /etc/pki/product-default/
drwxr-xr-x. 2 root root 51 Aug 4 02:41 /etc/pki/product
drwxr-xr-x. 2 root root 20 Jul 26 06:20 /etc/pki/product-default/
# for i in `ls /etc/pki/product/* /etc/pki/product-default/*`; do ls -l $i; done
-rw-r--r--. 1 root root 2183 Aug 4 02:41 /etc/pki/product/201.pem
-rw-r--r--. 1 root root 2151 Aug 4 02:41 /etc/pki/product/250.pem
-rw-r--r--. 1 root root 2139 Aug 4 02:41 /etc/pki/product/408.pem
-rw-r--r--. 1 root root 2159 Dec 2 2020 /etc/pki/product-default/69.pem
@sayan3296
sayan3296 / .tmux.conf
Created May 7, 2023 16:03
Basic tmux config
# Set the prefix to Ctrl+a
set -g prefix C-a
# Remove the old prefix
unbind C-b
# Send Ctrl+a to applications by pressing it twice
bind C-a send-prefix
# use mouse and enable scrolling
@sayan3296
sayan3296 / check_all_blobs.sh
Created April 21, 2023 16:32
Fix corrupted blobs and manifests in Pulp2 ( satellite and capsule both )
#!/bin/bash
mongo pulp_database --eval "db.units_docker_blob.find({},{"_id":0, "_storage_path":1}).toArray()" | grep _storage_path|cut -d '"' -f 4 > all_blob_lists_on_db.txt
for blobs in $(cat all_blob_lists_on_db.txt);
do
STATUS=$(sha256sum $blobs 2>&1 || echo "missing file $blobs")
CHECKSUM_DB=$(echo $blobs|cut -d ':' -f 2)
echo "Processing list : $blobs."
if [[ $STATUS == *"missing file"* ]]
@sayan3296
sayan3296 / pulp3_mimic_connection.sh
Created April 21, 2023 16:28
Mimic connection to pulp remote in pulp3 based on pulp_id of repos from core_remote
#!/bin/bash
remote_id=$1
if [ ! -z $remote_id ]
then
psql_core_remote() {
# the trailing sed: we need to replace null value output \N by empty string
su - postgres -c "psql pulpcore -c \"COPY (SELECT $1 FROM core_remote WHERE pulp_id = '${remote_id}') TO STDOUT;\"" | sed 's!^\\N$!!1'
}
@sayan3296
sayan3296 / repo_rpms_to_artifacts.sh
Last active March 6, 2023 15:09
Get RPM name for a repo along with arifact name on filesystem
#!/bin/bash
NAME="$1"
if [ -z "$NAME" ]
then
echo 'Please pass a valid repository name with quotes. Refer the "hammer repository list" output for the names'.
exit 0;
fi
echo "COPY(select main.id,root.name,main.relative_path from katello_root_repositories root left JOIN katello_repositories main on main.root_id=root.id where main.library_instance_id is null and root.name = '$NAME') TO STDOUT WITH CSV;" | su - postgres -c "psql foreman" > /tmp/library_repos.txt