Skip to content

Instantly share code, notes, and snippets.

@weshouman
weshouman / README.md
Last active September 7, 2022 20:15
Automating Synology Disk Station

Following are the steps I followed to have further understanding

  1. Know the architecture from this link. Whether the API totally encapsulates the CGI or there are some differences, that is not the topic of this guide, so it's better to be always aware of the Disk Station Architecture your script would support, so that when we have to read the sources we'll know which source to check

  2. Try a working ansible role. That will give a pretty good overview of how the interaction is implemented.

  3. Check the official docs for the

@weshouman
weshouman / README.md
Last active August 19, 2021 15:22
Advanced Ansible hints

Naming

  • Use underscores
  • Do not use hyphens, based on the issues 1042 and 1123

History

  • Previously people used ansible-role-ROLE-NAME and Galaxy removed the ansible-role- part and kept ROLE-NAME
  • Later on galaxy stopped removing the prefix, and left the role maintainers do the heavy-lefting of setting the ROLE-NAME into meta/main.yml:role_name:
    However, there's a trick here, hyphens will be replaced with underscores, only the old roles could keep their hyphens x)
  • Then meta/main.yml:role_name: got deprecated, people got pretty angry as they are now stuck with ansible-role-ROLE-NAME naming, then over time they undeprecated the option
@weshouman
weshouman / README.md
Last active April 17, 2020 09:39
vim regex guide
  • Half the even numbered spaces :% s/\(\( \)\{\-2\}\)/\2/g by matching the the consecutive 4 spaces, source
    • origin: s/(( ){-2}/$2/g
  • Half the even numbered spaces :% s/\^\(\( \)\+\)\\1/\1/g by matching the whole spaces and halving them, source
    • origin: s/^(( )+)\1/$1/g
  • Encapsulate all the small caps strings into double quotes: :% s/\([a-z]\+\)/"\1"/g
    • origin: s /([a-z]+)/"$1"/g
  • Replace [:abc] with "abc": :% s/\[:\([a-z]\+\)\]/"\1"/g
    • origin: s /[:([a-z]+)]/$1/g or s /\[:([a-z]+)\]/$1/g I have to double check
  • Replace Model.enum[:abc].to_s with "abc": :% s/Model\.[a-z]\+\[:\([a-z]\+\)\]\.to_s/"\1"/g
  • origin: s /Model\.[a-z]+[:([a-z]+)]\.to_s/$1/g or s /Model\.[a-z]+\[:([a-z]+)\]\.to_s/$1/g I have to double check
@weshouman
weshouman / exploder.py
Last active September 21, 2023 21:51
Unentangling my yaml confusion
#!/usr/bin/python
# This script cleans up reference keys assuming they start with an underscore
import yaml
import argparse
def read_data(input_file):
# Read YAML file
with open(input_file, 'r') as f:
data = yaml.safe_load(f)
@weshouman
weshouman / bare-metal.md
Last active July 2, 2022 03:03
A guide to some issues working with cloud-init

Post-Setup Modification

I was looking forward to changing the user-data available on baremetal installation of user-data on an RPI, and following are the hits that I reached.

Note: I found multiple instances of the user-data and user-data.i, but I didn't reach yet which is the source as all the ones that I changed got reverted upon a restart.

rsyslog

The warning cc_rsyslog.py:205: FutureWarning: Possible nested set at position 23 is not severe, but it shows up, it could be circumvented using version 19.1

@weshouman
weshouman / kube-registry.yaml
Last active June 10, 2020 12:33 — forked from coco98/kube-registry.yaml
Docker registry on a cluster
apiVersion: v1
kind: ReplicationController
metadata:
name: kube-registry-v0
namespace: kube-system
labels:
k8s-app: kube-registry
version: v0
spec:
replicas: 1
@weshouman
weshouman / README.md
Last active January 31, 2020 13:35
metrics-server deployment tips

Using Geerlingguy's K8s cluster and trying to install the metrics-server has some little snowflakes, following is how they got solved for me.

Steps

  • get the metrics server git clone https://github.com/kubernetes-sigs/metrics-server.git metrics-server
  • label the nodes according to the metrics-server node affinity to ensure it works, original labelling was in my case beta.kubernetes.io/arch=amd64
kubectl label node master kubernetes.io/arch=amd64
kubectl label node node1  kubernetes.io/arch=amd64
kubectl label node node2  kubernetes.io/arch=amd64
@weshouman
weshouman / 1-simple.mk
Last active February 20, 2024 18:16
Makefile function example
PATH = /tmp/
define myfn
processed_input=${PATH}/$(2)
$(1) := $$(processed_input)
endef
mytarget:
$(eval FILE=myfile)
$(eval $(call myfn,abs_filename,$(FILE)))
@weshouman
weshouman / docker_ps_specific_period.sh
Created January 24, 2020 11:09
a script to get the containers based on their age
# -------
## Status
# -------
# export DISABLE_STATUS="true" # any status
export DISABLE_STATUS="" # the specified status
export RUNNING=true
# export RUNNING=false
# -----
@weshouman
weshouman / sublime_plugins.md
Last active January 18, 2020 13:13
A list of useful plugins