First big articles reformatting now that I properly understand hugo

This commit is contained in:
Julien Dessaux 2021-03-11 19:47:26 +01:00
parent 5e6844592a
commit 1a4981a826
40 changed files with 184 additions and 173 deletions

View file

@ -1,5 +0,0 @@
---
title: "Ansible"
linkTitle: "Ansible"
weight: 30
---

View file

@ -1,17 +1,31 @@
--- ---
title: "Ansible vault example" title: "Ansible vault example"
linkTitle: "Ansible vault example"
date: 2018-02-21 date: 2018-02-21
description: > description: Getting started with ansible vault
Ansible vault example tags:
- ansible
--- ---
## Editing a protected file
Here is how to edit a vault protected file : Here is how to edit a vault protected file :
{{< highlight sh >}} {{< highlight sh >}}
ansible-vault edit hostvars/blah.yml ansible-vault edit hostvars/blah.yml
{{< / highlight >}} {{< / highlight >}}
Here is how to put a multiline entry like a private key in vault (for a simple value, just don't use a `|`): ## Using a vault entry in a task or a jinja template
It is as simple as using any variable :
{{< highlight yaml >}}
- copy:
path: /etc/ssl/private.key
mode: 0400
content: '{{ ssl_key }}'
{{< / highlight >}}
## How to specify multiple lines entries
This is actually a yaml question, not a vault one but since I ask myself this frequently in this context here is how to put a multiple lines entry like a private key in vault (for a simple value, just don't use a `|`):
{{< highlight yaml >}} {{< highlight yaml >}}
ssl_key : | ssl_key : |
@ -21,13 +35,7 @@ ssl_key : |
----- END PRIVATE KEY ----- ----- END PRIVATE KEY -----
{{< /highlight >}} {{< /highlight >}}
And here is how to use it in a task : ## How to run playbooks when vault values are needed
{{< highlight yaml >}}
- copy:
path: /etc/ssl/private.key
mode: 0400
content: '{{ ssl_key }}'
{{< / highlight >}}
To run a playbook, you will need to pass the `--ask-vault` argument or to export a `ANSIBLE_VAULT_PASSWORD_FILE=/home/julien/.vault_pass.txt` variable (the file needs to contain a single line with your vault password here). To run a playbook, you will need to pass the `--ask-vault` argument or to export a `ANSIBLE_VAULT_PASSWORD_FILE=/home/julien/.vault_pass.txt` variable (the file needs to contain a single line with your vault password here).

View file

@ -1,17 +1,19 @@
--- ---
title: "Ansible custom facts" title: "Ansible custom facts"
linkTitle: "Ansible custom facts"
date: 2018-09-25 date: 2018-09-25
description: > description: How to write custom facts with ansible
How to write custom facte with ansible tags:
- ansible
--- ---
## Introduction
Custom facts are actually quite easy to implement despite the lack of documentation about it. Custom facts are actually quite easy to implement despite the lack of documentation about it.
## How they work ## How custom facts work
On any Ansible controlled host — that is, the remote machine that is being controlled and not the machine on which the playbook is run — you just need to create a directory at On any Ansible controlled host — that is, the remote machine that is being controlled and not the machine on which the playbook is run — you just need to create a directory at
`/etc/ansible/facts.d`. Inside this directory, you can place one or more `*.fact` files. These are files that return JSON data, which will then be included in the raft of facts that `/etc/ansible/facts.d`. Inside this directory, you can place one or more `*.fact` files. These are files that must return JSON data, which will then be included in the raft of facts that
Ansible gathers. Ansible gathers.
The facts will be available to ansible at `hostvars.host.ansible_local.<fact_name>`. The facts will be available to ansible at `hostvars.host.ansible_local.<fact_name>`.
@ -31,7 +33,7 @@ This will give you the fact `hostvars.host.ansible_local.mysql.password` for thi
## A more complex example ## A more complex example
A more interesting example is something I use with small webapps. In the container that hosts the frontent I use a small ansible role to generate a mysql password on its first run, and A more interesting example is something I use with small webapps. In the container that hosts the frontent I use a small ansible role to generate a mysql password on its first run, and
provision a database with a user that has access to it on a mysql server. This fact ensures that on subsequent runs we will stay idempotents. Here is how it works. provision a database with a user that has access to it on a mysql server. This fact ensures that on subsequent runs we will stay idempotent.
First the fact from before, only slightly modified : First the fact from before, only slightly modified :
{{< highlight sh >}} {{< highlight sh >}}

View file

@ -1,11 +1,13 @@
--- ---
title: "Dump all ansible variables" title: "Dump all ansible variables"
linkTitle: "Dump all ansible variables"
date: 2019-10-15 date: 2019-10-15
description: > description: How to dump all variables used by ansible in a task
How to dump all variables used by ansible tags:
- ansible
--- ---
## Task to use
Here is the task to use in order to achieve that : Here is the task to use in order to achieve that :
{{< highlight yaml >}} {{< highlight yaml >}}
@ -13,6 +15,8 @@ Here is the task to use in order to achieve that :
action: template src=dumpall.j2 dest=ansible.all action: template src=dumpall.j2 dest=ansible.all
{{< /highlight >}} {{< /highlight >}}
## Associated template
And here is the template to use with it : And here is the template to use with it :
{{< highlight jinja >}} {{< highlight jinja >}}
@ -36,3 +40,7 @@ HOST Variables ("hostvars"):
-------------------------------- --------------------------------
{{ hostvars | to_nice_json }} {{ hostvars | to_nice_json }}
{{< /highlight >}} {{< /highlight >}}
## Output
If you are running a local task, the output will be in your playbook directory. Otherwise, it will be on the target machine(s) in a `.ansible/tmp/ansible.all` file under the user your are connecting the machine(s)' with.

View file

@ -1,5 +0,0 @@
---
title: "Cfengine"
linkTitle: "Cfengine"
weight: 40
---

View file

@ -1,11 +1,13 @@
--- ---
title: "Leveraging yaml with cfengine" title: "Leveraging yaml with cfengine"
linkTitle: "Leveraging yaml with cfengine"
date: 2018-09-25 date: 2018-09-25
description: > description: How to leverage yaml inventory files with cfengine
How to leverage yaml inventory files with cfengine tags:
- cfengine
--- ---
## Introduction
CFEngine has core support for JSON and YAML. You can use this support to read, access, and merge JSON and YAML files and use these to keep policy files internal and simple. You CFEngine has core support for JSON and YAML. You can use this support to read, access, and merge JSON and YAML files and use these to keep policy files internal and simple. You
access the data using the usual cfengine standard primitives. access the data using the usual cfengine standard primitives.

View file

@ -1,5 +0,0 @@
---
title: "Commands"
linkTitle: "Commands"
weight: 40
---

View file

@ -1,11 +1,13 @@
--- ---
title: "List active calls on asterisk" title: "List active calls on asterisk"
linkTitle: "List active calls on asterisk"
date: 2018-09-25 date: 2018-09-25
description: > description: How to show active calls on an asterisk system
How to show active calls on an asterisk system tags:
- asterisk
--- ---
## Using the cli
{{< highlight yaml >}} {{< highlight yaml >}}
watch -d -n1 'asterisk -rx “core show channels”' watch -d -n1 'asterisk -rx “core show channels”'
{{< /highlight >}} {{< /highlight >}}

View file

@ -1,11 +1,13 @@
--- ---
title: "How to have asterisk call you into a meeting" title: "How to have asterisk call you into a meeting"
linkTitle: "How to have asterisk call you into a meeting"
date: 2018-09-25 date: 2018-09-25
description: > description: How to have asterisk call you itself into a meeting
How to have asterisk call you itself into a meeting tags:
- asterisk
--- ---
## Using the cli
At alterway we sometimes have DTMF problems that prevent my mobile from joining a conference room. Here is something I use to have asterisk call me At alterway we sometimes have DTMF problems that prevent my mobile from joining a conference room. Here is something I use to have asterisk call me
and place me inside the room : and place me inside the room :

View file

@ -1,12 +1,15 @@
--- ---
title: "Busybox web server" title: "Busybox web server"
linkTitle: "Busybox web server"
date: 2019-04-16 date: 2019-04-16
description: > description: How to serve static files from only busybox
Busybox web server tags:
- linux
- simple utilities
--- ---
If you have been using things like `python -m SimpleHTTPServer`, here is something even more simple and lightweight to use : ## The command
If you have been using things like `python -m SimpleHTTPServer` to serve static files in a pinch, here is something even more simple and lightweight to use :
{{< highlight sh >}} {{< highlight sh >}}
busybox httpd -vfp 80 busybox httpd -vfp 80

View file

@ -1,12 +1,14 @@
--- ---
title: "Capture a video of your desktop" title: "Capture a video of your desktop"
linkTitle: "Capture a video of your desktop"
date: 2011-11-20 date: 2011-11-20
description: > description: Capture a video of your desktop
Capture a video of your desktop tags:
- ffmpeg
--- ---
You can capture a video of your linux desktop with ffmpeg : ## The command
You can capture a video of your linux desktop very easily with ffmpeg :
{{< highlight sh >}} {{< highlight sh >}}
ffmpeg -f x11grab -s xga -r 25 -i :0.0 -sameq /tmp/out.mpg ffmpeg -f x11grab -s xga -r 25 -i :0.0 -sameq /tmp/out.mpg

View file

@ -1,12 +1,14 @@
--- ---
title: "Clean conntrack states" title: "Clean conntrack states"
linkTitle: "Clean conntrack states"
date: 2018-03-02 date: 2018-03-02
description: > description: How to clean conntrack states
Clean conntrack states tags:
- linux
--- ---
Here is an example of how to clean conntrack states that match a specific query on a linux firewall : ## A not so simple command
Firewalling on linux is messy, here is an example of how to clean conntrack states that match a specific query on a linux firewall :
{{< highlight sh >}} {{< highlight sh >}}
conntrack -L conntrack -p tcp orig-dport 65372 | \ conntrack -L conntrack -p tcp orig-dport 65372 | \

View file

@ -1,12 +1,14 @@
--- ---
title: "Convert unix timestamp to readable date" title: "Convert unix timestamp to readable date"
linkTitle: "Convert unix timestamp to readable date"
date: 2011-01-06 date: 2011-01-06
description: > description: the -d flag of the date command combined with @timestamp
Convert unix timestamp to readable date tags:
- simple utilities
--- ---
As I somehow have a hard time remembering this simple date flags as I rarely need it, I decided to write it down here : ## The trick
I somehow have a hard time remembering this simple date flags *(probably because I rarely get to practice it), I decided to write it down here :
{{< highlight sh >}} {{< highlight sh >}}
$ date -d @1294319676 $ date -d @1294319676

View file

@ -1,12 +1,14 @@
--- ---
title: "DMIdecode" title: "DMIdecode"
linkTitle: "DMIdecode"
date: 2011-02-16 date: 2011-02-16
description: > description: Some DMIdecode common flags
DMIdecode tags:
- simple utilities
--- ---
DMIdecode to obtain Hardware informations. ## Introduction
DMIdecode is a tool to obtain Hardware informations.
## Mose useful commands ## Mose useful commands

View file

@ -1,12 +1,12 @@
--- ---
title: "Find hardlinks to a same file" title: "Find hardlinks to a same file"
linkTitle: "Find hardlinks to a same file"
date: 2018-03-02 date: 2018-03-02
description: > description: How to list hardlinks that link to the same file
Find hardlinks to a same file tags:
- find
- simple utilities
--- ---
{{< highlight sh >}} {{< highlight sh >}}
find . -samefile /path/to/file find . -samefile /path/to/file
{{< /highlight >}} {{< /highlight >}}

View file

@ -1,12 +1,12 @@
--- ---
title: "Find where inodes are used" title: "Find where inodes are used"
linkTitle: "Find where inodes are used"
date: 2018-04-25 date: 2018-04-25
description: > description: How to locate what is taking all the inodes in the subdirectory of a given device
Find where inodes are used tags:
- find
- simple utilities
--- ---
{{< highlight sh >}} {{< highlight sh >}}
find . -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n find . -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n
{{< /highlight >}} {{< /highlight >}}

View file

@ -1,13 +1,14 @@
--- ---
title: "Import commits from one git repo to another" title: "Import commits from one git repo to another"
linkTitle: "Import commits from one git repo to another"
date: 2018-09-25 date: 2018-09-25
description: > description: How to take commits from one git repo and bring them into another
Import commits from one git repo to another tags:
- git
--- ---
This imports commits from a repo in the `../masterfiles` folder and applies them to the repository inside the current folder : ## The trick
In an ideal world there should never be a need to do this, but here is how to do it properly if you ever walk into this bizarre problem. This command imports commits from a repo in the `../masterfiles` folder and applies them to the repository inside the current folder :
{{< highlight sh >}} {{< highlight sh >}}
(cd ../masterfiles/; git format-patch stdout origin/master) | git am (cd ../masterfiles/; git format-patch stdout origin/master) | git am
{{< /highlight >}} {{< /highlight >}}

View file

@ -1,13 +1,14 @@
--- ---
title: "Rewrite a git commit history" title: "Rewrite a git commit history"
linkTitle: "Rewrite a git commit history"
date: 2018-03-05 date: 2018-03-05
description: > description: How to rewrite a git commit history
Rewrite a git commit history tags:
- git
--- ---
## git filter-branch
Here is how to rewrite a git commit history, for example to remove a file : Here is how to rewrite a git commit history, for example to remove a file :
{{< highlight sh >}} {{< highlight sh >}}
git filter-branch index-filter "git rm --cached --ignore-unmatch ${file}" --prune-empty --tag-name-filter cat - -all git filter-branch index-filter "git rm --cached --ignore-unmatch ${file}" --prune-empty --tag-name-filter cat - -all
{{< /highlight >}} {{< /highlight >}}

View file

@ -1,11 +1,12 @@
--- ---
title: "ipmitool" title: "ipmitool"
linkTitle: "ipmitool"
date: 2018-03-05 date: 2018-03-05
description: > description: some ipmitool command examples
ipmitool tags:
- simple utilities
--- ---
## Usage examples
- launch ipmi shell : `ipmitool -H XX.XX.XX.XX -C3 -I lanplus -U <ipmi_user> shell` - launch ipmi shell : `ipmitool -H XX.XX.XX.XX -C3 -I lanplus -U <ipmi_user> shell`
- launch ipmi remote text console : `ipmitool -H XX.XX.XX.XX -C3 -I lanplus -U <ipmi_user> sol activate` - launch ipmi remote text console : `ipmitool -H XX.XX.XX.XX -C3 -I lanplus -U <ipmi_user> sol activate`
- Show local ipmi lan configuration : `ipmitool lan print` - Show local ipmi lan configuration : `ipmitool lan print`
@ -16,4 +17,3 @@ ipmitool lan set 1 ipaddr 10.31.149.39
ipmitool lan set 1 netmask 255.255.255.0 ipmitool lan set 1 netmask 255.255.255.0
mc reset cold mc reset cold
{{< /highlight >}} {{< /highlight >}}

View file

@ -1,9 +1,10 @@
--- ---
title: "mdadm" title: "mdadm"
linkTitle: "mdadm"
date: 2011-11-15 date: 2011-11-15
description: > description: some mdadm command examples
mdadm tags:
- linux
- simple utilities
--- ---
## Watch the array status ## Watch the array status
@ -39,4 +40,3 @@ mdadm --stop /dev/md0
mdadm --zero-superblock /dev/sda mdadm --zero-superblock /dev/sda
mdadm --zero-superblock /dev/sdb mdadm --zero-superblock /dev/sdb
{{< /highlight >}} {{< /highlight >}}

View file

@ -1,11 +1,11 @@
--- ---
title: "MegaCLI" title: "MegaCLI"
linkTitle: "MegaCLI"
date: 2018-03-05 date: 2018-03-05
description: > description: MegaCLI for dell hardware investigations
MegaCLI for dell hardware investigations tags:
- linux
--- ---
## Some command examples
- `megacli -LDInfo -LALL -aALL|grep state` - `megacli -LDInfo -LALL -aALL|grep state`
- `MegaCli -PDlist -a0|less` - `MegaCli -PDlist -a0|less`

View file

@ -1,9 +1,9 @@
--- ---
title: "omreport" title: "omreport"
linkTitle: "omreport"
date: 2018-03-05 date: 2018-03-05
description: > description: Some omreport command examples
omreport tags:
- linux
--- ---
## Your raid status at a glance ## Your raid status at a glance
@ -17,4 +17,3 @@ omreport storage vdisk
omreport storage pdisk controller=0 vdisk=0 omreport storage pdisk controller=0 vdisk=0
omreport storage pdisk controller=0 pdisk=0:0:4 omreport storage pdisk controller=0 pdisk=0:0:4
{{< /highlight >}} {{< /highlight >}}

View file

@ -1,11 +1,14 @@
--- ---
title: "qemu-nbd" title: "qemu-nbd"
linkTitle: "qemu-nbd"
date: 2019-07-01 date: 2019-07-01
description: > description: qemu-nbd usage example
qemu-nbd tags:
- linux
- virtualization
--- ---
## Usage example
{{< highlight sh >}} {{< highlight sh >}}
modprobe nbd max_part=8 modprobe nbd max_part=8
qemu-nbd -c /dev/nbd0 image.img qemu-nbd -c /dev/nbd0 image.img
@ -14,4 +17,3 @@ mount /dev/nbd0p1 /mnt # or vgscan && vgchange -ay
umount /mnt umount /mnt
qemu-nbd -d /dev/nbd0 qemu-nbd -d /dev/nbd0
{{< /highlight >}} {{< /highlight >}}

View file

@ -1,9 +1,10 @@
--- ---
title: "Qemu" title: "Qemu"
linkTitle: "Qemu"
date: 2019-06-10 date: 2019-06-10
description: > description: Some simple qemu command usage
Qemu tags:
- linux
- virtualization
--- ---
## Quickly launch a qemu vm with local qcow as hard drive ## Quickly launch a qemu vm with local qcow as hard drive

View file

@ -1,9 +1,9 @@
--- ---
title: "rrdtool" title: "rrdtool"
linkTitle: "rrdtool"
date: 2018-09-25 date: 2018-09-25
description: > description: How to graph manually with rrdtool
rrdtool tags:
- simple utilities
--- ---
## Graph manually ## Graph manually

View file

@ -1,5 +0,0 @@
---
title: "Debian"
linkTitle: "Debian"
weight: 40
---

View file

@ -1,11 +1,14 @@
--- ---
title: "Error occured during the signature verification" title: "Error occured during the signature verification"
linkTitle: "Error occured during the signature verification"
date: 2015-02-27 date: 2015-02-27
description: > description: Fixing the "Error occured during the signature verification"
Error occured during the signature verification tags:
- debian
- linux
--- ---
## How to fix
Here is how to fix the apt-get “Error occured during the signature verification” : Here is how to fix the apt-get “Error occured during the signature verification” :
{{< highlight sh >}} {{< highlight sh >}}
cd /var/lib/apt cd /var/lib/apt

View file

@ -1,11 +1,14 @@
--- ---
title: "Force package removal" title: "Force package removal"
linkTitle: "Force package removal"
date: 2015-01-27 date: 2015-01-27
description: > description: How to force the removal of a package
Force package removal tags:
- debian
- linux
--- ---
## How to force the removal of a package
Here is how to force package removal when post-uninstall script fails : Here is how to force package removal when post-uninstall script fails :
{{< highlight sh >}} {{< highlight sh >}}
dpkg --purge --force-all <package> dpkg --purge --force-all <package>

View file

@ -1,11 +1,14 @@
--- ---
title: "Fix the no public key available error" title: "Fix the no public key available error"
linkTitle: "Fix the no public key available error"
date: 2016-01-27 date: 2016-01-27
description: > description: How to fix this common debian error when using non official repositories
Fix the no public key available error tags:
- debian
- linux
--- ---
## How to fix
Here is how to fix the no public key available error : Here is how to fix the no public key available error :
{{< highlight sh >}} {{< highlight sh >}}
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEYID apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEYID

View file

@ -1,5 +0,0 @@
---
title: "Docker"
linkTitle: "Docker"
weight: 40
---

View file

@ -1,12 +1,15 @@
--- ---
title: "Cleaning a docker host" title: "Cleaning a docker host"
linkTitle: "Cleaning a docker host"
date: 2018-01-29 date: 2018-01-29
description: > description: How to retrieve storage space by cleaning a docker host
How to retrieve storage space by cleaning a docker host tags:
- docker
- linux
--- ---
Be carefull that this will delete any stopped container and remove any locally unused image and tags : ## The command
Be careful that this will delete any stopped container and remove any locally unused images, volumes and tags :
{{< highlight sh >}} {{< highlight sh >}}
docker system prune -f -a docker system prune -f -a
{{< /highlight >}} {{< /highlight >}}

View file

@ -1,14 +1,19 @@
--- ---
title: "Docker compose predictable bridge" title: "Docker compose predictable bridge"
linkTitle: "Docker compose predictable bridge"
date: 2018-09-25 date: 2018-09-25
description: > description: How to use a predefined bridge with docker compose
How to use a predefined bridge with docker compose tags:
- docker
- linux
--- ---
## The problem
By default, docker-compose will create a network with a randomly named bridge. If you are like me using a strict firewall on all your machines, this just cannot work. By default, docker-compose will create a network with a randomly named bridge. If you are like me using a strict firewall on all your machines, this just cannot work.
You need to put your services in `network_mode: “bridge”` and add a custom `network` entry like : ## The fix
For example if your bridge is named docbr1, you need to put your services in `network_mode: “bridge”` and add a custom `network` entry like :
{{< highlight yaml >}} {{< highlight yaml >}}
version: '3.0' version: '3.0'
@ -27,5 +32,5 @@ services:
networks: networks:
default: default:
external: external:
name: bridge name: docbr1
{{< /highlight >}} {{< /highlight >}}

View file

@ -1,12 +1,15 @@
--- ---
title: "Migrate a data volume" title: "Migrate a data volume"
linkTitle: "Migrate a data volume"
date: 2018-01-30 date: 2018-01-30
description: > description: How to migrate a data volume between two hosts
How to migrate a data volume tags:
- docker
- linux
--- ---
Here is how to migrate a data volume between two of your hosts. A rsync of the proper `/var/lib/docker/volumes` subfolder would work just as well, but is here a fun way to do it with docker and pipes : ## The command
Here is how to migrate a data volume between two of your hosts. A rsync of the proper `/var/lib/docker/volumes` subfolder would work just as well, but here is a fun way to do it with docker and pipes :
{{< highlight sh >}} {{< highlight sh >}}
export VOLUME=tiddlywiki export VOLUME=tiddlywiki
export DEST=10.1.0.242 export DEST=10.1.0.242

View file

@ -1,12 +1,19 @@
--- ---
title: "Shell usage in dockerfile" title: "Shell usage in dockerfile"
linkTitle: "Shell usage in dockerfile"
date: 2019-02-04 date: 2019-02-04
description: > description: How to use a proper shell in a dockerfile
How to use a proper shell in a dockerfile tags:
- docker
- linux
--- ---
The default shell is `[“/bin/sh”, “-c”]`, which doesn't handle pipe fails when chaining commands. To process errors when using pipes use this : ## The problem
The default shell is `[“/bin/sh”, “-c”]`, which doesn't handle pipe fails when chaining commands.
## The fix
To process errors when using pipes use this :
{{< highlight sh >}} {{< highlight sh >}}
SHELL ["/bin/bash", "-eux", "-o", "pipefail", "-c"] SHELL ["/bin/bash", "-eux", "-o", "pipefail", "-c"]

View file

@ -1,5 +0,0 @@
---
title: "FreeBSD"
linkTitle: "FreeBSD"
weight: 40
---

View file

@ -1,5 +0,0 @@
---
title: "Gentoo"
linkTitle: "Gentoo"
weight: 40
---

View file

@ -1,5 +0,0 @@
---
title: "Kubernetes"
linkTitle: "Kubernetes"
weight: 40
---

View file

@ -1,5 +0,0 @@
---
title: "Miscellaneous"
linkTitle: "Miscellaneous"
weight: 40
---

View file

@ -1,5 +0,0 @@
---
title: "Netapp"
linkTitle: "Netapp"
weight: 30
---

View file

@ -1,5 +0,0 @@
---
title: "Travels"
linkTitle: "Travels"
weight: 20
---