Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍🏭

Gonéri Le Bouder goneri

👨‍🏭
View GitHub Profile
@goneri
goneri / deploy-windmill.sh
Created Apr 30, 2020
deploy a all-in-one Zuul with Windmill
View deploy-windmill.sh
#!/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
View connect-windows-vm.sh
# 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 Apr 24, 2020
Example of interaction with a vCenter with curl and the REST API.
View vcenter_curl_rest_api.sh
#!/bin/bash
server='https://vcenter.test'
password='z!Zq4Y&`/!E(o<br?:L>'
session_id=$(curl -q -X POST -k -u "administrator@vsphere.local:${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
View personal_notes.md

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 Apr 2, 2020
Push a given commit on Github
View push-patch
#!/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,.*/,,')
View 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 Mar 2, 2020
Automagically pick ansible/ansible PR
View magic-pick.py
#!/usr/bin/python
import re
import urllib.request
import argparse
import subprocess
parser = argparse.ArgumentParser()
parser.add_argument("pr_id", type=int)
View gist:4d1ce451d27ed48126c3648cf6219bc2
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 Feb 21, 2020
Cherry pick a patch, even if the file has been renamed.
View cherry_pick_patch_demo.sh
#!/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 Feb 18, 2020
Ansible VMware module test coverage
View vmware_coverage.sh
#!/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