Skip to content

Instantly share code, notes, and snippets.

---
- name: Set the host grouping
set_fact:
host_grouping: "{% if inventory_hostname != groups['k8s_master'][0] %}master{% else %}worker{% endif %}"
- name: set cluster API address.
set_fact:
# cluster_api_address: "{{ hostvars[groups['k8s_master'][0]].ansible_default_ipv4.address }}"
cluster_api_address: "{{ hostvars[groups['k8s_master'][0]]['secondary_ip'] if ('secondary_ip' in hostvars[groups['k8s_master'][0]]) else hostvars[groups['k8s_master'][0]]['ansible_default_ipv4']['address'] }}"
@piersharding
piersharding / minikube-on-windiws.md
Created June 19, 2019 02:04
Launching Minikube on Windows
@piersharding
piersharding / python.sh
Created February 17, 2019 23:52
Wrapper for .env vars for vscode-python broken-ness - https://github.com/Microsoft/vscode-python/issues/944
#!/bin/sh
# environment fix for vscode-python problems https://github.com/Microsoft/vscode-python/issues/944
# stick this in ${workspaceFolder}/venv/bin/python.sh and adjust settings.json:
# "python.pythonPath": "${workspaceFolder}/venv/bin/python.sh",
# "python.envFile": "${workspaceFolder}/dev.env",
# "python.terminal.activateEnvironment": true,
# "python.venvPath": "${workspaceFolder}/venv"
# ...
echo "Current path is " `pwd`
@piersharding
piersharding / test_http_proxy_in_dockerfile.sh
Last active February 3, 2019 20:56
Dockerfile --build-arg - behaviour of http_proxy
#!/bin/sh -x
# test using your own http_proxy value at build time
# there is a default ARG for http_proxy already available
IMG=test
docker rm -f ${IMG}
cat <<EOF | docker build --build-arg HTTP_PROXY=http://piers-work:3128 -t ${IMG} -
@piersharding
piersharding / python
Created January 31, 2019 03:47
Launching Python interpreter in a container for PyCharms (example)
#!/usr/bin/env bash
docker run --rm --net=host -e HOME=${HOME} -v /etc/passwd:/etc/passwd:ro --user=$(id -u) -v /snap:/snap -v ${HOME}:${HOME} -w ${HOME} -i python:3.6 python $*
@piersharding
piersharding / docker-credentials.sh
Last active April 26, 2024 21:16
Create Docker config.json file credentials
#!/bin/bash
# This script creates a docker config.json file with the auth section
# as an example of what can be passed into GitLab-CI and used in
# conjunction with DOCKER_CONFIG - the config file directory location.
# command line parameter default values
DOCKER_REGISTRY=""
DOCKER_USER=""
DOCKER_PASSWORD=""
@piersharding
piersharding / sh
Created October 8, 2016 18:12
Terminal trouble with apt-get GPG signatures in /etc/apt/trusted.gpg
# fix completely broken signature validation for apt whe you get message like:
# W: GPG error: http://archive.canonical.com/ubuntu xenial InRelease: At least one invalid signature was encountered.
# W: The repository 'http://archive.canonical.com/ubuntu xenial InRelease' is not signed.
# N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
# N: See apt-secure(8) manpage for repository creation and user configuration details.
# ...
# and running:
apt-key update
@piersharding
piersharding / bigvis-diamonds-example.R
Last active December 17, 2015 03:39
An example of how to use bigvis - https://github.com/hadley/bigvis
# use bigvis to bin, condense, smooth and present data
library('bigvis')
library('ggplot2')
# subset the diamonds data
mydiamonds <- subset(diamonds, carat < 2.75)
# condense avg price based on bins of carat sizes of .1 carat intervals
myd <- condense(bin(mydiamonds$carat, .1), z=mydiamonds$price, summary="mean")
# smooth out the trend