Outils pour utilisateurs

Outils du site


blog

Ansible collection

Voir :

Dépendances :

Exemple

/data/ansible/collections/ansible_collections/acme_it/test

.ansible.cfg

collections_path = /data/ansible/collections, $HOME/.ansible/collections, /usr/share/ansible/collections

Voir aussi la variable d’environnement ANSIBLE_COLLECTIONS_PATHS

collections/requirements.yml

---

collections:
  - name: https://git.acme.local/ansible_collections/my_collection
    # type: git
    scm: git
    version: master
ansible-galaxy collection install -r collections/requirements.yml -p /home/ansible/.ansible/collections/
    - name: Install collections
      community.general.ansible_galaxy_install:
        type: collection
        requirements_file: collections/requirements.yml
        dest: ~/.ansible/collections/
      changed_when: false

Généralités

Les collections les plus utilisées

  • ansible.builtin
  • community.general
  • ansible.posix

Dépôts distants :

Collection path

$ ansible --version | grep collection
  ansible collection location = /home/ansible/.ansible/collections:/usr/share/ansible/collections

$ ansible-config dump | grep -i collection

$ ansible-config init --disabled  | grep -i collection | grep -v ^#

Lister les collections installées

ansible-galaxy collection list

Rechercher une collection distante

ansible-galaxy search plop

Utiliser une collection distante

collections/requirements.yml

---
collections:
  - name: https://acme.fr/plop/acme-plop.tar.gz
    version: X.Y.Z

  - name: git+https://git.acme.local/acme/plop.git#ansible_collections/acme/plop
    version: master

Rapatrier les collections distantes en local

ansible-galaxy collection install -r collections/requirements.yml

play.yml

#!/usr/bin/env ansible-playbook
---
- name: exemple
  hosts: localhost
  collections:
    - acme.plop

  roles:
    - install_plop

Ou

git clone ssh://git@git.acme.fr/plop/plop.git
 
cd plop/
mkdir ~/.ansible/
cp -a collection/ ~/.ansible/
 
ls -l ~/.ansible/collections/ansible_collections/awx
 
ansible-doc acme.awx.tower_credential
Exemple de role distant sur Git

roles/requirements.yml

---

- src: ssh://git@git.acme.local:2222/ansible/ansible-role-test_jb.git
  scm: git
  version: master
Exemple de collection distante sur Git

collections/requirements.yml

---    

collections:
  - name: https://git.acme.fr/ansible-automation-platform/PlaybooksGroupe/dns_cache_enable
    # type: git
    scm: git

git.acme.fr/ansible-automation-platform/PlaybooksGroupe/dns_cache_enable

dns_cache_enable/

  • roles/
  • galaxy.yml

galaxy.yml

---

namespace: acme
name: dns
version: 1.0.0
license: BSD
readme: README.md
authors:
  - Jean <jean@acme.fr>

description: DNS client collection

tasks/main.yml

- name: Enable local cache DNS
  include_role:
    name: acme.dns.enable_local_cache_dns

Utiliser une collection locale

Chemin possible

  • ~/.ansible/collections/ansible_collections/acme/plop/
  • collections/ansible_collections/acme/plop/

Composition d'une collection

Exemple d'arborescence :

  • COPYING
  • FILES.json
  • images/
  • MANIFEST.json
  • meta/
  • plugins/
  • README.md
  • requirements.txt
  • setup.cfg
  • test/
  • TESTING.md
  • tests/
  • tools/

Autres

git clone ssh://git@git.acme.fr/plop/projet1.git
 
cd projet1/
mkdir ~/.ansible/
cp -a collection/ ~/.ansible/
 
ln -s ~/.ansible/collections/ansible_collections/acme ~/.ansible/collections/ansible_collections/awx
 
ansible-doc acme.awx.tower_credential
2025/03/24 15:06

AAP Ansible Automation Platform - Credentials - exports - decrypt

Voir :

Voir aussi :

L'algo de chiffrement est aes-cbc Le secret principal est présent dans /etc/tower/SECRET_KEY, mais une clef dérivée est systématiquement utilisée.

Lors de l'export d'un Credential, le secret (mot de passe, clef privée..) n'est pas exportée pour des raisons de sécurité.

Voici comment le récupérer

sudo -u awx -i
 
#awx-manage shell_plus --ipython
awx-manage shell_plus
from awx.main.utils import decrypt_field
cred = Credential.objects.get(name="Nom_Credential")
 
# Avoir la liste des champs (ex: password)
cred.inputs
 
# Avoir le mdp déchiffré
#print(decrypt_field(cred, "password"))
cred.get_input('password')

Notes Credentials et base de données

psql -t -A -h pg1.db.acme.local -U user1 -d twrdb -p 5454
SELECT inputs FROM main_credential WHERE name = 'Nom_Credential';"
{"password": "$encrypted$UTF8$AESCBC$Z0FBQUFZQmtRT2t6Y3IwMl9yZXk3SUEwemdCVGxQZUZvZDQwbEw0MUgyYjdwd0JkdDlRUHZDUldnWVNTVjFuZ0ZfdGhxTWZndEJ2M050ZFpVdFFpVnVmaDF1dTViVHJCNVV3dkFYMU5abVVKeEZLRXlHVkUtUW89", "username": "user1@acme.local"}

La DB contient un champ nommé inputs dont le contenu est du JSON. A l’intérieur du JSON, nous avons un champs password dans notre exemple et un champ username A l’intérieur du champs password nous avons plusieurs champs séparé par le caractère $


