Printing Text or Variables in Ansible
Explore how to display messages and variable values using Ansible's debug module. Understand the usage of msg, var, and verbosity parameters to enhance playbook debugging and gain better visibility during automation tasks. This lesson helps you control output details and troubleshoot effectively.
We often need to print messages or the variable’s value in Ansible. The statements can be text, Ansible variables, facts, and so on.
Ansible debug module
The Ansible ansible.builtin.debug module is a useful tool for displaying information during playbook execution. It allows us to print specific variables or custom messages to the standard output, providing insights into the state of the system or playbook execution. The debug module is commonly used for debugging purposes, troubleshooting, or simply to gain more visibility into the Ansible playbook’s operations.
It can also be used to display messages, expressions, and variables in different formats, such as JSON, YAML, or plaintext. The output can be saved to a file or displayed in the console.