From 1821af750a892b9cc27bc85b8b957c5bed83be0d Mon Sep 17 00:00:00 2001 From: Mickael Asseline Date: Thu, 8 Jul 2021 17:52:12 +0000 Subject: [PATCH] docs: update Configuration/Ansible/Installation --- Configuration/Ansible/Installation.md | 108 +++++++++++++++++++++++--- 1 file changed, 96 insertions(+), 12 deletions(-) diff --git a/Configuration/Ansible/Installation.md b/Configuration/Ansible/Installation.md index 67d5ce4..276996c 100644 --- a/Configuration/Ansible/Installation.md +++ b/Configuration/Ansible/Installation.md @@ -2,7 +2,7 @@ title: Ansible - Installation et configuration description: Mettre en place Ansible dans son environnement published: true -date: 2021-07-08T17:46:26.598Z +date: 2021-07-08T17:52:10.797Z tags: ansible, configuration editor: markdown dateCreated: 2021-07-08T17:18:58.350Z @@ -175,6 +175,7 @@ ssh -F /dev/null xavki@monhost
+ ## Configuration Configuration de différentes manières : @@ -188,10 +189,6 @@ Et à différents endroits pour ansible.cfg (ordre inverse de prise en compte) - ~/.ansible/ansible.cfg - /etc/ansible/ansible.cfg - - - - Exemple : ```bash inventory = /etc/ansible/hosts @@ -210,18 +207,17 @@ pipelining = False Doc : https://docs.ansible.com/ansible/2.3/intro_configuration.html Commande : - +```bash ansible-config ansible-config view # voir le ansible.cfg pris en compte ansible-config list # toute les variables et leurs valeurs -cf : https://docs.ansible.com/ansible/latest/reference_appendices/config.html - ansible-config dump # liste toutes les variables ansible ansible-config dump --only-changed #valeurs par défaut modifiée +``` +cf : https://docs.ansible.com/ansible/latest/reference_appendices/config.html -exemple - - +Exemple : +```bash ANSIBLE_SSH_ARGS: default: -C -o ControlMaster=auto -o ControlPersist=60s description: @@ -236,4 +232,92 @@ ANSIBLE_SSH_ARGS: - key: ssh_args section: ssh_connection yaml: - key: ssh_connection.ssh_args \ No newline at end of file + key: ssh_connection.ssh_args +``` + +## Tuning +Host key checking = fingerprint +```bash +[defaults] +host_key_checking = False +``` + +Callback temps par action +```bash +[defaults] +callback_whitelist = profile_tasks +``` + +Pipelining +```bash +[ssh_connection] +pipelining = True +``` + +Principe par défaut : +- création fichier python +- création directory +- envoi fichier python via sftp +- run python +- récupération résultat + +Avec pipelining : +- génération du fichier python +- envoi sur le python interpreter distant via stdin +- récupération du stdout + +Rq: travailler sans fichier distant + +Partage de plusieurs sessions et augmentation de la persistence (connexion...) +```bash +[ssh_connection] +ssh_args = -o ControlMaster=auto -o ControlPersist=60s +``` +Doc : https://www.blog-libre.org/2019/05/11/loption-controlmaster-de-ssh_config/ + + +Spécifier le mode d'identification +```bash +[ssh_connection] +ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o PreferredAuthentications=publickey +``` + +fork = parallélisation +```bash +[defaults] +forks = 30 +``` + +gather facts avec précaution +```bash +gather_facts: no +``` + +gather facts caching par fichier +```bash +fact_caching = jsonfile +fact_caching_timeout = 3600 +fact_caching_connection = /tmp/mycachedir +``` + +gather facts caching par redis +```bash +fact_caching = redis +fact_caching_timeout = 3600 +fact_caching_connection = localhost:6379:0 +``` + +Mitogen + +Doc : https://mitogen.networkgenomics.com/ansible_detailed.html + + +cas ultime > ansible localhost >> ansible-pull (commande) + +chargement du code ansible sur le serveur distant + +cloud init > cron > ansible-pull + + +exécution en localhost +problème récupération des informations