Create prometheus alert for absent metrics
Prerequisites prometheus package installed prometheus-alertmanager package installed node-exporter deployed on target device: this alert is using the node-exporter in order to use node_filesystem_avail_bytes metrics. Create an Alerting Rule in Prometheus PromQL expression to detect missing mountpoints Make sure to test your query on /explore tab. You can use metric node_filesystem_avail_bytes to detect specific mountpoint (e.g. /mnt/data) on specific instance (e.g vm-name:9100): node_filesystem_avail_bytes{instance="vm-name:9100",mountpoint="/mnt/data"} â Any missing mountpoints for an instance might be due to default regexp value of the argument --collector.filesystem.ignored-mount-points="^/(dev|proc|run|sys|mnt|media|var/lib/docker/.+)($|/)", so you might just remove the path you need in regexp value ...
Manage Windows Using Ansible
Setup openssh (prerequisites) Before using ansible to manage windows, make sure that openssh is installed and enabled. If not, you can use this powershell script to do so: $sshServer = Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH.Server*' if ($sshServer.State -ne 'Installed') { Write-Host "Installing OpenSSH Server..." Add-WindowsCapability -Online -Name $sshServer.Name } else { Write-Host "OpenSSH Server is already installed." } # Set default shell to powershell for ansible if (-not (Get-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -ErrorAction SilentlyContinue)) { Write-Host "Set default shell to powershell..." New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShellCommandOption -Value "/c" -PropertyType String -Force } else { Write-Host "Default shell already configured." } # Optional: Reconfigure the firewall to allow SSH traffic to port 2222 (default one is 22) Write-Host "Configuring firewall to allow SSH traffic..." Remove-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue New-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -Description "Inbound rule for OpenSSH SSH Server (sshd)" -DisplayName "OpenSSH Server (sshd)" -Group "OpenSSH Server" -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 2222 # Start the OpenSSH server service Write-Host "Starting OpenSSH Server service..." Restart-Service sshd ## Set the OpenSSH server service to start automatically on boot Write-Host "Configuring OpenSSH Server service to start automatically..." Set-Service -Name sshd -StartupType 'Automatic' Write-Host "OpenSSH setup completed." Run one command ansible -m win_shell -a "hostname" win_group Thatâs it! ...
Ansible Utils Commands
NB: As an example, the machines are defined in file inventory.yaml with the following content: # VMs all: hosts: vm01: vm02: vm03: vm04: vm05: vm06: # Groups dev: hosts: vm01: vm02: test: hosts: vm03: vm04: prod: hosts: vm05: vm06: # Parent Groups lan: children: dev: test: wan: children: prod: â If you did not name your inventory file inventory.yaml at root folder, youâll need to add the argument -i <inventory_filename> to all the commands in the following post. ...
Play steam games remotely using moonlight/sunshine or steam link and wake-on-lan
General overview Goal My goal here is to be able to play on my PC remotely from a portable device (laptop, tablet or phone) . I used steamlink first to play through the Internet. It worked well and did not need to have additional setup (no vpn or additional port in/out manual setup on my computer or router). I also want my computer to be able to go to sleep to save energy and be able to wake it up remotely. I needed a solution to send magic packet (wake on lan) safely so Wireguard VPN comes in action. ...
Troubleshoot Wsl Issues
Change mode/rights of Windows files in WSL Symptoms: By default, if you try to chmod your files hosted on windows in WSL, it wonât change anything e.g. ls -l /mnt/c/userid/.ssh/vault_pass.txt -rwxrwxrwx 1 userid userid 34 Nov 22 14:21 /mnt/c/userid/.ssh/vault_pass.txt chmod 400 /mnt/c/userid/.ssh/vault_pass.txt ls -l /mnt/c/userid/.ssh/vault_pass.txt -rwxrwxrwx 1 userid userid 34 Nov 22 14:21 /mnt/c/userid/.ssh/vault_pass.txt It can be particularly painful for keys since they cannot be too permissive e.g. for a ssh key ...
SSH Getting Started
Generate key ssh-keygen -t ed25519 -C "your_email@example.com" Copy key to server ssh-copy-id -i .ssh/id_ed25519.pub <server_name> Connect to server ssh -i ~/.ssh/id_ed25519 <user>@<server_name> Avoid retyping passphrase on each new connection eval $(ssh-agent -s) ssh-add /mnt/c/Users/f.tith/.ssh/id_ed25519 It is only valid in one session. On terminal kill, youâll need to rerun those commands. Sources https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key
Git Usual Commands
This page describe the usual git commands I used on daily, weekly or monthly basis. Daily push git add -u git commit -m "<changes description>" git push [<remote>] [<branch>] e.g. git add -u git commit -m "add feature" git push origin main Update feature branch from base branch Scenario: you are working on your feature branch âdevâ and made a Pull Request targeting âmainâ as base. Unfortunately, someone pushed changes on the base branch âmainâ and your feature branch âdevâ is âOut-Of-Dateâ. ...
Docker Compose Tips
Useful commands List deployed docker compose project docker compose ls Cleanup containers and volumes docker compose down -v Copy from one volume to another cp -rp /var/lib/docker/volumes/ftith_opensearch-data1/_data/ /var/lib/docker/volumes/opensearch_opensearch-data1/ YAML anchor and aliases Simple x-common_env: &common_env env_file: - db.env services: db: <<: *common_env image: postgres:16.3 frontend: <<: *common_env image: nginx:1.27.0-bookworm Common anchors with multiple docker compose files Due to this bug: https://github.com/docker/compose/issues/5621, youâll need a workaround to fix this issue. Given those 2 files: db.yml ...
Ansible Data Structures
Type of data structures Since Ansible is based on Python. There are two main data structures in Ansible: list and dictionary. List Initialization of a list - name: Initialize an empty list set_fact: list: [] Result is: {"list": []} Append element to a list - name: Append element to list set_fact: list: "{{ list + [ 'element_1' ] }}" Result is: {"list": ["element_1"]} Append multiple elements to a list - name: Get list of files in current directory shell: "ls" register: ls_files - name: Append filtered elements (only yaml file) to list set_fact: list: "{{ list + [ item ] }}" loop: "{{ ls_files.stdout_lines }}" when: "'yaml' in item" Result is: {"list": ["element_1", "list.yaml"]} if your current directory is for instance composed of: ...
Deploy hugo website to Github Pages
Hey! My first post is a dog eats dog post: I will give you the commands I used to deploy my blog using hugo framework to github pages. Sources: Quick start on official Hugo website Papermod Theme Installation Prerequisites git hugo cli Local setup Create a new hugo website This command will generate a template for hugo project. By default it will use .toml extension for the configuration file. You can also use .yaml extension by adding --config hugo.yaml to the first command. ...