Skip to content

Instantly share code, notes, and snippets.

@jhoblitt
jhoblitt / gist:b1fdd396b3641088f31f1a421787b1ad
Created February 19, 2025 18:16
rke2 fix etcd member peer url
export CRI_CONFIG_FILE=/var/lib/rancher/rke2/agent/etc/crictl.yaml
...
[root@yagan03 rancher]# /var/lib/rancher/rke2/bin/crictl exec 49cb8ba0d8373 etcdctl --cert /var/lib/rancher/rke2/server/tls/etcd/server-client.crt --key /var/lib/rancher/rke2/server/tls/etcd/server-client.key --cacert /var/lib/rancher/rke2/server/tls/etcd/server-ca.crt member list
23fe8fb09d160c69, started, yagan01-60882631, https://139.229.180.1:2380, https://139.229.180.1:2379, false
56d45c007a1663e9, started, yagan04-8f0b5969, https://139.229.180.4:2380, https://139.229.180.4:2379, false
73498b2b56b52d54, started, yagan02-4a05f740, https://139.229.180.2:2380, https://139.229.180.2:2379, false
7c4b2fb7e89203b5, started, yagan03-01987620, https://139.229.180.80:2380, https://139.229.180.3:2379, false
c35e2bc4a7d42c48, started, yagan05-39f67a83, https://139.229.180.5:2380, https://139.229.180.5:2379, false
@jhoblitt
jhoblitt / gist:cb91d6388dd55f3e3207e9caacf8fa3b
Last active February 18, 2025 21:48
chatgpt o1 generated script to cleanup after ceph on drives which have already have the partition table removed by kickstart.
#!/usr/bin/env bash
# WARNING: This operation is destructive and will overwrite data on the device.
# Ensure you really want to overwrite these drives.
for dev in $(lsblk -dn -o NAME | grep '^nvme'); do
# Capture parted output (quiet mode) and return code
parted_output=$(parted -s "/dev/$dev" print 2>&1)
parted_status=$?
@jhoblitt
jhoblitt / set_pxe_boot.sh
Created February 18, 2025 18:02
chatgpt 4o generated script to set net boot. The prompt: `What a bash script to use efibootmgr to set the next boot and the boot order to the first boot option which contains the string UEFI PXE: IPv4 Intel(R) Ethernet Controller X550`
#!/bin/bash
# Find the boot entry number that matches the given string
BOOT_ENTRY=$(efibootmgr | grep "UEFI PXE: IPv4 Intel(R) Ethernet Controller X550" | head -n 1 | awk '{print $1}' | sed 's/Boot//;s/\*//')
# Check if a matching boot entry was found
if [[ -z "$BOOT_ENTRY" ]]; then
echo "No matching UEFI PXE boot entry found!"
exit 1
fi
pvs | grep ceph | awk '{print $1}' | xargs -L1 /sbin/sgdisk --zap-all
@jhoblitt
jhoblitt / nvme-smart-check.sh
Last active February 17, 2025 21:28
chatgpt 01 generated script to look for failed nvme devices. The prompt was: `Write a bash script which loops over all nvme devices installed in a system and runs the smart-log subcommand and reports any device which has a critical_warning other than 0.`
#!/usr/bin/env bash
#
# nvme-smart-check.sh
#
# This script lists all NVMe devices on the system, runs 'nvme smart-log'
# on each, and reports any device whose 'critical_warning' is non-zero.
#
# Exit on any error (optional; remove 'set -e' if you prefer to continue on errors)
set -e
@jhoblitt
jhoblitt / sync.txt
Created February 12, 2025 17:58
How to sync a git branch between github and gitlab.
~ $ cd tmp
~/tmp $ git clone [email protected]:lsst-it/puppet-tailscale.git
Cloning into 'puppet-tailscale'...
remote: Enumerating objects: 219, done.
remote: Counting objects: 100% (219/219), done.
remote: Compressing objects: 100% (106/106), done.
remote: Total 219 (delta 95), reused 206 (delta 84), pack-reused 0 (from 0)
Receiving objects: 100% (219/219), 51.18 KiB | 595.00 KiB/s, done.
Resolving deltas: 100% (95/95), done.
~/tmp $ cd puppet-tailscale/
@jhoblitt
jhoblitt / main.go
Created January 30, 2025 22:49
Demo of idempotent reconcilation multiple of rgw user keys
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/ceph/go-ceph/rgw/admin"
"github.com/pkg/errors"
@jhoblitt
jhoblitt / rancher-rke2.repo
Created June 21, 2024 17:00
/etc/yum.repos.d/rancher-rke2.repo as created by `curl -sfL https://get.rke2.io`
[rancher-rke2-common-stable]
name=Rancher RKE2 Common (stable)
baseurl=https://rpm.rancher.io/rke2/stable/common/centos/9/noarch
enabled=1
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://rpm.rancher.io/public.key
[rancher-rke2-1.28-stable]
name=Rancher RKE2 1.28 (stable)
baseurl=https://rpm.rancher.io/rke2/stable/1.28/centos/9/x86_64
@jhoblitt
jhoblitt / README
Created June 3, 2024 18:46
finding route53 records with names that match 'pdu' and formatting them into prometheus file sd json format.
aws route53 list-resource-record-sets --hosted-zone-id ZPIEHXTK3ZPMR | jq '.ResourceRecordSets' > ls.lsst.org.json
aws route53 list-resource-record-sets --hosted-zone-id Z2CCXZLXGUUYM5 | jq '.ResourceRecordSets' > cp.lsst.org.json
./r53_to_file_sd.rb ls.lsst.org.json cp.lsst.org.json > /home/jhoblitt/github/k8s-cookbook/fleet/lib/snmp-exporter-pre/files/sd/dev/snmp-raritan-pdu.json
@jhoblitt
jhoblitt / inv_to_file_sd.rb
Created May 9, 2024 21:47
Recursively extract the hostnames from an ansible inventory file and construct as prometheus sd file.
#!/bin/env ruby
require 'yaml'
require 'json'
inv = YAML.load_file('auto_inventory.yml')
def find_hosts(parent, h, output)
h.each {|k, v|
if v.is_a?(Hash)