Skip to content

Instantly share code, notes, and snippets.

View d3athkai's full-sized avatar
🦾
Kaizen

SK d3athkai

🦾
Kaizen
  • Singapore
  • 10:24 (UTC +08:00)
View GitHub Profile
@d3athkai
d3athkai / Ansible and yum check-update return codes.md
Last active December 30, 2023 05:12
Ansible and yum check-update return codes [rc]

Yum check-update return codes

When using yum check-update in Ansible Playbook, it may failed sometimes because of the following reasons:

  • yum check-update returns exit value of 100 if there are packages available for an update. Also returns a list of the packages to be updated in list format.
  • yum check-update returns 0 if no packages are available for update.
  • yum check-update returns 1 if an error occurred.

The easiest way is to use ignore_error: yes in your that task, but this will also cause other return codes to be ignored and your playbook will continue execute.

The better way is to add the following line:

@d3athkai
d3athkai / Ansible Tips and Tricks.md
Last active May 9, 2024 11:59
Ansible Tips and Tricks

Ansible Tips and Tricks

A collection of some of my useful Ansible Tips and Tricks.


Configure default Ansible user and Python interpreter

In /etc/ansible/ansible.cfg, under [defaults], add:

remote_user=<ansible-user>
interpreter_python=/usr/bin/python3
@d3athkai
d3athkai / Linux CSR.md
Last active April 27, 2024 11:01
Certificate Signing Request (CSR) in Linux

Generate Linux CSR

This guide will show you how to generate certificate signing request (CSR) file in Linux system.
The CSR file generated will be sent and signed by the CA server.

Subject Alternative Name (SAN) is required by chromium-based browers such as Chrome or Microsoft Edge.
Without SAN, chromium-based browers will still display the SSL error: ERR_CERT_COMMON_NAME_INVALID.

Generate client private key:
openssl genrsa -out myhost.example.com.key 2048

@d3athkai
d3athkai / RegEx Tips and Tricks.md
Last active January 5, 2024 02:37
Regular Expression Tips and Tricks

Regular Expression Tips and Tricks

A collection of some of my useful Regular Expression Tips and Tricks.


Detect all variants of text

Given the following list of input:

1test2
test2
1test

Free DNS

https://nip.io is a dead simple wildcard DNS for any IP Address without any registration.
nip.io maps <anything>[.-]<IP Address>.nip.io to .
Can be useful for application deployments with apache/nginx.

Usage examples

To give URL for your ip 192.168.0.1, you can have the following URLs:

  • 192.168.0.1.nip.io
  • anything.192.168.0.1.nip.io

Linux CLI to download releases from GitHub Repo

  • Use curl to get the JSON response for the latest release
  • Use grep to find the line containing file URL
  • Use cut and tr to extract the URL
  • Use wget to download it
curl -s https://api.github.com/repos/jgm/pandoc/releases/latest \
| grep "browser_download_url.*deb" \
@d3athkai
d3athkai / Linux Tips and Tricks.md
Last active January 13, 2024 04:37
Linux Tips and Tricks

Linux Tips and Tricks

A collection of some of my useful Linux Tips and Tricks.


Check if a restart is needed

If a restart is required in a Linux instance, it will add a file: /var/run/reboot-required.
It contains the message *** System restart required ***.


Check and Auto-Fix File System

@d3athkai
d3athkai / Screen.md
Created April 26, 2023 16:46
Screen Usage

Screen

Screen or GNU Screen is a terminal multiplexer. In other words, it means that you can start a screen session and then open any number of windows (virtual terminals) inside that session. Processes running in Screen will continue to run when their window is not visible even if you get disconnected.

Usage

Start a Named Session

screen -S <session_name>

List all Sessions

screen -list