Skip to content

Instantly share code, notes, and snippets.

View ioggstream's full-sized avatar

Roberto Polli ioggstream

View GitHub Profile
@ioggstream
ioggstream / heat-ternary-yaql.yaml
Created May 18, 2017 17:11
Ternary operator with heat and yaql
heat_template_version: newton
parameters:
one:
type: string
default: one
two:
type: string
default: two
@ioggstream
ioggstream / example.com.ovpn
Created May 26, 2017 10:35
An openvpn example file.
#
# Sample vpn file for example.com.
# get tls-remote from the configuration source
#
client
dev tun
proto tcp
remote vpn.example.com 443
ca myca.pem
@ioggstream
ioggstream / flush_keystone_token.py
Created June 6, 2017 18:51
Flush expired keystone token in 30 minutes chunks.
#!/usr/bin/env python
"""Print a set of mysql query to flush expired tokens.
Splits the deletion in 30 minutes chunks to reduce lock duration on MariaDB.
BEWARE: relies on the machine current timestamp to pick the right value for current_date.
"""
from datetime import datetime
from datetime import timedelta
from subprocess import check_output
@ioggstream
ioggstream / stack-download.py
Last active June 12, 2017 13:03
Dump a stack with all its files in a local directory
#!/usr/bin/env python
"""
Download a stack and recreate the generating source
into a given folder.
"""
from subprocess import Popen, PIPE
from shlex import split
@ioggstream
ioggstream / gather_heat_files.rb
Last active September 18, 2017 14:21
Stub for gathering heat files
require 'yaml'
require 'open-uri'
def traverse(obj, parent, &blk)
case obj
when Hash
# Forget keys because I don't know what to do with them
obj.each {|k,v| traverse(v, k, &blk) }
when Array
@ioggstream
ioggstream / case_01891685.yaml
Created July 19, 2017 21:41
A simple template to reproduce a cloudforms bug.
heat_template_version: newton
resources:
a_file:
type: OS::Heat::SoftwareConfig
properties:
group: script
config: {get_file: "https://google.com/robots.txt"}
@ioggstream
ioggstream / ocp_backup.yml
Last active July 26, 2017 11:28
Backup openshift 3.4
- hosts: masters
vars:
etcd_data: /var/lib/etcd
etcd_bak: /var/lib/etcd.{{ansible_date_time.epoch}}
tasks:
- name: Check etcd process
shell: |
pgrep -fa etcd
- name: Check etcd health
@ioggstream
ioggstream / etcd-restore.sh
Created July 25, 2017 23:25
Initialize an etcd node from a backup and restarts
[rpolli@rpolli tmp]$ cat reinit-etcd.sh
alias ecc='etcdctl --cert-file=/etc/etcd/peer.crt --key-file=/etc/etcd/peer.key --ca-file=/etc/etcd/ca.crt -C "https://192.168.0.16:2380,https://192.168.0.18:2380,https://192.168.0.17:2380" '
echo "restore backup"
rm /var/lib/etcd/member/ -fr
tar xf /tmp/etcd-backup.tar.bz --strip-components=3 -C /var/lib/etcd
chcon -R --reference /var/lib/etcd_ori_1501018211 /var/lib/etcd
chown -R etcd:etcd /var/lib/etcd
echo "force restart etcd"
@ioggstream
ioggstream / stack_trace.sh
Created August 2, 2017 16:20
Check stack status
stack_trace(){
openstack stack resource list -n10 \
-c resource_name \
-c resource_status \
-c stack_name \
-c updated_time ${1:-$STACK_NAME} | egrep 'PROG|FAIL'
}
@ioggstream
ioggstream / hot_yaql_regexp_split.yaml
Last active September 8, 2017 07:27
YAQL examples in heat templates
heat_template_version: newton
parameters:
items:
type: comma_delimited_list
default:
- antani-12
- antani-12-openshift-xas31fsad
- antani-12-openshift-xas31fsad-foobar