Project

General

Profile

Demande #5838

Utiliser ansible pour exécuter des commandes sur plusieurs machines de l'infra

Added by Pierre-Louis Bonicoli over 1 year ago. Updated 3 days ago.

Status:
En cours de traitement
Priority:
Normale
Category:
Task
Target version:
Start date:
03/30/2022
Due date:
% Done:

0%

Estimated time:
Difficulté:
2 Facile

Description

Utiliser ansible pour exécuter des commandes sur plusieurs machines de l'infra, à la do.sh

History

#1

Updated by Pierre-Louis Bonicoli over 1 year ago

  • Status changed from Nouveau to En cours de traitement

Tout semble déjà présent dans le dossier ansible du dépôt Git admin:

$ cd ansible
$ ansible agir -mcommand -a"hostname -f" 
agir | CHANGED | rc=0 >>
agir.cluster.april.org

J'ai testé le plugin d'inventaire libvirt:

$ cat libvirt.yml
plugin: community.libvirt.libvirt
uri: 'qemu+ssh://root@virola.april.org/system'
keyed_groups:
  - key:
    default_value: from_libvirt
    prefix: hosts

Il peut être utile pour détecter des VM qui ne seraient pas présentes dans l'inventaire ansible (ou des VMs présentes dans l'inventaire ansible mais inexistantes):
$ ansible localhost -i ansible_hosts -i libvirt.yml -mdebug -amsg="{{ groups['hosts_from_libvirt']|symmetric_difference(groups['cluster_vm']) }}" 
localhost | SUCCESS => {
    "msg": [
        "candidatsfr-clone",
        "pad-test",
        "spip",
        "drupal-test" 
    ]
}

Si le service QEMU Guest Agent était activé au sein des VMs, le plugin d'inventaire libvirt pourrait être utilisé pour se connecter aux VMs en passant par libvirt plutôt que par SSH:
ansible agir -i libvirt.yml -mcommand -auptime

#2

Updated by Quentin Gibeaux over 1 year ago

  • Target version changed from Avril 2022 to Mai 2022
#3

Updated by Pierre-Louis Bonicoli over 1 year ago

TODO:
  • documenter l'utilisation d'ansible pour l'exécution d'une commande sans playbook
  • ajouter un playbook pour mettre à jour les machines (attention à needrestart qui bloque en mode interactif)
  • documenter l'utilisation de ce playbook
#4

Updated by Pierre-Louis Bonicoli over 1 year ago

J'ai créé dans le wiki admin une entrée concernant Ansible et son utilisation.
b7d4fa45304b76a97cbc9308f7b1dcb66019c266 ajoute un playbook permettant de mettre à jour (apt) les machines.

#5

Updated by Quentin Gibeaux over 1 year ago

  • Target version changed from Mai 2022 to Juin 2022
#6

Updated by Quentin Gibeaux over 1 year ago

  • Target version changed from Juin 2022 to Été 2022
#7

Updated by Quentin Gibeaux over 1 year ago

  • Target version changed from Été 2022 to Septembre 2022
#8

Updated by Quentin Gibeaux about 1 year ago

  • Target version changed from Septembre 2022 to Octobre 2022
#9

Updated by Quentin Gibeaux about 1 year ago

  • Target version changed from Octobre 2022 to Novembre 2022
#10

Updated by Quentin Gibeaux about 1 year ago

  • Target version changed from Novembre 2022 to Décembre 2022
#11

Updated by Quentin Gibeaux 11 months ago

  • Target version changed from Décembre 2022 to Janvier 2023
#12

Updated by Quentin Gibeaux 10 months ago

  • Target version changed from Janvier 2023 to Février 2023
#13

Updated by Frédéric Couchet 9 months ago

  • Target version changed from Février 2023 to Mars 2023
#14

Updated by Quentin Gibeaux 8 months ago

  • Target version changed from Mars 2023 to Avril 2023
#15

Updated by Quentin Gibeaux 7 months ago

  • Target version changed from Avril 2023 to Mai 2023
#16

Updated by Quentin Gibeaux 6 months ago

  • Target version changed from Mai 2023 to Juin 2023
#17

Updated by Quentin Gibeaux 5 months ago

  • Target version changed from Juin 2023 to Été 2023
#18

Updated by Quentin Gibeaux 3 months ago

  • Target version changed from Été 2023 to Septembre 2023
#19

Updated by Quentin Gibeaux 2 months ago

  • Target version changed from Septembre 2023 to Octobre 2023
#20

Updated by Quentin Gibeaux about 1 month ago

  • Target version changed from Octobre 2023 to Novembre 2023
#21

Updated by Quentin Gibeaux 3 days ago

  • Target version changed from Novembre 2023 to Décembre 2023

Also available in: Atom PDF