Skip to content

Instantly share code, notes, and snippets.

@jaimegago
jaimegago / gist:3896119
Created October 15, 2012 22:38
one liner we use for release rpm tag
git log -1 --pretty=format:"%ad %h" --date=short|sed s/'[[:space:]]'/."$(git log --oneline|wc -l)"git/|sed s/-//g
YYYYMMDD.$NUMBER_OF_COMMITS.git$COMMIT_HASH_SHORT
example output: 20121015.722git48b7147
We use this to package our JAVA based snapshot as an extension of http://fedoraproject.org/wiki/Packaging:NamingGuidelines#Snapshot_packages .
Adding the number of commits before the "git" allows proper ordering of packages in yum database.
@jaimegago
jaimegago / mailman lists subscribers
Created November 29, 2012 23:01
A very basic 1 shot python script that uses mailman CLI to send the subscribers list of all mailing list
#!/usr/bin/python
#
#
# a simple script to use the mailman cli
# to send via email the list of members of each mailman list
#
#
import smtplib
import string
import commands
@jaimegago
jaimegago / shell_vim_prov
Last active January 4, 2016 22:55
A script I use for local provisioning of my bash profile in vagrant, does a bunch of stuff for the prompt and for vim
#!/bin/bash
function cinfo() {
COLOR='\033[01;33m' # bold yellow
RESET='\033[00;00m' # normal white
MESSAGE=${@:-"${RESET}Error: No message passed"}
echo -e "${COLOR}${MESSAGE}${RESET}"
}
##
cinfo "Local Provisioning detected"
#A couple of tools that are not on my base box
@jaimegago
jaimegago / gist:6926304
Last active December 25, 2015 05:39
A script that detects unmodified templates Ansible files and adds the ansible_managed commented out. Deals with XML files comment syntax by reading first line.
#!/usr/bin/python
#A script that detects unmodified templates Ansible files and adds the ansible_managed commented
# out. Deals with XML files comment syntax by reading first line.
import fileinput
import os
import re
#Defining different headers as commenting syntax is different for XML
@jaimegago
jaimegago / gist:11229750
Last active October 23, 2022 23:31
Grafana Dashboards Backups
#!/usr/bin/python -tt
#
import datetime
import json
import logging
import logging.handlers
import optparse
import os
import re
import shutil
@jaimegago
jaimegago / install_ansible_from_source_deb
Created June 17, 2014 19:14
Ansible install from source on a debian/ubuntu box
#!/bin/bash
# bootstrap-ansible.sh: download and build Ansible on Debian host
# https://github.com/ginas/ginas/
set -e
# Create temporary directory for build
build_dir=$(mktemp -d)
trap "rm -rf ${build_dir}" EXIT
@jaimegago
jaimegago / graphite_url_api_pngs
Created March 5, 2015 02:31
Python script to create and download PNG graphs via Graphite Render URL API
#!/usr/bin/python -tt
import requests
graphite_targets = [
'some.graphite.metric.target',
'another.graphite.metric.target
]
graphite = 'some_graphite_host'
@jaimegago
jaimegago / netscaler_nitro_config_stats
Last active June 21, 2023 18:36
Python script targeting Citrix Netscaler Nitro REST API to find which Netscaler config objects have stats associated with them
#!/usr/bin/python -tt
import requests
user = 'nsroot'
password = 'nsroot'
netscaler = 'my_netscaler_fqdn_or_ip'
url = 'http://%s/nitro/v1/config/' % netscaler
response = requests.get(url, auth=(user, password))
@jaimegago
jaimegago / ansible_download_apache_access_logs
Created June 16, 2015 06:11
An ansible playbook to dowwload all the apache access log files
---
- hosts: all
sudo: yes
tasks:
- name: "Get all the access log file paths"
shell: "ls /var/log/apache2/access.log*"
register: ls_output
- name: "Download all the apache logs"
fetch: src={{ item }} dest="logs"
@jaimegago
jaimegago / sensu-keepalive-delete
Created July 17, 2015 18:12
Sensu delete dead clients
#!/usr/bin/python -tt
import json
import optparse
import requests
import sys
def get_dead_sensu_clients(sensu_server, sensu_port):
get_dead_clients_url = 'http://%s:%s/events' % (sensu_server, sensu_port)