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"
linkTitle: "Ansible vault example"
date: 2018-02-21
description: >
Ansible vault example
description: Getting started with ansible vault
tags:
- ansible
---
## Editing a protected file
Here is how to edit a vault protected file :
{{< highlight sh >}}
ansible-vault edit hostvars/blah.yml
{{< / 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 >}}
ssl_key : |
@ -21,13 +35,7 @@ ssl_key : |
----- END PRIVATE KEY -----
{{< /highlight >}}
And here is how to use it in a task :
{{< highlight yaml >}}
- copy:
path: /etc/ssl/private.key
mode: 0400
content: '{{ ssl_key }}'
{{< / highlight >}}
## How to run playbooks when vault values are needed
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"
linkTitle: "Ansible custom facts"
date: 2018-09-25
description: >
How to write custom facte with ansible
description: How to write custom facts with ansible
tags:
- ansible
---
## Introduction
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
`/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.
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 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 :
{{< highlight sh >}}

View file

@ -1,11 +1,13 @@
---
title: "Dump all ansible variables"
linkTitle: "Dump all ansible variables"
date: 2019-10-15
description: >
How to dump all variables used by ansible
description: How to dump all variables used by ansible in a task
tags:
- ansible
---
## Task to use
Here is the task to use in order to achieve that :
{{< 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
{{< /highlight >}}
## Associated template
And here is the template to use with it :
{{< highlight jinja >}}
@ -36,3 +40,7 @@ HOST Variables ("hostvars"):
--------------------------------
{{ hostvars | to_nice_json }}
{{< /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"
linkTitle: "Leveraging yaml with cfengine"
date: 2018-09-25
description: >
How to leverage yaml inventory files with cfengine
description: 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
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"
linkTitle: "List active calls on asterisk"
date: 2018-09-25
description: >
How to show active calls on an asterisk system
description: How to show active calls on an asterisk system
tags:
- asterisk
---
## Using the cli
{{< highlight yaml >}}
watch -d -n1 'asterisk -rx “core show channels”'
{{< /highlight >}}

View file

@ -1,11 +1,13 @@
---
title: "How to have asterisk call you into a meeting"
linkTitle: "How to have asterisk call you into a meeting"
date: 2018-09-25
description: >
How to have asterisk call you itself into a meeting
description: 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
and place me inside the room :

View file

@ -1,12 +1,15 @@
---
title: "Busybox web server"
linkTitle: "Busybox web server"
date: 2019-04-16
description: >
Busybox web server
description: How to serve static files from only busybox
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 >}}
busybox httpd -vfp 80

View file

@ -1,12 +1,14 @@
---
title: "Capture a video of your desktop"
linkTitle: "Capture a video of your desktop"
date: 2011-11-20
description: >
Capture a video of your desktop
description: 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 >}}
ffmpeg -f x11grab -s xga -r 25 -i :0.0 -sameq /tmp/out.mpg

View file

@ -1,12 +1,14 @@
---
title: "Clean conntrack states"
linkTitle: "Clean conntrack states"
date: 2018-03-02
description: >
Clean conntrack states
description: How to 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 >}}
conntrack -L conntrack -p tcp orig-dport 65372 | \

View file

@ -1,12 +1,14 @@
---
title: "Convert unix timestamp to readable date"
linkTitle: "Convert unix timestamp to readable date"
date: 2011-01-06
description: >
Convert unix timestamp to readable date
description: the -d flag of the date command combined with @timestamp
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 >}}
$ date -d @1294319676

View file

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

View file

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

View file

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

View file

@ -1,13 +1,14 @@
---
title: "Import commits from one git repo to another"
linkTitle: "Import commits from one git repo to another"
date: 2018-09-25
description: >
Import commits from one git repo to another
description: How to take commits from one git repo and bring them into 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 >}}
(cd ../masterfiles/; git format-patch stdout origin/master) | git am
{{< /highlight >}}

View file

@ -1,13 +1,14 @@
---
title: "Rewrite a git commit history"
linkTitle: "Rewrite a git commit history"
date: 2018-03-05
description: >
Rewrite a git commit history
description: How to 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 :
{{< highlight sh >}}
git filter-branch index-filter "git rm --cached --ignore-unmatch ${file}" --prune-empty --tag-name-filter cat - -all
{{< /highlight >}}

View file

@ -1,11 +1,12 @@
---
title: "ipmitool"
linkTitle: "ipmitool"
date: 2018-03-05
description: >
ipmitool
description: some ipmitool command examples
tags:
- simple utilities
---
## Usage examples
- 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`
- 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
mc reset cold
{{< /highlight >}}

View file

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

View file

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

View file

@ -1,9 +1,9 @@
---
title: "omreport"
linkTitle: "omreport"
date: 2018-03-05
description: >
omreport
description: Some omreport command examples
tags:
- linux
---
## 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 pdisk=0:0:4
{{< /highlight >}}

View file

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

View file

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

View file

@ -1,9 +1,9 @@
---
title: "rrdtool"
linkTitle: "rrdtool"
date: 2018-09-25
description: >
rrdtool
description: How to graph manually with rrdtool
tags:
- simple utilities
---
## 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"
linkTitle: "Error occured during the signature verification"
date: 2015-02-27
description: >
Error occured during the signature verification
description: Fixing the "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” :
{{< highlight sh >}}
cd /var/lib/apt

View file

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

View file

@ -1,11 +1,14 @@
---
title: "Fix the no public key available error"
linkTitle: "Fix the no public key available error"
date: 2016-01-27
description: >
Fix the no public key available error
description: How to fix this common debian error when using non official repositories
tags:
- debian
- linux
---
## How to fix
Here is how to fix the no public key available error :
{{< highlight sh >}}
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"
linkTitle: "Cleaning a docker host"
date: 2018-01-29
description: >
How to retrieve storage space by cleaning a docker host
description: 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 >}}
docker system prune -f -a
{{< /highlight >}}

View file

@ -1,14 +1,19 @@
---
title: "Docker compose predictable bridge"
linkTitle: "Docker compose predictable bridge"
date: 2018-09-25
description: >
How to use a predefined bridge with docker compose
description: 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.
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 >}}
version: '3.0'
@ -27,5 +32,5 @@ services:
networks:
default:
external:
name: bridge
name: docbr1
{{< /highlight >}}

View file

@ -1,12 +1,15 @@
---
title: "Migrate a data volume"
linkTitle: "Migrate a data volume"
date: 2018-01-30
description: >
How to migrate a data volume
description: How to migrate a data volume between two hosts
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 >}}
export VOLUME=tiddlywiki
export DEST=10.1.0.242

View file

@ -1,12 +1,19 @@
---
title: "Shell usage in dockerfile"
linkTitle: "Shell usage in dockerfile"
date: 2019-02-04
description: >
How to use a proper shell in a dockerfile
description: 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 >}}
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
---