Skip to content

Instantly share code, notes, and snippets.

View flrichar's full-sized avatar
Gitops Platform Curation

Fred Richards flrichar

Gitops Platform Curation
View GitHub Profile
@flrichar
flrichar / silly ipv4 parser
Created March 13, 2018 18:26
parse v4 ip with perl
#!/usr/bin/perl
## extracts all ips from log file
while (<>) {
chomp;
if (/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/) {
print "$&\n";
}
}
@flrichar
flrichar / aws-rtb-facts.yml
Last active June 13, 2018 15:43
VPC Route-Table Facts via Ansible
---
- hosts: localhost
name: show route-table facts via aws api
## proper creds belong in ~/.boto
tasks:
- name: all us-west-2 route-tables
ec2_vpc_route_table_facts:
region: us-west-2
profile: default
@flrichar
flrichar / temp-wg-interface.yml
Created January 27, 2020 12:11
conditional ansible tasks
- name: update facts with services; haproxy, docker, pdns, wireguard
setup: filter='ansible_wg*'
tags: ['services','wg']
- name: add 172.31.0.0/16 route
command: 'ip route add 172.31.0.0/16 via 172.28.254.105'
when: ansible_wg0.active == true
ignore_errors: yes
tags: ['routes','wg']
@flrichar
flrichar / dvolume.txt
Created February 20, 2020 14:42
dvolume, dir/ls command for docker volume dirs
dvolume() {
local volume volumes_to_list=${1:-$(docker volume ls --quiet)}
for volume in $volumes_to_list; do
sudo ls -lRa "$(docker volume inspect --format '{{ .Mountpoint }}' "$volume")"
echo
done
}
@flrichar
flrichar / pv-by-pod.txt
Last active January 4, 2023 09:28
filter pod using certain pv
kubectl get pods --all-namespaces -o=json | jq -c '.items[] | {name: .metadata.name, namespace: .metadata.namespace, claimName: .spec | select( has ("volumes") ).volumes[] | select( has ("persistentVolumeClaim") ).persistentVolumeClaim.claimName }'
### if needed, patch reclaim policy of pv for this pod ...
kubectl patch pv <the-pv-name> -p '{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}'
@flrichar
flrichar / rhel8-opt.txt
Last active July 22, 2021 18:33
rhel8 optional improvements
remove sub mgr repo
## subscription-manager repos --disable codeready-builder-for-rhel-8-x86_64-rpms
enabled elrepo for ml kernel updates
## yum --enablerepo=elrepo-kernel install kernel-ml
grubby disables selinux if needed // prob not as big a deal any longer
## grubby --update-kernel=ALL --args="selinux=0"
@flrichar
flrichar / linux-terraform-latest.yaml
Last active July 22, 2021 18:34
ansible terraform installer
---
## It's so nice when the kids get along
- hosts: localhost
become: yes
vars_files:
- vars/become.yaml
vars:
tfversion: 1.0.3 // look over there, elvis
@flrichar
flrichar / grubby-options.md
Last active November 15, 2023 21:12
Grubby options, for rhel or centos

Grubby Options

Use Grubby to add or remove kernel parameters, and select the default kernel to boot into. Note, this is for primarily OpenSUSE and RHEL-like distros, Alma, Rocky etc.

  • disable selinux: sudo grubby --update-kernel=ALL --args="selinux=0"
  • list all kernels: sudo grubby --info ALL
  • default kernel by name: sudo grubby --default-kernel, set default-kernel: sudo grubby --set-default-kernel="/boot/vmlinuz-xxxxxx"
  • default kernel by index: sudo grubby --default-index, set default-index: sudo grubby --set-default-index=2

CGroups Kernel Parameters

  • default cgroup version (legacy = v1, unified = v2) ... systemctl --version | awk '{print $NF}'
### lab has two node groups, leap152 & bionics
### fetch/install calicoctl of specific version on all nodes
---
- hosts: bionics,leap152
become: yes
vars_files:
- ~/YAML/vars/become.yaml
vars:
### grab nameTags privIP and IPv6 addrs
aws ec2 describe-instances --profile=mongooseZ13 --region=ca-central-1 --query 'Reservations[].Instances[].[Tags[?Key==`Name`] | [0].Value, InstanceId, PrivateIpAddress, NetworkInterfaces[].Ipv6Addresses]' --output=text
# note I dont care about EIPs ... left that as an excercise for the reader