Références

13.1.3. Secret handling for automation use

Ansible Tower stores a variety of secrets in the database that are either used for automation or are a result of automation. These secrets include: all secret fields of all credential types (passwords, secret keys, authentication tokens, secret cloud credentials) secret tokens and passwords for external services defined in Ansible Tower settings “password” type survey fields entries

To encrypt secret fields, Tower uses AES in CBC mode with a 256-bit key for encryption, PKCS7 padding, and HMAC using SHA256 for authentication. The encryption/decryption process derives the AES-256 bit encryption key from the SECRET_KEY (described above), the field name of the model field and the database assigned auto-incremented record ID. Thus, if any attribute used in the key generation process changes, Tower fails to correctly decrypt the secret. Ansible Tower is designed such that the SECRET_KEY is never readable in playbooks Ansible Tower launches, that these secrets are never readable by Tower users, and no secret field values are ever made available via the Ansible Tower REST API. If a secret value is used in a playbook, we recommend using no_log on the task so that it is not accidentally logged.

https://docs.ansible.com/ansible-tower/latest/html/administration/secret_handling.html

Data is encrypted before it is saved to the database and is decrypted as is needed in Tower. The encryption/decryption process derives the AES-256 bit encryption key from <SECRET_KEY, field_name, primary_key> where field_name is the name of the Model field and primary_key is the database assigned auto-incremented record ID. Thus, if any attribute used in the key generation process changes, Tower fails to correctly decrypt the secret.

https://docs.ansible.com/ansible-tower/3.5.3/html/userguide/credentials.html

Added a command to generate a new SECRET_KEY and rekey the database

https://docs.ansible.com/ansible-tower/3.6.2/html/installandreference/release_notes.html

Autres

openssl enc -aes-256-cbc -pbkdf2 -pass pass:MYPASSWORD -p -in foo_clear -out foo_enc
2025/03/24 15:06

Fan de la console

Console Linux Text-Based

FB FrameBuffer http://blog.rom1v.com/2012/04/lire-des-images-et-des-videos-sans-serveur-x-dans-un-tty/

http://doc.ubuntu-fr.org/liste_des_applications_console

Voir :

  • tmux / GNU screen
  • mutt
  • Poezio
  • IPython / Jupyter
  • lftp
  • se_passer_de_flash youtube-dl / yt-dlp, cclive
  • Kpcli (KeepassX)
  • fbi (Frame Buffer)
  • Play (Sound, mp3, flac etc…)
  • taskwarrior / tasksh
  • Abook
  • alsamixer
  • Aptitude
  • mplayer
  • nnn
  • feh
  • bat ( remplace cat )
  • exa ( remplace ls )
  • ncdu ( Visualiser facilement la taille des dossiers en console )
  • fzf (command-line fuzzy finder) ; alternative à locate et find

Web :

  • w3m
  • retawq
  • lynx
  • links
  • links2
  • elinks
  • edbrowse
  • aview

Voir aussi :

  • surfraw

Ecran de connexion login - Display Linux system Information In Terminal :

  • screenFetch
  • neofetch
  • neowofetch
  • linuxlogo
  • archey

Terminals :

Geo

Lock

Voir vlock verrouillage_de_session_gnu_linux

Remplacé par physlock

sudo aptitude install vlock cmatrix
cmatrix -s && vlock -san

fzf

#export FZF_DEFAULT_OPTS="--preview 'bat --color=always {}'"
export FZF_DEFAULT_OPTS="--preview 'batcat --color=always {}'"
 
#export FZF_DEFAULT_COMMAND="fd --type f"
export FZF_DEFAULT_COMMAND="fdfind --type f"
2025/03/24 15:06

Faire une pause toutes les x heures pour éviter les tendinites et la fatigues des yeux

Voir également : workrave

Un peu d'ergonomie !

Je cherchais à avoir une alerte toutes les 2 heures, pour faire une pause, me rappeler de sortir et regarder loin pour préserver un peu mes yeux.

J'ai découvert un logiciel Libre initialement prévu pour prévenir des tendinites qui répond parfaitement à ce besoin.

Installation

apt-get install xwrits
xwrits +idle=0:20 breaktime=15:00 typetime=120:00 +mouse +rp=/home/jean/Images/pause.gif +wp=/home/jean/Images/pause.gif

typetime=120:00
Pause toutes les 2 heures (120 minutes) d'activité sur l'ordi (clavier et souris grâce à +mouse)

breaktime=15:00
Pause de 15 minutes requis

+idle=0:20
Ne pas comptabiliser le temps d'inactivité (pas d'entrée clavier/souris pendant 20 secondes)

Les images doivent être au format GIF.

Reste à lancer cette commande après chaque ouverture de session. Avec mate-session-properties si vous êtes sous MateDesktop ou gnome-session-properties si vous êtes sous Gnome.

Workrave

Par défaut Workrave enregistre sa configuration dans ????? FIXME

Par itiliser un fichier ini, il suffit de créer le fichier

touch ~/.workrave/workrave.ini
2025/03/24 15:06

Faire fonctionner Adminer avec Sqlite

/var/www/usvn/public/adminer.php

<?php
function adminer_object() {
 
  class AdminerSoftware extends Adminer {
 
    function login($login, $password) {
      // validate user submitted credentials
      // return ($login == 'admin');
      return ($login == 'admin' && $password == 'P@ssw0rd');
    }
 
  }
 
  return new AdminerSoftware;
}
 
include 'adminer-4.6.1.php';
2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki