Ansible: Default Variables Values

In Ansible it is recommended to set default values for variables to avoid undefined-variable errors: The task includes an option with an undefined variable. The default variables for a role can be defined in the defaults/main.yml file that might look something like this: nginx_version: 1.20.1 nginx_service_name: “nginx.service” Ansible will use the default values only if […]

Ansible: Check If File Exists

To check whether the destination file exists and then run tasks based on its status, we can use the Ansible’s stat module (or win_stat for Windows targets). With this module we can identify not only whether the destination path exists or not but also if it is a regular file, a directory or a symbolic […]

Ansible: Human-Readable Output Format

By default Ansible sends output of the plays, tasks and module arguments to STDOUT in the format that is not suitable for human reading. Starting from Ansible 2.5, the default output format can be changed to a human-readable using the callback plugin. This short note shows how to change the default Ansible’s JSON output format […]