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 / 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
@goneri
goneri / vcenter_curl_rest_api.sh
Created April 24, 2020 15:08
Example of interaction with a vCenter with curl and the REST API.
#!/bin/bash
server='https://vcenter.test'
password='z!Zq4Y&`/!E(o<br?:L>'
session_id=$(curl -q -X POST -k -u "[email protected]:${password}" ${server}/rest/com/vmware/cis/session|jq -r .value)
for i in $(seq 10); do
curl -ik -H 'Accept:application/json' -H "vmware-api-session-id:${session_id}" -X GET ${server}/rest/vcenter/cluster
done

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/
@goneri
goneri / vmware_coverage.sh
Last active February 18, 2020 14:39
Ansible VMware module test coverage
#!/bin/bash
echo "module,status"
for module in $(find lib -type f -name 'vmware*.py' -or -name 'vca*.py' -or -name 'vcenter*.py'|xargs -n1 basename -s .py|sort -u); do
aliases_file="test/integration/targets/${module}/aliases"
current_status="no_test"
if [ -f "${aliases_file}" ]; then
if [ -n "$(egrep '(disabled)' ${aliases_file})" ]; then
current_status="disabled"
elif [ -n "$(grep zuul ${aliases_file})" ]; then