Skip to content

Instantly share code, notes, and snippets.

@trondhindenes
trondhindenes / PowerShell Workflow paralell with throttle limit.ps1
Last active January 7, 2019 10:25
PowerShell Workflow paralell with throttle limit
workflow paralleltest
{
$a = 1..10
#Divide the 10 iterations into 3 (+1) blocks
foreach -parallel -throttlelimit (($a.count)/3) ($b in $a)
{
Write-Output $b
}
@trondhindenes
trondhindenes / main.py
Created December 28, 2018 19:58
Flask-Injector example
import boto3
from bloop import BaseModel, Column, String, Engine
from flask import Flask
from flask_injector import FlaskInjector, singleton
from flask_restful import Api, Resource
from injector import inject, provider
import random
import string
from bloop_local import patched_local_bloop_engine
- name: Replay GETs against staging #arbitrary name
methods: #only replay these requests
- get
paths: #replay these paths (use wildcard-notation because I suck at regex)
- "/api/1/*"
host_names: #The hostnames to match on
- api.domain.com
strip_headers: #remove these headers before replaying the request (list of strings). You can use wildcards such as
- "X-*" #strip away all X-type headers
- "User-Agent" #Strip away this and add a new one down below
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: config-ansiblejobservicefrontend-v{{ major_version }}-{{ environment }}-{{ environmentid }}-httpsecure
namespace: sre
annotations:
traefik.frontend.passHostHeader: "true"
labels:
expose: internal-httpsecure
@trondhindenes
trondhindenes / traefik_daemonset.yml
Created April 29, 2018 10:00
traefik_daemonset_example
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: traefik-ingress-controller-internal-httpsecure-{{ environment }}
namespace: networking
labels:
app: traefik-ingress-lb-internal-httpsecure
environment: "{{ environment }}"
environmentid: "{{ environmentid }}"
Traceback (most recent call last):
File "/home/trond/apps/pycharm-community-2018.1.1/helpers/pydev/pydevd.py", line 1664, in <module>
main()
File "/home/trond/apps/pycharm-community-2018.1.1/helpers/pydev/pydevd.py", line 1658, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/trond/apps/pycharm-community-2018.1.1/helpers/pydev/pydevd.py", line 1068, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/trond/apps/pycharm-community-2018.1.1/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/trond/Documents/projects-rikstv/SRE/RiksTV.Utils.ServiceOwnership/runserver.py", line 1, in <module>
{
"beat": {
"cpu": {
"system": {
"ticks": 62,
"time": 62
},
"total": {
"ticks": 155,
"time": 155,
@trondhindenes
trondhindenes / site.yml
Created March 25, 2018 08:28
example of using the mssql role to provision RDS databases
- name: do sql things
hosts: sqlserver_jumphost
tasks:
- name: doit
include_role:
name: rikstv_windows_mssqlconfig
vars:
admin_login: "superduperadmin"
admin_password: "superduperpassword"
sql_server_name: "super-duper-mssql01.eu-west-1.rds.amazonaws.com"
@trondhindenes
trondhindenes / main.yml
Created March 25, 2018 08:23
MSSQL config ansible role
- name: Create MSSQL Logins
win_dsc:
resource_name: SqlServerLogin
Ensure: "{{ item['state'] | default('present')}}"
LoginType: "SqlLogin"
ServerName: "{{ sql_server_name }}"
Name: "{{ item['username'] }}"
InstanceName: MSSQLSERVER
LoginCredential_username: "{{ item['username'] }}"
LoginCredential_password: "{{ item['password'] }}"
@trondhindenes
trondhindenes / handler.py
Created February 12, 2018 15:38
Stuff you need for x-ray with Python in lambda
from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.core import patch_all
patch_all()
def handler(event, context):
return 'blarg'