Skip to content

Instantly share code, notes, and snippets.

View gonoph's full-sized avatar

Billy Holmes gonoph

View GitHub Profile
@gonoph
gonoph / test_aws.md
Last active January 16, 2025 16:32
AAP playbook to test AWS BYOS billing

Purpose

I use the following playbook in AAP to test my AWS instances to ensure they are using BYOS Linux vs the more expensive PAYG images.

Usage

You will need an inventory source, and playbook.

Create a template from the playbook, and run it. It will error if any instances are not BYOS.

@gonoph
gonoph / mkremediate.sh
Last active August 28, 2024 18:38
Script to - extract OpenScap reports from Satellite - generate an Ansible remediation playbook
#!/bin/sh
N=$(tput sgr0)
B=$(tput bold)
banner() {
_width=$(tput cols)
tput bold
python3 -c "print('#' * $_width)"
tput sgr0
@gonoph
gonoph / getldd.sh
Last active July 23, 2024 14:43
getldd - script to recursively extract all the shared libraries of an elf executable
#!/bin/sh
# usage: ./getldd mybinary
# will hard copy all the shared libs to
DEPS=/tmp/deps.txt
getldd() {
for i in $(ldd $1 | grep / | xargs echo) ; do
test -r "$i" && realpath "$i" && getldd $i
done
}
@gonoph
gonoph / satellite.yml
Created January 31, 2024 15:45
Satellite registration playbook example
---
# vim: ts=2 sw=2 ai expandtab
- name: Register to Satellite
hosts: "{{ workflow_hosts | default('all') }}"
connection: smart
gather_facts: true
become: true
vars_files:
- satellite_credentials.yml
@gonoph
gonoph / peek.bash
Last active November 8, 2023 16:48
Peek.bash - get a hex dump of the memory of a running process
#!/bin/bash
# vim: sw=4 ts=4 expandtab
# modifed from https://www.baeldung.com/linux/read-process-memory
err() { echo "$@" >&2 ; exit 1; }
test -z "$1" && err "Usage: $0 <pid>"
test -d "/proc/$1" || err "PID $1 does not exist"
while read -r mem_range perms JUNK ; do
if [[ "$perms" == "r"* ]]; then
@gonoph
gonoph / sshtmp.bash
Created October 9, 2023 14:01
sshtmp - quick function to ssh to a machine without remembering the hostkey
# put this in .bashrc
# - or -
# mkdir ~/.bashrc.d
# put it in ~/.bashrc.d/sshtmp.bash
sshtmp ()
{
echo "About to temporarily connect to host" > /dev/tty;
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "$@"
}
@gonoph
gonoph / get_ip_tests.bash
Last active April 16, 2024 15:42
Different script methods to obtain the primary interface ip address
###
### Use any of the following to programmatically obtain the primary interface ip address
###
# using ansible facts module
# requires: jq
ansible -msetup -i localhost, all -o | cut -d'>' -f 2- | jq .ansible_facts.ansible_default_ipv4.address | xargs echo
# ip command and bash
# requires: iproute
@gonoph
gonoph / aws-rhel-buildah.sh
Last active September 15, 2018 03:41
container image based on RHEL 7.5 for AWS RHUI Hosts
#!/bin/bash
# This will build a container image based on RHEL 7.5
# for use in AWS with RHUI
DEFAULT_FROM=rhel7/rhel:7.5
DEFAULT_TAG='devel/rhel:latest'
BZ='https://bugzilla.redhat.com/show_bug.cgi?id=1498628'
declare -r DEFAULT_FROM DEFAULT_TAG BZ
@gonoph
gonoph / satellite-randomize-playbook.yml
Created June 1, 2018 03:25
Randomize Satellite Username and Password
# vim: sw=2 ai expandtab
---
- name: Randomize Satellite Username and Password
hosts: satellites
gather_facts: false
connection: smart
become: false
force_handlers: True
@gonoph
gonoph / Password-Generator.md
Last active September 14, 2024 02:22
Password generator

Generates a selection of random passwords of the specified length

genpass ()
{
  local _size=$1          # size of the password - default(16)
  local _count=$2         # how many passwords to generate - default(fill your terminal screen)
  local _rc _rows _width _cols

  : ${_size:=16}