Skip to content

Instantly share code, notes, and snippets.

- hosts: localhost
vars:
k8s_namespaces:
- argocd-system
- monitoring-system
tasks:
- include_tasks: fetcher-role-v2.yaml
- include_tasks: kubectl-role.yaml

Ansible kubectl role

Ansible role for kubectl command with resource checking

Usage

Get list of required kubernetes resources on cluster

 tasks:

Simple kubernetes namespace context switcher (with autocompletion)

functions.sh

function kn {
    kubectl config set-context --current --namespace=$1
}

function knx {

Authorization service for kubectl

Create service wrapper beargen.sh

export HOSTNAME=$1

export USER=username
export PASSWORD=$(security find-generic-password -l Exchange -g -w)
@stepanpelc
stepanpelc / Auto_Dark_Mode_Colors.py
Last active May 7, 2020 10:29
iTerm 2: Sync color presets with iTerm2 light and dark themes forked from https://gitlab.com/snippets/1840760
#!/usr/bin/env python3.7
"""
Auto_Dark_Mode_Colors auto set profile colors based on iTerm2 theme.
To configure, update the mapping in `PROFILE_PRESETS` such that the profile
name maps to the light and dark presets you'd like to use.
"""
import asyncio
import iterm2
@stepanpelc
stepanpelc / exchange_atachments.py
Last active May 1, 2020 08:12
[#Python client for extracting #attachments] from Microsoft #Exchange mailserver
from exchangelib import Credentials, Account, Configuration, ServiceAccount, FileAttachment, ItemAttachment, Message, CalendarItem, HTMLBody, NTLM, DELEGATE, IMPERSONATION
from exchangelib.protocol import BaseProtocol, NoVerifyHTTPAdapter
import os.path
credentials = Credentials('DOMAIN\\DOMAIN_USER', 'PASSWORD')
config = Configuration(server='mail.server.cz',
credentials=credentials, auth_type=NTLM)
account = Account('user@server.cz', autodiscover=True,
credentials=credentials)
SELECT obec.nazev, momc.nazev, cast_obce.nazev, COUNT(DISTINCT ulice.nazev) AS pocet_ulic FROM adresni_bod
INNER JOIN obec ON adresni_bod.obec_kod = obec.kod AND obec.nazev = 'Praha'
INNER JOIN ulice ON adresni_bod.ulice_kod = ulice.kod
INNER JOIN cast_obce ON adresni_bod.cast_obce_kod = cast_obce.kod
INNER JOIN momc ON adresni_bod.momc_kod = momc.kod
GROUP BY obec.nazev, momc.nazev, cast_obce.nazev WITH ROLLUP;