Skip to content

Instantly share code, notes, and snippets.

@yilas
yilas / imds.sh
Last active December 21, 2023 08:36
AWS IMDSv2 (token, etc.)
TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/
curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/ami-id
## Creds
curl -H "X-aws-ec2-metadata-token: $TOKEN" -sS http://169.254.169.254/latest/meta-data/iam/security-credentials
curl -H "X-aws-ec2-metadata-token: $TOKEN" -sS http://169.254.169.254/latest/meta-data/iam/security-credentials/test-yann-instanceprofile01|jq
export AWS_ACCESS_KEY_ID="ASIA2*REDACTED*"
Task 1: Create a project jumphost instance
Navigation menu > Compute engine > VM Instance
Task 2: Create a Kubernetes service cluster
gcloud config set compute/zone us-east1-b
gcloud container clusters create nucleus-webserver1
@yilas
yilas / gist:d6f0e29330143c549e0b60a76d650617
Created April 9, 2021 07:06
Installation of Vagrant With Libvirt KVM Provider
sudo dnf install gcc libvirt libvirt-devel libxml2-devel make ruby-devel
CONFIGURE_ARGS="with-libvirt-include=/usr/include/libvirt with-libvirt-lib=/usr/lib64" vagrant plugin install vagrant-libvirt
CONFIGURE_ARGS="with-libvirt-include=/usr/include/libvirt with-libvirt-lib=/usr/lib64" vagrant plugin install vagrant-mutate
@yilas
yilas / gist:1137a17fb769eb9caee8b4b913cbeb2d
Created December 18, 2017 13:40
Remove SENHW_ from /tmp
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# vim: :set ts=8 et sw=4 sts=4
import glob, sys
def CleanTmpDir():
folder = '/tmp'
import os
for the_file in os.listdir(folder):
@yilas
yilas / Divers
Last active March 4, 2016 13:09
## sed fichier /etc/hosts
sed -n '/HostsBegin/,/HostsEnd/p' /etc/hosts|\
egrep -v '^[[:space:]]*$|^#' |\
while read ipaddr hn x; do
if ! ping -c 2 -W 2 $ipaddr >/dev/null 2>&1; then
echo $ipaddr $hn unreachable
fi
done
@yilas
yilas / VPN_IPsec_PSK_noNAT.markdown
Created February 24, 2016 13:37
VPN IPsec PSK between 2 VM separated by a router
[root@vm-2-100 ~]# cat /etc/ipsec.conf
# /etc/ipsec.conf - Openswan IPsec configuration file
#
# Manual:     ipsec.conf.5
#
# Please place your own config files in /etc/ipsec.d/ ending in .conf

version 2.0     # conforms to second version of ipsec.conf specification
@yilas
yilas / tmux_cheatsheet.markdown
Created February 24, 2016 13:12 — forked from henrik/tmux_cheatsheet.markdown
tmux cheatsheet

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

# csv
import csv
file_csv = ''
csvfile = open(file_csv, 'rb')
reader = csv.reader(csvfile)
for row in reader:
print row
import csv
import os
scsi = os.popen('lsscsi').read().rstrip().split('\n')
for l in [s.split() for s in scsi]:
print l[0], l[-1]
==== IAAS / Q5 ====
ca = i.config.cloudApiConnection.find('main')
volid = 'c0a12a612e5946ea'
ca.disk.find(id = volid)
volguid = ca.disk.find(id = volid)['result'][0]
volguid
ca.disk.getObject(volguid)