Skip to content

ansible hello world

---
- name: Hello World Playbook
  hosts: localhost
  gather_facts: no
  tasks:
    - name: Print Hello World
      debug:
        msg: "Hello, World!"

Pour exécuter ce playbook, enregistrez-le dans un fichier nommé hello_world.yml et exécutez la commande suivante :

ansible-playbook hello_world.yml

La sortie devrait ressembler à ceci :

PLAY [Hello World Playbook] ****************************************************

TASK [Print Hello World] ******************************************************
ok: [localhost] => {
    "msg": "Hello, World!"
}

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

En ajoutant gather_facts: no, vous désactivez la collecte des faits, ce qui peut accélérer l'exécution du playbook si vous n'avez pas besoin de ces informations.