Skip to content

Instantly share code, notes, and snippets.

View 0xSheepdog's full-sized avatar
💭
fixing your broken shit

Jeff Pettorino 0xSheepdog

💭
fixing your broken shit
  • guardians of the galaxy
  • Mountain Standard Tribe
View GitHub Profile
@0xSheepdog
0xSheepdog / virt-customize-example.sh
Last active January 14, 2024 03:20
howto customize libvirt guest disk image before deployment
# This script provides examples for using the 'virt-customize' command to modify
# a libvirt guest disk image. It demonstrates a few common items as well as
# runs a shell script with more in-depth commands that will be run on the
# appliance and saved to the disk image. See my 'customize-guest.sh' gist for
# an example of the type of script you may use.
# gist.github.com/0xSheepdog/07284a9b1a1a3e2d30cc63a40a89cb77
$ virt-customize \
-a rocky-9.0-x86_64.qcow2 \
--root-password password:S3CRETPA$SW0RD \
@0xSheepdog
0xSheepdog / customize-guest.sh
Last active November 25, 2023 20:56
this shell script is intended for use with the `virt-customize` command via the `--run` parameter. it sets certain configurations on a libvirt guest disk image
# add myuser and grant sudo privileges
useradd -m myuser
echo password | passwd myuser --stdin
echo "myuser ALL=(ALL) ALL" | tee -a /etc/sudoers.d/00-myuser
# enable serial console
systemctl enable --now serial-getty@ttyS0.service
#
@0xSheepdog
0xSheepdog / enable-serial-console.sh
Created November 16, 2023 18:51
Enable a serial port console on Enterprise Linux 8+
sudo systemctl enable --now serial-getty@ttyS0.service
@0xSheepdog
0xSheepdog / linked-clone.sh
Created February 25, 2021 05:10 — forked from aojea/linked-clone.sh
Script to create a linked clone with libvirt
#!/bin/bash
set -xe
# This script takes as a parameter the name of the VM
# and creates a linked clone
# Ref: https://unix.stackexchange.com/a/33584
# The scripts assumes that it runs from the same folder
# where the vm image is located and it coincides with the
# image name
@0xSheepdog
0xSheepdog / ansible.cfg
Last active January 20, 2021 00:15
A simple, quick ansible.cfg example file. AND a not quite so simple YAML formatted inventory/hosts file. Examples for multiple group membership, host and group variables ... please review the official doco.
[defaults]
inventory = ./inventory.yml
vault_password_file = .vaultpass
retry_files_enabled = false
roles_path = ./roles
gathering = smart
callback_whitelist = timer, profile_tasks
[privilege_escalation]
become = true
@0xSheepdog
0xSheepdog / howto_virt-install_KVM-guest
Last active November 6, 2022 23:26
howto create a new KVM guest at the CLI with virt-install
source: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/sect-guest_virtual_machine_installation_overview-creating_guests_with_virt_install
The following example installs a virtual machine from an ISO image:
# virt-install \
--name guest1-rhel7 \
--memory 2048 \
--vcpus 2 \
--disk size=8 \
--network default \
--cdrom /path/to/rhel7.iso \
@0xSheepdog
0xSheepdog / howto-access-qcow2-image
Last active October 26, 2023 17:09
How to change root passwd/gain access to an official .qcow2 image from Red Hat et al.
source info: https://access.redhat.com/solutions/641193#comment-1104651
virt-customize -a rhel-guest-image-7.2-20160302.0.x86_64.qcow2 --root-password password:PASSW0RD --uninstall cloud-init
virt-sparsify --tmp=. --compress drive.qcow2 new-drive.qcow2
@0xSheepdog
0xSheepdog / powerline_setup.sh
Created May 24, 2019 19:54 — forked from cheuerde/powerline_setup.sh
Powerline on Debian and Centos for BASH, VIM and TMUX
# Claas Heuer, November 2015
#
# Setup Powerline on Debian and Centos for BASH, VIM and TMUX
# source: https://fedoramagazine.org/add-power-terminal-powerline/
# install on debian
sudo apt-get install python-pip
sudo apt-get install powerline
@0xSheepdog
0xSheepdog / cidr-cheat-sheet
Created January 17, 2019 22:24
CIDR SUBNET MASK CHEATSHEET & ICMP TYPE CODES
CIDR SUBNET MASK CHEATSHEET & ICMP TYPE CODES
https://oav.net/mirrors/cidr.html
_____________________________________________________________________________
Netmask Netmask (binary) CIDR Notes
_____________________________________________________________________________
255.255.255.255 11111111.11111111.11111111.11111111 /32 Host (single addr)
255.255.255.254 11111111.11111111.11111111.11111110 /31 Unuseable
255.255.255.252 11111111.11111111.11111111.11111100 /30 2 useable
255.255.255.248 11111111.11111111.11111111.11111000 /29 6 useable