ansible.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Thu, 16 Jan 2020 13:42:03 +0200
changeset 2403 f5347f511cb3
parent 2390 f2b450fa4f4b
child 2430 315b44793009
permissions -rw-r--r--
To search for string in commit messages.


=========
 Ansible
=========
.. contents::
   :local:

Debugging Ansible
=================

Pass ``-vvv`` to Ansible utilities::

  ansible -vvv ...
  ansible-playbook -vvv ...

To debug connection use ``-vvvv``::

  ansible -vvvv ...

To debug Python modules set ``ANSIBLE_KEEP_REMOTE_FILES`` to ``1`` (it causes Ansible to leave the
exact copy of the Python scripts it executed on the target machine)::

  ANSIBLE_KEEP_REMOTE_FILES=1  ansible ...

There is ``debugger`` keyword that triggers debugger, see `Ansible Debugger
<https://docs.ansible.com/ansible/latest/user_guide/playbooks_debugger.html>`_

To activate debugger on task::

  - name: Execute a command
    command: false
    debugger: on_failed

To activate debugger in ``ansible.cfg``::

  [defaults]
  enable_task_debugger = True

To activate debugger via env var::

  ANSIBLE_ENABLE_TASK_DEBUGGER=True ansible-playbook -i hosts site.yml

Use ``ansible-lint``::

  $ sudo apt install ansible-lint
  $ ansible-lint site.yml

https://docs.ansible.com/ansible/latest/network/user_guide/network_debug_troubleshooting.html
  Network Debug and Troubleshooting Guide.
https://stackoverflow.com/questions/42417079/how-to-debug-ansible-issues
  How to debug Ansible issues?