Skip to content

Instantly share code, notes, and snippets.

@eoldavix
eoldavix / playbook.yml
Created September 16, 2019 07:58
Ansible: Get AMI instance type of an AWS EC2 machine
- hosts: all
tasks:
- name: Gathering Instance Type
uri:
url: http://169.254.169.254/latest/meta-data/instance-type
return_content: yes
register: curl
- debug:
@eoldavix
eoldavix / ilo.sh
Created September 25, 2018 14:28
Enable ILO management from external network
# Enable ILO management from external network
PORTS="22 443 80 623 17990 17988"
IPILO=192.168.1.x
SSHUSER=root
EXTERNALURL=domain.tld
SSHOPTS="" ; for i in ${PORTS} ; do SSHOPTS="$SSHOPTS -L ${i}:${IPILO}:${i}" ; done ; ssh -C ${SSHOPTS} ${SSHUSER}@${EXTERNALURL}
@eoldavix
eoldavix / docker-compose.yml
Created July 30, 2018 11:48
Docker Stack for Docker Flow Proxy with automatic LetsEncrypt certificate creation
version: "3"
services:
proxy:
image: vfarcic/docker-flow-proxy
ports:
- 80:80
- 443:443
volumes:
- dfp-certs:/certs
@eoldavix
eoldavix / lastmultioccurrence.sh
Created December 12, 2017 10:53
Get last multiline occurrence in a file
#!/bin/bash
tac < test.xml | sed '/<\/food>/,$!d;/<food/q' | tac
@eoldavix
eoldavix / unix_perms.py
Last active November 15, 2017 12:39
Unix 'ls' permissions to octal
import re
ISAPERM = r'(^[ld\-](?:[r\-][w\-][x\-sS]){2}[r\-][w\-][x\-tT](?:\.)?$)'
def to_octal(perms):
if re.compile(ISAPERM).match(perms):
userperms = perms[1:4]
groupperms = perms[4:7]
otherperms = perms[7:10]
@eoldavix
eoldavix / disableInsecureRequestWarning.py
Created September 28, 2017 11:50
Disable InsecureRequestWarning in python requests
import requests
requests.packages.urllib3.disable_warnings()
@eoldavix
eoldavix / galera_stretch.md
Last active July 28, 2017 09:23
Clúster MariaDB con Galera en Debian 9 Stretch

Clúster MariaDB con Galera en Debian 9 Stretch from scratch

Todos los pasos a continuación se realizan como usuario root

Suponiendo dos servidores con IP's 10.1.0.1 (galera1) y 10.1.0.2 (galera2), la instalación de un cluster MariaDB es bien sencilla.

  • Instalamos mariadb-server en nuestros nodos: apt install mariadb-server
  • Paramos el servicio mariadb.service en todos los nodos: systemctl stop mariadb.service
@eoldavix
eoldavix / changeme
Last active July 26, 2017 08:02
Cambiar contraseña de un usuario en una línea
echo CHANGEME | passwd --stdin myuser
@eoldavix
eoldavix / 0_reuse_code.js
Created October 28, 2016 11:43
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@eoldavix
eoldavix / macGenerator.py
Created June 21, 2016 09:16
Random hardware MAC file generator
#!/usr/bin/env python
# coding=utf-8
import random
def HexGenerator():
return format(random.randrange(255), '02x')
def MacGenerator():
return "{}:{}:{}:{}:{}:{};".format(HexGenerator(),