author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Tue, 13 Oct 2020 19:59:17 +0300 | |
changeset 2438 | f570bd31717d |
parent 2435 | 27921ee2c781 |
child 2439 | 7377cd066123 |
permissions | -rw-r--r-- |
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 |
||
2390
f2b450fa4f4b
Network Debug and Troubleshooting Guide.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2389
diff
changeset
|
48 |
https://docs.ansible.com/ansible/latest/network/user_guide/network_debug_troubleshooting.html |
f2b450fa4f4b
Network Debug and Troubleshooting Guide.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2389
diff
changeset
|
49 |
Network Debug and Troubleshooting Guide. |
2389 | 50 |
https://stackoverflow.com/questions/42417079/how-to-debug-ansible-issues |
51 |
How to debug Ansible issues? |
|
2430 | 52 |
|
53 |
Bash completion |
|
54 |
=============== |
|
55 |
||
56 |
https://github.com/ansible/ansible/issues/36397 |
|
57 |
Provide bash-completion script for ansible commands. |
|
58 |
https://docs.ansible.com/ansible/devel/installation_guide/intro_installation.html#shell-completion |
|
59 |
As of Ansible 2.9 shell completion of the ansible command line utilities is available and provided |
|
60 |
through an optional dependency called argcomplete. |
|
61 |
||
62 |
Ansible language |
|
63 |
================ |
|
64 |
||
65 |
https://docs.ansible.com/ansible/latest/user_guide/playbooks_module_defaults.html |
|
66 |
Module defaults. |
|
2435 | 67 |
https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html |
68 |
Magic variables. |
|
2438
f570bd31717d
Reserved keywords. Patterns: targeting hosts and groups. Using aliases & groups for hosts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2435
diff
changeset
|
69 |
https://docs.ansible.com/ansible/latest/reference_appendices/playbooks_keywords.html |
f570bd31717d
Reserved keywords. Patterns: targeting hosts and groups. Using aliases & groups for hosts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2435
diff
changeset
|
70 |
Reserved keywords. |
f570bd31717d
Reserved keywords. Patterns: targeting hosts and groups. Using aliases & groups for hosts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2435
diff
changeset
|
71 |
https://docs.ansible.com/ansible/latest/user_guide/intro_patterns.html |
f570bd31717d
Reserved keywords. Patterns: targeting hosts and groups. Using aliases & groups for hosts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2435
diff
changeset
|
72 |
Patterns: targeting hosts and groups. |
f570bd31717d
Reserved keywords. Patterns: targeting hosts and groups. Using aliases & groups for hosts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2435
diff
changeset
|
73 |
https://docs.ansible.com/ansible/latest/network/getting_started/first_inventory.html |
f570bd31717d
Reserved keywords. Patterns: targeting hosts and groups. Using aliases & groups for hosts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2435
diff
changeset
|
74 |
Using aliases & groups for hosts. |
2430 | 75 |
|
2435 | 76 |
Search path |
77 |
=========== |
|
78 |
||
79 |
Files, templates, variables definitions are looked in ``files``, ``templates``, ``vars`` role / play |
|
80 |
directories first, then in the base directory for role / play. |
|
81 |
||
82 |
https://docs.ansible.com/ansible/latest/user_guide/playbook_pathing.html |
|
83 |
Search paths in Ansible. |
|
84 |
||
85 |
Templates |
|
86 |
========= |
|
87 |
||
88 |
https://docs.ansible.com/ansible/latest/user_guide/playbooks_templating.html |
|
89 |
Templating (Jinja2). |
|
90 |