Skip to content

Instantly share code, notes, and snippets.

View treyd's full-sized avatar

Trey Duskin treyd

  • NVIDIA
  • Atlanta, GA
View GitHub Profile
@treyd
treyd / swift_api.sh
Last active July 16, 2020 15:23 — forked from simontraill/swift_api.sh
swift api checks in check_mk format
#!/usr/bin/env bash
# Openstack Swift Basic API tests for check_mk
# straill (SwiftStack) 2017/10/16
#
# Setup:
# - Ensure you have a swift account created - see SWIFT_USER below.
# - Then set the config varibles below for your endpoints and password.
# - Runs basic functional test set using some (ugly) cURL commands; returns status in check_mk format
# - Failures will cause us to immediately bail and return bad status
@treyd
treyd / vagrant.py
Last active May 15, 2018 13:25 — forked from lorin/vagrant.py
Vagrant dynamic inventory script for Ansible
#!/usr/bin/env python
# Adapted from Mark Mandel's implementation
# https://github.com/ansible/ansible/blob/devel/plugins/inventory/vagrant.py
import argparse
import json
import paramiko
import subprocess
import sys
@treyd
treyd / gist:e4841e13851f81f76eb683a4d097a85e
Last active March 9, 2022 19:24
ansible ad-hoc commands to add ansible user
#ensure your hosts file is defined but your ansible-configuration does NOT set up an ansible_user (this is what you're creating)
# Ubuntu (14.04) Trusty
ansible -i hosts -b -K -k -u <username_with_sudo> -m user -a "name=ansible groups=sudo append=yes" hostname
ansible -i hosts -b -K -k -u <username_with_sudo> -m authorized_key -a "user=ansible key='<public_key_as_string>' manage_dir=yes" hostname
ansible -i hosts -b -K -k -u <username_with_sudo> -m lineinfile -a "dest=/etc/sudoers state=present regexp='^%sudo' line='%sudo ALL=(ALL) NOPASSWD: ALL' validate='visudo -cf %s'" hostname
# CentOS/RHEL 7
ansible -i hosts -b -K -k -u <username_with_sudo> -m user -a "name=ansible groups=wheel append=yes" hostname
ansible -i hosts -b -K -k -u <username_with_sudo> -m authorized_key -a "user=ansible key='<public_key_as_string>' manage_dir=yes" hostname
@treyd
treyd / statemodels.py
Created November 11, 2017 18:18
Example of using django-fsm and transitions on a django model
import logging
from django_fsm import FSMField, transition
from django.db import models
logger = logging.getLogger(__name__)
class MyStatefulModel(models.Model):
class STATE:
@treyd
treyd / yum-gather-deps.sh
Last active October 5, 2017 12:56
How to gather dependency rpms for a package or other rpm
#ensure the yum cache is clear first
yum install yum-plugin-downloadonly
yum install --downloadonly <your-package-or-your-rpm>
find /var/cache/yum -iname '*.rpm'
@treyd
treyd / ssh-colorize
Last active March 31, 2017 23:27
set the background color of iTerm based on ssh-host
#!/bin/bash
#
# (1) copy to: ~/bin/ssh-colorize
# (2) set: alias ssh=~/bin/ssh-colorize
# (3) do: chmod +x ~/bin/ssh-colorize
#
# Forkd from https://gist.github.com/thomd/956095
set_term_bgcolor(){
local R=$1