DebugFactor.com | Forum

How to view Ansible logs for the jobs in Ansible CLI or Ansible Tower

I would like to see the detailed log for the ansible playbook in Ansible Tower/AWX/Ansible Core Please let me know if there is a way to achieve this.

There are multiple ways to achieve this.

  1. If you need to view the logs while running the job in Ansible CLI, then add -v to the ansible command.
    eg: ansible-playbook playbook.yml -v
    You can add upto 5 v’s for more details.
    eg: ansible-playbook playbook.yml -vvvvv

  2. Edit the below line in ansible.cfg to add the log path.
    log_path=/log/path/for/ansible
    You will be able to see all the job logs in this location.

To view the logs in Ansible Tower or AWX, navigate to jobs and search for the job name.
You could provide the verbose (1,2 or 3) in the job template to view detailed logs.

Additionaly, if you dont need logs to be printed you can add no_log: true in your tasks in the playbook. This will stop ansible from displaying passwords or other secure information in the job output.
eg:

- name: Do not show the logs
  command: <some commands>
  no_log: true