Skip to content

Instantly share code, notes, and snippets.

@rohitkothari
rohitkothari / ParameterizeHashicorpNomadJob.md
Created July 15, 2017 16:02
How to parameterize a Hashicorp's Nomad Job for user-defined variables?

How to parameterize a Hashicorp's Nomad Job for user-defined variables?

Description

This sample Nomad job attempts to clone a github repository from a github account, and then perform ls command to verify if it downloaded.

However, the cool thing is, it uses parameterized construct to parameterize the repository name so I can re-use this nomad job to clone any repository at runtime.

Motivation for writing

@rohitkothari
rohitkothari / lookup_ec2.py
Created April 24, 2016 03:56
Ansible Lookup plugin (v1.x) to get list of AWS EC2 Instance IDs given the value of Name tag
# A Lookup plugin to lookup EC2 instance IDs with given Name tag
# The plugin accepts instance name, i.e. the value for Name tag
# and returns a list of Instance IDs with that Name tag
# USAGE:
# - debug: msg="{{ lookup('lookup_ec2', instance_name) }}"
# OR
# with_lookup_ec2: "{{ instance_name }}"
@rohitkothari
rohitkothari / BackupAWSRDS.java
Created April 2, 2015 07:03
Download a backup of MySQL schema and data from AWS RDS to local machine using mysqldump
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class BackupAWSRDS {
public static void main(String[] args) {
BackupAWSRDS bckupRds = new BackupAWSRDS();
// Make sure you replace the parameters in below String with actual RDS_IP_ADDRESS, RDS_USERNAME, RDS_PASSWORD, DB
String createBackupCommand = "/usr/local/mysql/bin/mysqldump -hRDS_IP_ADDRESS -uRDS_USERNAME -pRDS_PASSWORD --port=3306 --single-transaction --routines --triggers --databases DB -r /tmp/mysql-dump.sql";