Skip to content

Instantly share code, notes, and snippets.

View yogeek's full-sized avatar

Guillaume Dupin yogeek

View GitHub Profile
@yogeek
yogeek / docker-stack.yml
Created January 16, 2018 23:24
ElasticSearch
version: "3.4"
services:
elasticsearch:
# Remember to "sysctl -w vm.max_map_count=262144" on swarm nodes
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.5
environment:
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: elasticsearch
@yogeek
yogeek / Check ENV var
Created January 15, 2018 20:55
Bash condition
if [ -z "${VAR}" ]; then
echo "VAR is unset or set to the empty string"
fi
if [ -z "${VAR+set}" ]; then
echo "VAR is unset"
fi
if [ -z "${VAR-unset}" ]; then
echo "VAR is set to the empty string"
fi
if [ -n "${VAR}" ]; then
@yogeek
yogeek / daemon.json
Created January 9, 2018 14:02
Docker Private Registry (insecure)
# /etc/docker/daemon.json
# (stop docker before editing et start after)
{
"data-root": "/data/docker",
"hosts": [
"unix:///var/run/docker.sock",
"tcp://0.0.0.0:2376"
],
"insecure-registries": [
"registry-host:5000"
@yogeek
yogeek / Chrome extension policy
Last active January 7, 2018 12:40
Chrome Windows Admin Policy
# Interdire les utilisateurs d'installer des extensions
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallBlacklist
ValueName = 1
Value Type = REG_SZ
Value = *
# Autoriser certaines extensions
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\EnabledPlugin
@yogeek
yogeek / Process
Created January 6, 2018 19:39
System commands
# List of top processes ordered by RAM and CPU use in descendant form
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
@yogeek
yogeek / docker-machine-playbook.yml
Created January 5, 2018 19:20
Docker-Machine playbook
---
- hosts: localhost
vars:
docker_machine_version: v0.14.0
tasks:
- name: Install Docker Machine
get_url:
url: "https://github.com/docker/machine/releases/download/{{ docker_machine_version }}/docker-machine-linux-x86_64"
@yogeek
yogeek / docker-compose.yml
Created January 5, 2018 18:34
docker-compose generic readiness condition
# Example : waiting for DB and Elasticsearch to be ready before launching a service
# The svc docker image must contain the start-when-ready.sh script
services:
svc:
image: svc
environment:
READINESS_CONDITION: '[ $$(curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st) = 200 ] && nc -w 1 -z $$DB_HOST $$DB_PORT 2>/dev/null'
READINESS_SLEEP: 5
# Adapted from <https://superuser.com/questions/332252/creating-and-formating-a-partition-using-a-bash-script>
(
echo d # Delete sda2 partition table
echo 2 # Default = sda2
echo n # Add a new sda2 partition
echo p # Primary partition
echo 2 # Partition number
echo # First sector (Accept default: 2099200)
echo # Last sector (Accept default: varies, e.g 104857599)
# Script to switch between HTTP and SSH git remote URL
gitswitch () {
if [[ "$(git remote -v)" == "" ]]
then
echo "No remote configured. Use 'git remote add' to set one"
return
fi
remoteRoot=$(git remote -v | head -1 | grep root)
@yogeek
yogeek / Test jinja template
Last active April 15, 2019 13:11
Ansible comands
./ansible.sh -i inventories/dev -c local -m template -a "src=file.j2 dest=file.txt" 127.0.0.1
# Online tool
https://cryptic-cliffs-32040.herokuapp.com/
# https://stackoverflow.com/questions/35407822/how-can-i-test-jinja2-templates-in-ansible