Skip to content

Instantly share code, notes, and snippets.

View muresan's full-sized avatar

Catalin Muresan muresan

  • Broadwing
  • Scotland
View GitHub Profile
@muresan
muresan / autosign-psk
Last active August 29, 2015 14:23
enable puppet to autosign clients based on a shared secret
#!/bin/bash
# puppet client part:
# create the file /etc/puppet/csr_attributes.yaml with the PSK in it:
##---
##extension_requests:
## pp_preshared_key: @the_psk@
# puppet master part:
## puppet config set --section master autosign /usr/local/bin/autosign-psk
@muresan
muresan / 10-mount
Last active May 23, 2024 06:56
Script to automatically mount NTFS filesystems for OpenWRT
#!/bin/bash
# filename: /etc/hotplug.d/block/10-mount
# automatically mount ntfs volumes into $BASEDIR with $LABEL or $UUID, depending on what's available.
# to be used with OpenWRT.
BASEDIR=/media
export PATH=/usr/bin:/usr/sbin:/bin:/sbin
@muresan
muresan / nginx_pull_cdn
Last active November 7, 2015 01:29
Pull CDN using NGINX. domain.tld.cdn.example.com/uri will be fetched from domain.tld/uri and stored in /cdn/domain.tld/uri
server {
listen 80;
server_name *.cdn.example.com;
set $origin_host 'nothing';
if ( $host ~* ([^.]+\.[^.]+)\.cdn\.example\.com$ ) {
set $origin_host $1;
}
@muresan
muresan / mysql_tuning_parameters
Created November 10, 2015 13:51
MySQL tunning from a persentation
All the changes that are fit to print. Droppin’ Mo’ Science 52 All Your IOPS Are Belong To Us: Ernie Souhrada, Database Engineer @ Pinterest - Percona Live MySQL Conference & Expo 2015 Full list of customizations / changes deployed:
-  Linux kernel 3.18.7
-  irqbalance 1.0.8
-  RPS enabled
-  Jemalloc instead of Glibc
-  Disk IO scheduler = noop
-  XFS + 64K RAID block size
-  Mount options: -  noatime,nobarrier,discard,inode64,logbsize=256k
-  my.cnf changes:
innodb_max_dirty_pages_pct = 75
@muresan
muresan / nginx_redirect_from_memcached
Created November 11, 2015 11:47
Redirect based on value of origin_host from memcache. Needs nginx-lua and nginx-memc modules.
server {
listen 80;
server_name example.com;
root /var/www/example.com;
set $origin_host 'origin.example.com';
access_log /var/log/nginx/example.com.access.log main;
@muresan
muresan / client.json
Last active August 25, 2016 07:19
consul for http service + check
{
"datacenter": "dc1",
"data_dir": "/var/lib/consul",
"bind_addr": "5.6.7.8",
"log_level": "INFO",
"node_name": "node2",
"server": false,
"bootstrap" : false,
"retry_join": [ "1.2.3.4" ],
"rejoin_after_leave": true,
@muresan
muresan / backup_webservice.json
Created November 26, 2015 17:57
Backup-like feature implemented using consul. cdnhealth.json and webservice.json is on all CDN members which are not backup and backup_webservice.json is on the backup(s)
{
"services": [
{ "id": "webservice-backup",
"name": "webservice",
"tags": ["backup"],
"port": 80,
"checks": [{
"name": "DNS check ",
"script": "/usr/lib64/nagios/plugins/negate -s /usr/lib64/nagios/plugins/check_dns -H cdnhealth.service.cdn.example.com.",
"interval": "5s",
@muresan
muresan / nginx microcache nginx.conf
Created February 19, 2016 15:43
nginx microcache
http {
fastcgi_cache_path /var/cache/nginx2 levels=1:2 keys_zone=microcache:5m max_size=1000m;
log_format cache '$remote_addr - $remote_user [$time_local] "$request" ' '$status $upstream_cache_status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
}
@muresan
muresan / Vagrantfile
Last active August 3, 2020 11:14
Vagrant virtualbox multiple disks
osd_data_size = 6
osd_journal_size = 6
osd_path = '/d02/vagrant/virtualbox-ceph-disks'
hosts = {
'mon-1' => {
'ip' => '10.253.60.151', 'cpus' => 1, 'memory' => 1024, 'autostart' => true,
'data_disk_size' => osd_data_size * 1024, 'journal_disk_size' => osd_journal_size * 1024 },
}
@muresan
muresan / fetch_cert_from_s3.py
Last active August 23, 2016 12:44
Fetch an object (my use case: pem file) from S3, using an assumed IAM role and copy it to stdout
import json
import os
import re
import sys
import urllib3
import boto3
CERT_BUCKET_IAM_ROLE = os.environ['CERT_BUCKET_IAM_ROLE']
CERT_BUCKET_NAME = os.environ['CERT_BUCKET_NAME']