Skip to content

Instantly share code, notes, and snippets.

@abelboldu
abelboldu / digitalocean.py
Created April 26, 2018 12:24
Digital Ocean inventory
#!/usr/bin/env python2
'''
DigitalOcean external inventory script
======================================
Generates Ansible inventory of DigitalOcean Droplets.
In addition to the --list and --host options used by Ansible, there are options
for generating JSON of other DigitalOcean data. This is useful when creating
@abelboldu
abelboldu / ost_smoketest.sh
Last active July 16, 2018 23:36
Openstack quick smoke test
#!/bin/bash
echo "Installing dependencies..."
APT=`command -v apt-get` || true
YUM=`command -v yum` || true
if [[ "$APT" != "" ]]; then
apt-get update > /dev/null; sudo apt-get install -qqy sshpass > /dev/null
elif [[ "$YUM" != "" ]]; then
yum -y install sshpass >> /dev/null
else
echo "Distro unsupported."
@abelboldu
abelboldu / bsd lessons
Last active December 19, 2015 13:41
Dragonfly BSD, things learned
* pkg is the package manager
* build Dports tree:
# cd /usr
# make dports-create-shallow
*
Follow https://www.dragonflybsd.org/docs/how_to_get_to_the_desktop/
to install mate
@abelboldu
abelboldu / jenkins-scripts
Created July 17, 2015 08:06
Jenkins scripts n tricks
// CLEAN JOB BUILDS //
// change this variable to match the name of the job whose builds you want to delete
def jobName = "Your Job Name"
def job = Jenkins.instance.getItem(jobName)
job.getBuilds().each { it.delete() }
// uncomment these lines to reset the build number to 1:
//job.nextBuildNumber = 1
//job.save()
@abelboldu
abelboldu / ost_oneliners
Last active August 29, 2015 14:22
OpenStack OneLiners
# Clean all unassociated FIPs
nova floating-ip-list | grep "| -" | awk '{ print $2}' | xargs -L1 nova floating-ip-delete
@abelboldu
abelboldu / delete_vm_from_db.sh
Last active August 29, 2015 14:19
Delete instance in nova
# The usage quotas for the tenant are updated after deleting or creating a new instance
read -s -p "MySQL Password: " pw
vm_uuid=$1
mysql -D nova -p$pw -e "update instances set deleted='1', vm_state='deleted',deleted_at='now()' where uuid='$vm_uuid' limit 1;"
sleep 1
mysql -D nova -p$pw -e "delete from instance_faults where instance_faults.instance_uuid = '$vm_uuid';"
mysql -D nova -p$pw -e "delete from instance_id_mappings where instance_id_mappings.uuid = '$vm_uuid';"
mysql -D nova -p$pw -e "delete from instance_info_caches where instance_info_caches.instance_uuid = '$vm_uuid';"
mysql -D nova -p$pw -e "delete from instance_system_metadata where instance_system_metadata.instance_uuid = '$vm_uuid';"
mysql -D nova -p$pw -e "delete from security_group_instance_association where security_group_instance_association.instance_uuid = '$vm_uuid';"
@abelboldu
abelboldu / leopold_kb.sh
Created February 24, 2015 09:15
Leopold FC660C custom layout
setxkbmap -layout us -variant altgr-intl -option -option lv3:ralt_switch
xmodmap -e "keycode 47 = semicolon colon semicolon colon dead_grave dead_grave"
@abelboldu
abelboldu / rhelance
Last active August 29, 2015 14:06
Must add for basic RHEL/CentOS6 machines
#!/bin/bash
# run as root
yum install -y vim git tcpdump yum-utils wget w3m strace lsof curl sudo screen
yum localinstall -y http://ftp.cica.es/epel/6/i386/epel-release-6-8.noarch.rpm
yum install -y bash-completion htop ccze mtr nmap tmux
@abelboldu
abelboldu / commands_pit
Last active November 22, 2016 22:54
Useful/fun/weird commands
#Find a (wired) Raspberry Pi on the network
nmap -sn 192.168.1.0/24 > /dev/null; cat /proc/net/arp | grep b8:27 | awk '{print $1}'
# Symmetric encrypt with Blowfish
openssl enc -bf-cbc -salt -in myfile.txt -out myfile.enc
# Symmetric decrypt with Blowfish
openssl enc -d -bf-cbc -in myfile.enc -out myfile.txt
# Almost invisible shell
ssh -o UserKnownHostsFile=/dev/null -T user@host /bin/bash -i
@abelboldu
abelboldu / g_in_the_shell
Created March 27, 2013 13:16
Useful cummands puked here
# Monitoring processes I/O
dstat -s --top-io --top-bio
iotop