Print variable value with task debug. Search path.
--- a/ansible.rst Sun Oct 25 01:19:24 2020 +0300
+++ b/ansible.rst Mon Oct 26 12:51:23 2020 +0200
@@ -17,6 +17,14 @@
ansible -vvvv ...
+Print variable value with task ``debug``::
+
+ - debug: var=ansible_host
+ - debug:
+ var: ansible_host
+ - debug:
+ msg: "host is {{ ansible_host }}"
+
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)::
@@ -98,6 +106,16 @@
Files, templates, variables definitions are looked in ``files``, ``templates``, ``vars`` role / play
directories first, then in the base directory for role / play.
+https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html
+ You can also add ``group_vars/`` and ``host_vars/`` directories to your playbook
+ directory. The ansible-playbook command looks for these directories in the current
+ working directory by default. Other Ansible commands (for example, ansible,
+ ansible-console, and so on) will only look for ``group_vars/`` and ``host_vars/`` in the
+ inventory directory. If you want other commands to load group and host variables from a
+ playbook directory, you must provide the ``--playbook-dir`` option on the command line.
+ If you load inventory files from both the playbook directory and the inventory
+ directory, variables in the playbook directory will override variables set in the
+ inventory directory.
https://docs.ansible.com/ansible/latest/user_guide/playbook_pathing.html
Search paths in Ansible.