Skip to content

Instantly share code, notes, and snippets.

@JamesOBenson
JamesOBenson / create_ec2_ami_image_for_openstack.sh
Last active May 12, 2023 18:08
Automated way to convert the latest Amazon Linux 2 image to an OpenStack compatible image
#!/bin/bash
# This idea was from Ales Nosek at https://alesnosek.com/blog/2018/04/21/booting-amazon-linux-2-on-openstack/
# This is an automated way to download Amazon's Linux 2 image and import it into openstack.
local_file=$(find . -name "*openrc.sh" -type f -print -quit)
# If not found, search in /etc/kolla/
if [ -z "$local_file" ]; then
kolla_file=$(find /etc/kolla/ -name "*openrc.sh" -type f -print -quit)
fi
@JamesOBenson
JamesOBenson / cephbackup
Created August 25, 2020 19:48
Backup files directly from ceph_mon docker container, download to docker container, then locally, and lastly copy offsite for backup.
sshlogin="username@xx.xx.xx.xx"
cephdir=vms
array=()
while IFS='' read -r line; do array+=("$line"); done < <(docker exec ceph_mon rbd ls -p "$cephdir")
for ID in "${array[@]}"; do
echo "Do you want to skip this file: $ID"
options=("yes" "no")
select skipbackup in "${options[@]}"
do
{
"44454c4c-3000-1036-8056-b9c04f4e5131": {
"buckets-mdapi": {
"2": {
"16d34111-14a4-4cb5-b2e9-35b25e576aae": 1
}
},
"nameservice": {
"b2c34e19-b352-4dcd-ba16-a31a6d6e0e22": 1
},
CN headnode 44454c4c-3500-1048-804d-b2c04f424d31 192.168.2.5
SERVICE SH ZONENAME
buckets-api 1 70302e9b-7af0-4a67-b02b-fb11cd4714e8
loadbalancer 1 61e5f2bf-d598-4324-9c75-dcb26953ff94
moray 1 55617a89-75d6-494d-884e-465781785a8c
webapi 1 c4be6c5e-7546-46e3-a957-2df0b739c562
CN R2-610-17 44454c4c-3900-1054-8054-b5c04f4e5131 192.168.2.89
SERVICE SH ZONENAME
authcache 1 edfb241c-dfba-4549-8cf4-b9512d1eba69
buckets-postgres 2 f2365b5c-3919-47c8-9436-d45deb2214c4
# cat /var/log/manta-init.log
{"name":"manta-init","hostname":"b84470b6-13f8-447f-be15-7b524211ce56","pid":178453,"level":30,"msg":"UFDS: connected","time":"2020-04-20T17:59:04.623Z","v":0}
{"name":"manta-init","hostname":"b84470b6-13f8-447f-be15-7b524211ce56","pid":178453,"component":"ufds","clazz":"Client","ldap_id":"1__ldaps://ufds.ics.ics.utsa.edu","level":20,"msg":"connected after 1 attempt(s)","time":"2020-04-20T17:59:04.624Z","v":0}
{"name":"manta-init","hostname":"b84470b6-13f8-447f-be15-7b524211ce56","pid":178453,"level":30,"msg":"SAPI in full mode","time":"2020-04-20T17:59:04.648Z","v":0}
{"name":"manta-init","hostname":"b84470b6-13f8-447f-be15-7b524211ce56","pid":178453,"level":30,"msg":"getting or creating user poseidon","time":"2020-04-20T17:59:04.649Z","v":0}
{"name":"manta-init","hostname":"b84470b6-13f8-447f-be15-7b524211ce56","pid":178453,"level":30,"msg":"creating poseidon","time":"2020-04-20T17:59:04.672Z","v":0}
{"name":"manta-init","hostname":"b84470b6-13f8-447f-be15-7b524211ce56","pid":1
@JamesOBenson
JamesOBenson / clean-up-boot-partition-ubuntu.md
Last active April 8, 2021 16:32 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

TL;DR:

dpkg --list linux-{headers,image,modules,tools}-\* | awk '{ if ($1=="ii") print $2}' | grep -v -e "$(uname -r | cut -d"-" -f1,2)" | xargs sudo dpkg --remove  # use dpkg to remove all but the currently running kernel version
sudo apt-get install -f  # It's common for apt to be in a broken state after running out of space on /boot
sudo apt-get autoremove  # It's really common for apt to be broken on a package that should have been removed
sudo apt-get install -y linux-generic linux-headers-generic linux-image-generic linux-tools-generic  # just in case latest kernel was mysteriously removed (e.g. when you are not running the latest kernel)
sudo update-grub  # just in case it was not done automatically by dpkg
@JamesOBenson
JamesOBenson / RUN.sh
Last active July 3, 2019 18:45
Download all VM disk images and run in VirtualBox VM.
#!/bin/shell
# This will download all files in your ceph cluster under the 'vms' pool,
# Convert them from raw to qcow2, Create a virtualbox and mount that
# disk to the new VM for local access.
array=()
while IFS='' read -r line; do array+=("$line"); done < <(rbd ls -p vms | grep disk)
[defaults]
#callback_whitelist = timer, profile_tasks
fact_caching = jsonfile
fact_caching_connection = /tmp/.ansible_fact_cache
forks = 25 # Default: 5
host_key_checking = False # Default: True
internal_poll_interval = 0.01 # Must be greater than ansible 2.1, Default: 0.001 Greater is faster.
pipelining = True # Default: False
poll_interval = 5 # Default: 15
#transport = paramiko # May require some config changes
#!/bin/sh
SIZES="1 10 20 50"
MBGB="MB" # Options are: GB OR MB
SAMPLE_SIZE=5 # Number of time to run.
USER="admin"
PASSWORD="admin-password"
ENDPOINT="namenode2-1.utsaics.edu"
# Please also note that the port changed from 50070 to 9870 in Hadoop 3.0.
echo "Which version of Hadoop are you using?"
#!/bin/bash
MYDNS="8.8.8.8"
DATE=$(date '+%Y-%m-%d')
UBUNTU1_URL="http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img"
UBUNTU2_URL="http://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img"
CIRROS_URL="http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img"
CENTOS_URL="http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2c"
VOLUME_SIZE=10
NEW_VOLUME_SIZE=15
VOLUME_NAME=$(cat /proc/sys/kernel/random/uuid)