Skip to content

Instantly share code, notes, and snippets.

View jordiclariana's full-sized avatar

Jordi Clariana jordiclariana

View GitHub Profile
@jordiclariana
jordiclariana / consul-template-trace.log
Created May 30, 2019 08:27
consul-template -> vault unix socket TRACE
2019/05/30 08:26:27.999779 [INFO] consul-template v0.20.0 (b709612c)
2019/05/30 08:26:27.999893 [INFO] (runner) creating new runner (dry: false, once: false)
2019/05/30 08:26:28.000243 [DEBUG] (runner) final config: {"Consul":{"Address":"","Auth":{"Enabled":false,"Username":"","Password":""},"Retry":{"Attempts":12,"Backoff":250000000,"MaxBackoff":60000000000,"Enabled":true},"SSL":{"CaCert":"","CaPath":"","Cert":"","Enabled":false,"Key":"","ServerName":"","Verify":true},"Token":"","Transport":{"DialKeepAlive":30000000000,"DialTimeout":30000000000,"DisableKeepAlives":false,"IdleConnTimeout":90000000000,"MaxIdleConns":100,"MaxIdleConnsPerHost":2,"TLSHandshakeTimeout":10000000000}},"Dedup":{"Enabled":false,"MaxStale":2000000000,"Prefix":"consul-template/dedup/","TTL":15000000000},"Exec":{"Command":"","Enabled":false,"Env":{"Blacklist":[],"Custom":[],"Pristine":false,"Whitelist":[]},"KillSignal":2,"KillTimeout":30000000000,"ReloadSignal":null,"Splay":0,"Timeout":0},"KillSignal":2,"LogLevel":"trace","MaxStale":2000
@jordiclariana
jordiclariana / rekey_vaulted_vars.py
Created February 22, 2019 15:16
Rekey Vaulted YAML values
#!/usr/bin/env python2
from ansible.parsing import vault
from ansible.constants import DEFAULT_VAULT_ID_MATCH
import re
import os
import click
@click.command()
@jordiclariana
jordiclariana / migrate-redis.py
Created January 26, 2019 09:54 — forked from thomasst/migrate-redis.py
Migrate Redis data on Amazon ElastiCache
"""
Copies all keys from the source Redis host to the destination Redis host.
Useful to migrate Redis instances where commands like SLAVEOF and MIGRATE are
restricted (e.g. on Amazon ElastiCache).
The script scans through the keyspace of the given database number and uses
a pipeline of DUMP and RESTORE commands to migrate the keys.
Requires Redis 2.8.0 or higher.
@jordiclariana
jordiclariana / k8s_secret2yaml.py
Created October 30, 2018 08:36
Gets a secrets file from K8s (JSON format) and outputs it in yaml (without the base64 encoding).
#!/usr/bin/env python2
from ruamel.yaml import YAML
import json
import sys
import base64
with open(sys.argv[1], 'r') as srcfile:
myjson = json.loads(srcfile.read())
@jordiclariana
jordiclariana / route53_dump.sh
Created September 18, 2018 13:01
Dump all route53 zones and records
#!/bin/bash
aws route53 list-hosted-zones | jq -r '.HostedZones[] | (.Name + " " + .Id)' | while read -r domain zoneid; do
echo -e "\n======================\n## $domain - $zoneid\n"
aws route53 list-resource-record-sets --hosted-zone-id "$zoneid" | \
jq -r '.ResourceRecordSets[] | [.Name, .Type, (.ResourceRecords[]? | .Value), .AliasTarget.DNSName?] | @tsv'
done
@jordiclariana
jordiclariana / FullVault2PerVarVault.py
Created August 2, 2018 12:44
Turn full ansible-vault encrypted yaml to a regular yaml with per variable encrypted
#!/usr/bin/python2.7
from ansible.parsing import vault
from ansible.errors import AnsibleError
from ansible.constants import DEFAULT_VAULT_ID_MATCH
import ruamel.yaml as yaml
import re
import sys
import os
@jordiclariana
jordiclariana / tfgrep.sh
Last active August 7, 2018 12:07
Grep terraform files and print full resources
#!/bin/bash
if [ $# -eq 0 ]; then
echo "No arguments. Use: $(basename "$0") <regex> [<files|dirs]"
exit 1
fi
REGEX="${1/\\/\\\\}"
shift
@jordiclariana
jordiclariana / remove_jenkins_locks.groovy
Created June 14, 2018 07:54
Delete old locks from Jenkins
def res = GlobalConfiguration.all().get(org.jenkins.plugins.lockableresources.LockableResourcesManager.class).resources
res.retainAll {it -> it.locked}
This file has been truncated, but you can view the full file.
2018/06/06 15:52:08 [INFO] Terraform version: 0.11.7 41e50bd32a8825a84535e353c3674af8ce799161
2018/06/06 15:52:08 [INFO] Go runtime version: go1.10.1
2018/06/06 15:52:08 [INFO] CLI args: []string{"/home/jordi/.tfenv/versions/0.11.7/terraform", "plan"}
2018/06/06 15:52:08 [DEBUG] Attempting to open CLI config file: /home/jordi/.terraformrc
2018/06/06 15:52:08 Loading CLI configuration from /home/jordi/.terraformrc
2018/06/06 15:52:08 [INFO] CLI command args: []string{"plan"}
2018/06/06 15:52:08 [TRACE] module source: "./test_module"
2018/06/06 15:52:08 [TRACE] module source: "./test_module"
2018/06/06 15:52:08 [TRACE] module source: "./test_module"
2018/06/06 15:52:08 [INFO] command: empty terraform config, returning nil
This file has been truncated, but you can view the full file.
2018/06/06 15:52:08 [INFO] Terraform version: 0.11.7 41e50bd32a8825a84535e353c3674af8ce799161
2018/06/06 15:52:08 [INFO] Go runtime version: go1.10.1
2018/06/06 15:52:08 [INFO] CLI args: []string{"/home/jordi/.tfenv/versions/0.11.7/terraform", "plan"}
2018/06/06 15:52:08 [DEBUG] Attempting to open CLI config file: /home/jordi/.terraformrc
2018/06/06 15:52:08 Loading CLI configuration from /home/jordi/.terraformrc
2018/06/06 15:52:08 [INFO] CLI command args: []string{"plan"}
2018/06/06 15:52:08 [TRACE] module source: "./test_module"
2018/06/06 15:52:08 [TRACE] module source: "./test_module"
2018/06/06 15:52:08 [TRACE] module source: "./test_module"
2018/06/06 15:52:08 [INFO] command: empty terraform config, returning nil