Ansible - Network Debug and Troubleshooting

There may be some times when you are trying to run an ansible-playbook that you created but getting errors that you are not able to understand.

To understand why ansible-playbook is not working, we can enable debugging and logging to understand what is going wrong. Following are the steps to enable logging in ansible.

Before running ansible-playbook run the following commands to enable logging:

# Specify the location for the log file

export ANSIBLE_LOG_PATH=~/ansible.log

# Enable Debug


# Run with 4*v for connection level verbosity

ansible-playbook -vvvv ...

After Ansible has finished running you can inspect the log file which has been created on the ansible-controller:


2017-03-30 13:19:52,740 p=28990 u=fred |  creating new control socket for host veos01:22 as user admin
2017-03-30 13:19:52,741 p=28990 u=fred |  control socket path is /home/fred/.ansible/pc/ca5960d27a
2017-03-30 13:19:52,741 p=28990 u=fred |  current working directory is /home/fred/ansible/test/integration
2017-03-30 13:19:52,741 p=28990 u=fred |  using connection plugin network_cli
2017-03-30 13:20:14,771 paramiko.transport userauth is OK
2017-03-30 13:20:15,283 paramiko.transport Authentication (keyboard-interactive) successful!
2017-03-30 13:20:15,302 p=28990 u=fred |  ssh connection done, setting terminal
2017-03-30 13:20:15,321 p=28990 u=fred |  ssh connection has completed successfully
2017-03-30 13:20:15,322 p=28990 u=fred |  connection established to veos01 in 0:00:22.580626

To disable logging:

export ANSIBLE_DEBUG=False


Popular posts from this blog

Ansible-Playbook to display output of multiple show commands (using stdout_lines with Loop)

Filtering Routes in BGP using Route-maps and Prefix-list

Ansible-playbook for backing up running config of Cisco IOS

Ansible Playbook for Network OS Upgrade with pre and post checks

Cisco ASA Active/Active Failover Configuration

VMware NSX Traffic Flow — East-West & North-South

Export or Backup Azure Network Security Groups into CSV using PowerShell

Get Model Number and Serial number of Cisco devices using ios_facts module