How do I get logs/details of ansible-playbook module executions?

后端 未结 6 1937
攒了一身酷
攒了一身酷 2020-12-22 18:45

Say I execute the following.

$ cat test.sh
#!/bin/bash
echo Hello World
exit 0

$ cat Hello.yml
---

- hosts: MyTestHost
  tasks:
  - name: Hello yourself
           


        
6条回答
  •  失恋的感觉
    2020-12-22 18:51

    If you pass the -v flag to ansible-playbook on the command line, you'll see the stdout and stderr for each task executed:

    $ ansible-playbook -v playbook.yaml
    

    Ansible also has built-in support for logging. Add the following lines to your ansible configuration file:

    [defaults] 
    log_path=/path/to/logfile
    

    Ansible will look in several places for the config file:

    • ansible.cfg in the current directory where you ran ansible-playbook
    • ~/.ansible.cfg
    • /etc/ansible/ansible.cfg

提交回复
热议问题