2389
|
1 |
|
|
2 |
=========
|
|
3 |
Ansible
|
|
4 |
=========
|
|
5 |
.. contents::
|
|
6 |
:local:
|
|
7 |
|
|
8 |
Debugging Ansible
|
|
9 |
=================
|
|
10 |
|
|
11 |
Pass ``-vvv`` to Ansible utilities::
|
|
12 |
|
|
13 |
ansible -vvv ...
|
|
14 |
ansible-playbook -vvv ...
|
|
15 |
|
|
16 |
To debug connection use ``-vvvv``::
|
|
17 |
|
|
18 |
ansible -vvvv ...
|
|
19 |
|
|
20 |
To debug Python modules set ``ANSIBLE_KEEP_REMOTE_FILES`` to ``1`` (it causes Ansible to leave the
|
|
21 |
exact copy of the Python scripts it executed on the target machine)::
|
|
22 |
|
|
23 |
ANSIBLE_KEEP_REMOTE_FILES=1 ansible ...
|
|
24 |
|
|
25 |
There is ``debugger`` keyword that triggers debugger, see `Ansible Debugger
|
|
26 |
<https://docs.ansible.com/ansible/latest/user_guide/playbooks_debugger.html>`_
|
|
27 |
|
|
28 |
To activate debugger on task::
|
|
29 |
|
|
30 |
- name: Execute a command
|
|
31 |
command: false
|
|
32 |
debugger: on_failed
|
|
33 |
|
|
34 |
To activate debugger in ``ansible.cfg``::
|
|
35 |
|
|
36 |
[defaults]
|
|
37 |
enable_task_debugger = True
|
|
38 |
|
|
39 |
To activate debugger via env var::
|
|
40 |
|
|
41 |
ANSIBLE_ENABLE_TASK_DEBUGGER=True ansible-playbook -i hosts site.yml
|
|
42 |
|
|
43 |
Use ``ansible-lint``::
|
|
44 |
|
|
45 |
$ sudo apt install ansible-lint
|
|
46 |
$ ansible-lint site.yml
|
|
47 |
|
|
48 |
https://stackoverflow.com/questions/42417079/how-to-debug-ansible-issues
|
|
49 |
How to debug Ansible issues?
|