blog
Table des matières
- 2026:
- 2025:
1 billet(s) pour avril 2026
| Notes ping ICMP | 2026/04/03 23:01 | Jean-Baptiste |
Ansible - exemples
- name: install truc import_tasks: "1-install-truc.yml" - name: conf truc import_tasks: "2-conf-truc.yml" - name: install plop import_tasks: "3-install-plop.yml"
Équivalent try except finally
- name: Attempt and graceful roll back demo block: - name: Print a message ansible.builtin.debug: msg: 'I execute normally' - name: Force a failure ansible.builtin.command: /bin/false - name: Never print this ansible.builtin.debug: msg: 'I never execute, due to the above task failing, :-(' rescue: - name: Print when errors ansible.builtin.debug: msg: 'I caught an error' - name: Force a failure in middle of recovery! >:-) ansible.builtin.command: /bin/false - name: Never print this ansible.builtin.debug: msg: 'I also never execute :-(' always: - name: Always do this ansible.builtin.debug: msg: "This always executes"
Plugin lookup
- name: raw result of running date command" debug: msg: "{{ lookup('pipe', 'date') }} - name: create a mysql user with a random password using many different char sets mysql_user: name: "{{ client }}" password" "{{ lookup('password', '/tmp/passwordfile chars=ascii_letters,digits,hexdigits,punctuation') }}" priv: "{{ client }}_{{ tier }}_{{ role }}.*:ALL"
Exemple config projet
.ansible-lint
--- skip_list: - '303' # Using command rather than module for yum/dnf - ignore-errors
.yamllint.yml
# SPDX-License-Identifier: MIT --- extends: .yamllint_defaults.yml # possible customizations over the base yamllint config # skip the yaml files in the /tests/ directory # NOTE: If you want to customize `ignore` you'll have to # copy in all of the config from .yamllint.yml, then # add your own - so if you want to just add /tests/ to # be ignored, you'll have to add the ignores from the base # ignore: | # /tests/ # /.tox/ # skip checking line length # NOTE: the above does not apply to `rules` - you do not # have to copy all of the rules from the base config
.yamllint_defaults.yml
# SPDX-License-Identifier: MIT --- ignore: | /.tox/ extends: default rules: braces: max-spaces-inside: 1 level: error brackets: max-spaces-inside: 1 level: error truthy: allowed-values: ["yes", "no", "true", "false"] level: error document-start: disable colons: disable
.yamllint
extends: default rules: colons: max-spaces-before: 1 max-spaces-after: 20 line-length: disable
ansible.cfg
[defaults] roles_path = ../
# To generate an example config file (a "disabled" one with all default settings, commented out): ansible-config init --disabled > ansible.cfg # Also you can now have a more complete file by including existing plugins: ansible-config init --disabled -t all > ansible.cfg # Voir la configuration : ansible-config dump --only-changed -t all
Voir ansible-navigator config
.gitignore
*.retry /.vagrant *.swp
DNS script check bind9
check-bind.sh
#! /bin/bash declare -i RET RET=0 rndc reload systemctl restart named.service systemctl status named.service RET=$((RET + $?)) IP_DNS=$(dig @127.0.0.1 plop.acme.local +short) if [ -z "$IP_DNS" ] then RET=$((RET + 1 )) fi FQDN_DNS=$(dig @127.0.0.1 -x "$IP_DNS" +short) if [ -z "$FQDN_DNS" ] then RET=$((RET + 1 )) fi named-checkconf RET=$((RET + $?)) for ZONE in $(awk '/^zone/ { gsub("\"", "") ; print $2 }' /etc/named.conf) do named-checkzone "$ZONE" "/etc/named/db.${ZONE}" RET=$((RET + $?)) dig -t AXFR @127.0.0.1 "$ZONE" |grep -v "^;;" RET=$((RET + $?)) rndc freeze acme.local rndc reload acme.local RET=$((RET + $?)) rndc thaw acme.local done rndc status RET=$((RET + $?)) echo if [ $RET == 0 ] then echo "*** ALL IS OK ***" else echo "** ERROR ***" fi echo exit $RET
Disque cache flush sync io purge
Source :
drop_caches.sh
echo 3 |sudo tee /proc/sys/vm/drop_caches
#!/bin/bash sync echo 3 >/proc/sys/vm/drop_caches swapoff -a && swapon -a
# (move data, modified through FS -> HDD cache) + flush HDD cache sync # (slab + pagecache) -> HDD (https://www.kernel.org/doc/Documentation/sysctl/vm.txt) echo 3 > /proc/sys/vm/drop_caches blockdev --flushbufs /dev/sda hdparm -F /dev/sda # Command that should be run before unplug, flushes everything guaranteed echo 1 > /sys/block/sdX/device/delete
watch the progress of a `sync` operation Source : http://unix.stackexchange.com/questions/48235/can-i-watch-the-progress-of-a-sync-operation
watch grep -e Dirty: -e Writeback: /proc/meminfo awk '{print $9}' /sys/block/sda/stat
Display manager
Quel est mon Display Manager ?
| Debian | /etc/X11/default-display-manager |
|---|---|
| RedHat | /etc/sysconfig/desktop |
| OpenSuSe | /etc/sysconfig/displaymanager |
| Debian | /etc/X11/default-display-manager |
cat /etc/X11/default-display-manager
systemctl status display-manager
pstree -alps $$
sddm
autologon
mkdir /etc/sddm.conf.d
# ls /usr/share/xsessions/ lxqt.desktop
/etc/sddm.conf.d/autologin.conf
[Autologin] User=jean Session=lxqt.desktop Relogin=
Diagramme sous GNU/Linux
Voir :
- Diagrams.net (Aka Draw.IO)
- draw io desktop
- PenPlot (SVG) - UX - alternative à Figma et Sketch.
Logos libres en SVG :
Voir aussi :
- Diagramme en Code avec PlantUML
http://www.softia-systems.net/contribs/dia_split_svg.py
# # Script realise par THOMAS DUBOIS pour SOFTIA SYSTEMS # BSD LICENCE # Merci d'envoyer un mail a tdubois@softia-systems.net # si vous utilisez, transmettez, ou reactualiser le script # (juste pour un suivi du travail :)) # Finalise le 28/08/2007 # # Ce script ne prends pas d'argument. # Il creera dans le repertoire courant un repertoire svg, et shape # Le repertoire svg contiendra les .svg de chaque objet # Le repertoire shape contiendra les .shape correspondant au SVG ainsi # qu'un PNG pour la preview # Un fichier Yourshape.sheet sera creer. # Le fichier .sheet doit etre modifier afin de changer # le nom de la feuille apparaissant dans dia # Le fichier shape est a copier dans votre ~/.dia/shape/Votreshape # Le fichier Yourshape.sheet est a copier dans le repertoire ~/dia/sheets/ # sous le nom Votreshape.sheet # Debut du script from xml.dom import minidom # Fichier SVG d'entree a parser xmldoc = minidom.parse('/path/to/file.svg') # probleme de locale, pas trouve d'autre solution .... # si quelqu'un a qqchose a proposer import locale, sys reload(sys) loc = locale.getdefaultlocale() if loc[1]: encoding = loc[1] # une version Non-Unicode retournera AttributeError... if encoding: sys.setdefaultencoding(encoding) import os import re import popen2 # recuperation des groups d'element, ici les objets reflist = xmldoc.getElementsByTagName('g') shapehead = """<?xml version="1.0"?> <shape xmlns="http://www.daa.com.au/~james/dia-shape-ns" xmlns:svg="http://www.w3.org/2000/svg"> """ shapetail = """ </svg:svg> </shape>""" svghead = """<?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg xmlns="http://www.w3.org/2000/svg"> """ svgtail = "\n</svg>" # Creation du fichier sheet sheetfile = open("YourSheet.sheet", "w") sheetfile.write("""<?xml version="1.0" encoding="iso-8859-1"?> <sheet xmlns="http://www.lysator.liu.se/~alla/dia/dia-sheet-ns"> <name>Sample</name> <description>A collection of sample shapes.</description> <contents> """) # Creation de repertoires pour stocker les fichiers os.mkdir("svg") os.mkdir("shape") i = 0 for block in reflist: #ouverture du fichier svg de l'objet courant et ecriture des entetes svgfile = open("svg/" + str(i) + ".svg", 'w') svgfile.write(svghead) svgfile.write("<desc>%i</desc>\n"%(i)) shapefile = open("shape/" + str(i) + ".shape", 'w') shapefile.write(shapehead) shapefile.write("<name>%s</name>\n"%(i)) shapefile.write("<icon>%s.png</icon>\n<svg:svg>\n"%(i)) # Regexp pour enlever nombre de classes qui sont incompatible avec dia p = re.compile('sodipodi:[a-z0-9\-]+=".*?\"') chaine = p.sub('', block.toxml()) svgfile.write(chaine) chaine = chaine.replace("<a:","") chaine = chaine.replace("<","<svg:") chaine = chaine.replace("<svg:/","</svg:") p = re.compile('i:[a-z\-]+=".*?\"') chaine = p.sub('', chaine) p = re.compile('inkscape:[a-z\-]+=".*?\"') chaine = p.sub('', chaine) shapefile.write(chaine) shapefile.write(shapetail) shapefile.close() sheetfile.write("<object name=\"%s\">\n"%(i)) sheetfile.write("<description>%s</description>\n"%(i)) sheetfile.write("</object>\n") # conversion des .svg de chaque objet svg en png popen2.popen3("/usr/bin/inkscape svg/%s.svg -e shape/%s.png -d 90 -z -D"%(i,i)) shapefile.close() svgfile.write(svgtail) svgfile.close() i += 1 sheetfile.write("""</contents> </sheet>""") sheetfile.close()
blog.txt · Dernière modification : de 127.0.0.1
