Skip to content

Instantly share code, notes, and snippets.

View goneri's full-sized avatar
🇺🇦

Gonéri Le Bouder goneri

🇺🇦
View GitHub Profile
@goneri
goneri / gist:ad252e30d48cfea99aaeb2e18736303e
Last active November 26, 2020 19:33
run k8s_info 100x in a row
- hosts: localhost
gather_facts: false
tasks:
- k8s_info:
kind: Pod
with_sequence: count=100
#!/bin/bash
set -eux
aws --version |grep aws-cli || pip install awscli
bucket_name="nodepool-images-test"
if ! aws s3 ls s3://${bucket_name}; then
aws s3 mb s3://${bucket_name} --region us-east-2
fi
for image_local_path in $(find /opt/nodepool/images -maxdepth 1 -name 'centos-8-0000002059.raw'); do
@goneri
goneri / deploy-windmill.sh
Created April 30, 2020 21:26
deploy a all-in-one Zuul with Windmill
#!/bin/bash
set -eux
# https://virt-lightning.org/
vl fetch ubuntu-18.04
vl start --memory 2048 ubuntu-18.04
target=$(vl status| awk '/ubuntu-1804/ {print$4}')
ssh $target sudo chsh -s /bin/bash goneri
ssh $target sudo apt update
# My stuff
ssh $target sudo apt install -y silversearcher-ag
# No compression/unsecure
xfreerdp /u:goneri /w:1880 /h:1000 /v:localhost:3389 /sound:sys:pulse -compression -encryption +home-drive
# Compression/Secure
xfreerdp /u:goneri /w:1880 /h:1000 /v:localhost:3389 /sound:sys:pulse +home-drive

Connection

Connection are reused if the task has a loop.

lib/ansible/executor/task_executor.py -> self._connection = self._get_connection(variables=variables, templar=templar)

@goneri
goneri / push-patch
Created April 2, 2020 19:04
Push a given commit on Github
#!/bin/bash
set -eux
commits=$*
current_dir=$(pwd)
temp_dir=$(mktemp -du)
github_user=$(git config --get github.user)
origin_url=$(git config --get remote.origin.url)
project=$(git config --get remote.origin.url|sed 's,/$,,'|sed 's,.*/,,')
@goneri
goneri / purge_volumes.sh
Created April 1, 2020 15:45
purge_volumes.sh
#!/bin/bash
set -eux
function clean_up_volumes() {
openstack volume list -f value -c ID -c Status|awk '/available/ {print $1}'|xargs -r openstack volume delete
}
OS_CLOUD=vexxhost OS_REGION_NAME=ca-ymq-1 clean_up_volumes
OS_CLOUD=vexxhost OS_REGION_NAME=sjc1 clean_up_volumes
OS_CLOUD=limestone OS_REGION_NAME=us-slc clean_up_volumes
OS_CLOUD=limestone OS_REGION_NAME=us-dfw-1 clean_up_volumes
@goneri
goneri / magic-pick.py
Created March 2, 2020 22:35
Automagically pick ansible/ansible PR
#!/usr/bin/python
import re
import urllib.request
import argparse
import subprocess
parser = argparse.ArgumentParser()
parser.add_argument("pr_id", type=int)
import json
import re
from pprint import pprint
def path_to_module_name(path, value):
def is_element(i):
if i and not '{' in i:
return True
else:
@goneri
goneri / cherry_pick_patch_demo.sh
Last active February 21, 2020 14:56
Cherry pick a patch, even if the file has been renamed.
#!/bin/bash
set -eux
git clone https://github.com/goneri/ansible_vmware_collection /tmp/cherry_pick_demo
cd /tmp/cherry_pick_demo
# starts a dev branch
git checkout -B dev origin/master
git mv community/vmware/plugins/modules/vmware_dvswitch.py ansible/vmware/plugins/modules/