Table des matières
- 2026:
- 2025:
4 billet(s) pour septembre 2026
| Notes HTTP Strict Transport Security - HSTS | 2026/09/18 11:04 | Jean-Baptiste |
| Notes GNU Linux GPU carte graphiques | 2026/09/08 15:49 | Jean-Baptiste |
| Notes GNU Linux graphique | 2026/09/08 15:42 | Jean-Baptiste |
| Notes urlencoding - passer des mots de passe en HTTPS | 2026/09/03 17:58 | Jean-Baptiste |
Script shell commande timeout
Voir aussi :
A titre d'exemple. Idéalement il faut gérer le timeout avec Ansible
Exemple de code Ansible
- name: command ldap_search become: true ansible.builtin.command: | /usr/bin/timeout --kill-after=15 10 /usr/bin/ldapsearch -LLL -D cn={{ lookup('env', 'LDAP_USER') }} -b o=unixauth -y /root/.ansible/tmp-files/.ldap.txt uid={{ CDO_ACCOUNT_USER | quote }} dn changed_when: false check_mode: false register: ldapsearch environment: LANG: C failed_when: - ldapsearch.rc != 0 # OK - ldapsearch.rc != 124 # Timeout. SIGTERM - ldapsearch.rc != 137 # Timeout. SIGKILL - name: fail when timeout - SIGTERM fail: msg: "Error_Command_Timeout. Process arrêté par SIGTERM." when: ldapsearch.rc == 124 - name: fail when timeout - SIGKILL fail: msg: "Error_Command_Timeout. Process arrêté par SIGKILL." when: ldapsearch.rc == 137 - name: fail if ACME user fail: msg: | Error_ElementAlreadyUsed. Nom de compte utilisateur déjà utilisé par ACME {{ CDO_ACCOUNT_USER }}. when: - ldapsearch.stdout_lines | select('regex', '^dn:') | list is regex(',o=unixauth') - not allow_ldap_acme
Concernant Ansible voir aussi https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_async.html
async pool timeout
play1.yml
#!/usr/bin/ansible-playbook --- - name: test hosts: localhost gather_facts: false # TIMEOUT_MAX = async # when poll != 0 # TIMEOUT_MAX = retries x delay # when poll == 0 tasks: - name: Command shell: | sleep 5 date >> /tmp/date.log poll: 0 # When pool is a positive value, the playbook will still block on the task until it either completes, fails or timeout async: 2 # if poll != 0 : fail when task is longer than async value register: cmd_sleep - name: DEBUG 10 debug: msg: "Command en cours d'execution" - name: Async_status async_status: jid: "{{ cmd_sleep.ansible_job_id }}" register: job_result until: job_result.finished retries: 3 # MAX TIMEOUT VAR delay: 2 # MAX TIMEOUT VAR - name: DEBUG 20 debug: msg: "Execution terminée"
Cobbler déploiement Ubuntu ou Debian
Voir :
Notes : Nous n'utiliserons pas debmirror \
Contexte : Nous sommmes sur une CentOS7 (Serveur Cobbler) et nous allons déployer une Ubuntu Server 16.04
Mise-à-jour de la liste des signatures (--os-version)
cobbler signature update
Import de l'ISO montée sur /mnt
mount ubuntu-16.04-server-amd64.iso /mnt cobbler import --name=ubuntu-server --path=/mnt --breed=ubuntu --os-version=xenial --arch=x86_64 umount /mnt
Copie du profile original
cobbler profile copy --name=ubuntu-server-x86_64 --newname=ubuntu-server-16.04.vm
Modif du nouveau profile
cobbler profile edit --name=ubuntu-server-16.04.vm --proxy=http://192.168.100.3:8080/ --virt-path=/var/lib/libvirt/images
Modif du nouveau profile (pour visrsh console et autre)
cobbler profile edit --name=ubuntu-server-16.04.vm --kopts-post="console=ttyS0,115200n8 ipv6.disable=1 vga=0x317" --kopts="console=ttyS0,115200n8 ipv6.disable=1"
vga=0x317 est déprécié, utiliser à la place : gfxpayload=1024x768x16,1024x768
Copie de la “distro” d'origine, car nous allons la modifier
cobbler distro copy --name ubuntu-server-x86_64 --newname=ubuntu-server-x86_64-orig
Modification du Kickstart Metadata de la distro ubuntu-server-x86_64 \ Nous changeons la ligne suivante :
tree=http://@@http_server@@/cblr/links/ubuntu-server-x86_64 \ en \ tree=http://fr.archive.ubuntu.com/ubuntu/dists/xenial/main/installer-amd64
cobbler distro edit --name=ubuntu-server-x86_64 --ksmeta='tree=http://fr.archive.ubuntu.com/ubuntu/dists/xenial/main/installer-amd64'
Copie du fichier d'exemple preseed (sample.seed) Nous modifierons la copie de la manière suivante :
/var/lib/cobbler/kickstarts/ubuntu-server-16.04.seed
d-i mirror/http/hostname string fr.archive.ubuntu.com d-i mirror/http/directory string /ubuntu
cp -p /var/lib/cobbler/kickstarts/sample.seed /var/lib/cobbler/kickstarts/ubuntu-server-16.04.seed sed -i -e 's%^\(d-i mirror/http/hostname string\).*%\1 fr.archive.ubuntu.com%' /var/lib/cobbler/kickstarts/ubuntu-server-16.04.seed sed -i -e 's%^\(d-i mirror/http/directory string\).*%\1 /ubuntu%' /var/lib/cobbler/kickstarts/ubuntu-server-16.04.seed
A faire aussi
cp -p /var/lib/cobbler/scripts/preseed_late_default /var/lib/cobbler/scripts/preseed_late_ubuntu-server-16.04 sed -i -e 's/preseed_late_default/preseed_late_ubuntu-server-16.04/' /var/lib/cobbler/kickstarts/ubuntu-server-16.04.seed
On modifie le script de postinstall
/var/lib/cobbler/kickstarts/ubuntu-server-16.04.seed
echo "$hostname" > /etc/hostname /bin/hostname $hostname $SNIPPET('download_config_files') $SNIPPET('kickstart_done')
Lier le nouveau fichier kickstart/preseed au profile
cobbler profile edit --name=ubuntu-server-16.04.vm --kickstart=/var/lib/cobbler/kickstarts/ubuntu-server-16.04.seed
Puis
cobbler sync
L'adresse MAC un un chiffre hexadécimal écrit sous la forme '52:54:XX:XX:XX:XX' (où X est un chiffre en base 16 entre 0 et F)
cobbler system add --name=${HostName} \ --gateway=${Gateway} \ --hostname=${HostName} \ --ipv6-autoconfiguration=false \ --power-type=ack_manual \ --profile=ubuntu-server-16.04.vm \ --repos-enabled=false \ --status=production \ --virt-auto-boot=0 \ --virt-type=kvm cobbler system edit --name=${HostName} \ --interface=ens3 \ --ip-address=${IP_Addr} \ --mac=$Mac \ --netmask=${NetMask} \ --static=1
Retour arrière
Effacement de la nouvelle distro
Exemple à adapter
cobbler system remove --name=ttest01 cobbler profile remove --name=ubuntu-server-16.04.vm cobbler profile remove --name=ubuntu-server-x86_64 cobbler distro remove --name=ubuntu-server-x86_64 cobbler repo remove --name=ubuntu-server-x86_64
Cobbler déploiement Debian
Debian
mount /home/debian-8.7.1-amd64-DVD-1.iso /mnt/iso cobbler import --name=debian --path=/mnt/iso --breed=debian --os-version=jessie --arch=x86_64 cobbler sync cobbler profile copy --name=debian-x86_64 --newname=debian-x86_64_custom cobbler profile edit --name debian-x86_64_custom --virt-type=kvm --virt-bridge=virbr0 \ --kopts="debian-installer/allow_unauthenticated=true console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 ipv6.disable=1 vga=0x317" \ --kopts-post="console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 ipv6.disable=1 vga=0x317" \ --virt-file-size=30 --virt-ram=2048 cobbler system add --profile=debian-x86_64_custom --name=debtest1 --mac=52:54:00:DD:EE:FF --interface=eth0 --virt-type=kvm #--virt-file-size=30 --virt-ram=2048 cd wget http://ftp.fr.debian.org/debian/dists/jessie/main/installer-amd64/current/images/netboot/netboot.tar.gz cd /var/www/cobbler/links/debian-x86_64/install/ mkdir netboot cd netbook tar xvf ~/netboot.tar.gz
/var/www/cobbler/links/debian-x86_64/.treeinfo
[general] family = Debian timestamp = 1272326522.13 totaldiscs = 1 version = 8 discnum = 1 packagedir = dists arch = x86_64 [images-x86_64] kernel = install/netboot/debian-installer/amd64/linux initrd = install/netboot/debian-installer/amd64/initrd.gz
cobbler repo copy --name=debian-x86_64 --newname=debian-x86_64_custom cobbler repo edit --name=debian-x86_64_custom --mirror=http://192.168.21.1/debian8/dists/jessie
KVM
export COBBLER_SERVER=192.168.21.3 LANG=C koan --virt --wait=-1 --system=debtest1 --server=192.168.21.3
Clean
cobbler system remove --name debtest1 cobbler profile remove --name debian-x86_64_custom cobbler profile remove --name debian-x86_64 cobbler profile remove --name debian-gtk-x86_64 cobbler distro remove --name debian-x86_64_custom cobbler distro remove --name debian-x86_64 cobbler distro remove --name debian-gtk-x86_64 cobbler repo remove --name debian-x86_64_custom cobbler repo remove --name debian-x86_64 cobbler repo remove --name debian-gtk-x86_64
CMS PHP Wordpress
Source : https://codex.wordpress.org/Debugging_in_WordPress
Debug Wordpress
wp-config.php
// Enable WP_DEBUG mode define( 'WP_DEBUG', true ); // Enable Debug logging to the /wp-content/debug.log file define( 'WP_DEBUG_LOG', true ); // Disable display of errors and warnings define( 'WP_DEBUG_DISPLAY', false ); @ini_set( 'display_errors', 0 ); // Use dev versions of core JS and CSS files (only needed if you are modifying these core files) define( 'SCRIPT_DEBUG', true );
Sécurité
Scan
sudo apt-get install ruby-rubygems ruby-dev export PATH="$PATH":/home/jibe/.local/share/gem/ruby/3.0.0/bin gem install --user-install wpscan wpscan --url https://wp.acme.fr -o wpscan_wp.acme.fr.txt
Doublon avec scriptinitsysvroot
Script init Wrapper
Lancement du serveur BCM sous un compte utilisateur (non-root) sous Debian.
1) Création d’un nouvel utilisateur dédie au serveur BCM.
Dans notre exemple il s’agit de « bcm »
TODO Commande de création utilisateur système
2) Création du script /etc/init.d/BMC
/etc/init.d/BMC
#! /bin/bash # chkconfig: 35 85 15 # description: Startup script for BMC Client Management agent ### BEGIN INIT INFO # Provides: BMC # Required-Start: $network $local_fs $remote_fs $time $syslog # Required-Stop: $network $local_fs $remote_fs $time $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Wrapper pour lancer les scripts sysVinit avec un compte utilisateur (non root) # Description: Wrapper pour lancer les scripts sysVinit avec un compte utilisateur (non root) ### END INIT INFO BCM_USER=bcm BCM_INITSCRIPT=/etc/init.d/BMCClientManagementAgent su - $BCM_USER -c "$BCM_INITSCRIPT" "$@"
Note : Les commentaires du scripts sont nécessaire. Voir
3) Gestion des services
Placer les droits d’exec :
chmod +x /etc/init.d/BMC
Désactivation du démarrage de l’ancien script.
update-rc.d BMCClientManagementAgent remove
Activation du nouveau script
update-rc.d BMC defaults
On vérifie :
find /etc/rc* -iname "*bmc*"
4) Fin
Arrêt process lancé en root /etc/init.d/BMCClientManagementAgent stop
Ici l’utilisateur « bcm » devient le nouveau propriétaires des fichiers
chown bcm: /opt/bcm/ -R
On démarre BCM
/etc/init.d/BCM start
En cas de Pb
Refaire point 3 et 4. Idem si application patch.
NB : il convient dans la supervision de s’assurer que le process tourne sous le bon compte. Exemple :
pgrep -u bcm mtxagent && echo OK || echo NOK
